public void AssociateSearchIndexWithBucketViaProperties() { var properties = new RiakBucketProperties(); properties.SetSearchIndex("famous"); var rslt = client.SetBucketProperties("cats", properties); CheckResult(rslt); }
public void WhenAddingAndRemovingPreAndPostCommitHooksThingsWorkAsExpected() { var props = new RiakBucketProperties() .AddPreCommitHook(new RiakJavascriptCommitHook("some_fun")) .AddPreCommitHook(new RiakJavascriptCommitHook("some_fun")) .AddPreCommitHook(new RiakErlangCommitHook("mod", "fun")) .AddPreCommitHook(new RiakErlangCommitHook("mod", "fun")) .AddPreCommitHook(new RiakErlangCommitHook("riak_search_kv_hook", "precommit")) .AddPreCommitHook(new RiakErlangCommitHook("riak_search_kv_hook", "precommit")) .AddPreCommitHook(RiakErlangCommitHook.RiakLegacySearchCommitHook) .AddPostCommitHook(new RiakErlangCommitHook("mod", "fun")) .AddPostCommitHook(new RiakErlangCommitHook("mod", "fun")); props.PreCommitHooks.Count.ShouldEqual(2); props.PostCommitHooks.Count.ShouldEqual(1); // setting search should not change commit hook count props.SetLegacySearch(true); props.PreCommitHooks.Count.ShouldEqual(2); props.PostCommitHooks.Count.ShouldEqual(1); // setting search should not change commit hook count props.SetLegacySearch(false); props.PreCommitHooks.Count.ShouldEqual(2); props.PostCommitHooks.Count.ShouldEqual(1); props.PreCommitHooks.Where(x => x is RiakErlangCommitHook).Cast<RiakErlangCommitHook>() .Any(x => x.Function == RiakErlangCommitHook.RiakLegacySearchCommitHook.Function && x.Function == RiakErlangCommitHook.RiakLegacySearchCommitHook.Function) .ShouldBeFalse(); }
public void WhenDisablingRiakLegacySearchOnBucketWithoutLegacySearchEnabledPreCommitHooksAreLeftAlone() { var props = new RiakBucketProperties() .AddPreCommitHook(new RiakErlangCommitHook("foo", "bar")) .SetLegacySearch(false); props.PreCommitHooks.Count.ShouldEqual(1); }
public void WhenEnablingRiakLegacySearchOnBucketPreCommitHookIsAdded() { var props = new RiakBucketProperties() .AddPreCommitHook(new RiakErlangCommitHook("foo", "bar")) .SetLegacySearch(true); props.PreCommitHooks.Count.ShouldEqual(1); props.LegacySearch.ShouldEqual(true); }
public void WhenDisablingRiakLegacySearchOnBucketPreCommitHookIsRemoved() { var props = new RiakBucketProperties() .AddPreCommitHook(new RiakErlangCommitHook("foo", "bar")) .SetLegacySearch(true); props.PreCommitHooks.Count.ShouldEqual(1); props.LegacySearch.ShouldEqual(true); props.SetLegacySearch(false); props.LegacySearch.ShouldNotEqual(true); ((RiakErlangCommitHook)props.PreCommitHooks[0]).Function.ShouldEqual("bar"); }
public void SettingPropertiesOnNewBucketWorksCorrectly() { RiakBucketProperties props = new RiakBucketProperties() .SetNVal((NVal)4) .SetLegacySearch(true) .SetW((Quorum)"all") .SetR((Quorum)"quorum"); var setResult = Client.SetBucketProperties(bucket, props); setResult.IsSuccess.ShouldBeTrue(setResult.ErrorMessage); Func<RiakResult<RiakBucketProperties>> getFunc = () => { var getResult = Client.GetBucketProperties(bucket); getResult.IsSuccess.ShouldBeTrue(getResult.ErrorMessage); return getResult; }; Func<RiakResult<RiakBucketProperties>, bool> successFunc = (r) => { bool rv = false; RiakBucketProperties p = r.Value; if (p.NVal == 4) { rv = true; props = p; } return rv; }; getFunc.WaitUntil(successFunc); props.NVal.ShouldNotBeNull(); ((int)props.NVal).ShouldEqual(4); props.LegacySearch.ShouldNotEqual(null); props.LegacySearch.Value.ShouldBeTrue(); props.W.ShouldEqual(Quorum.WellKnown.All); props.R.ShouldEqual(Quorum.WellKnown.Quorum); }
public void WhenRoundtrippingHllPrecisionItShouldStayTheSame() { var defaultProps = new RiakBucketProperties(); var defaultRpbBucketProps = defaultProps.ToMessage(); var newDefaultProps = new RiakBucketProperties(defaultRpbBucketProps); Assert.IsFalse(newDefaultProps.HllPrecision.HasValue); var props = new RiakBucketProperties().SetHllPrecision(14); var rpbBucketProps = props.ToMessage(); var newProps = new RiakBucketProperties(rpbBucketProps); Assert.IsTrue(newProps.HllPrecision.HasValue); Assert.AreEqual(14, newProps.HllPrecision.Value); }
public void WhenEnablingSearchOnABucketItSetsPropertiesCorrectly() { var props = new RiakBucketProperties().SetSearchIndex("foo"); Assert.AreEqual("foo", props.SearchIndex); var rpbMessageProps = props.ToMessage(); Assert.AreEqual("foo", rpbMessageProps.search_index.FromRiakString()); }
public void TestConsistentPropertyIsNullOnNewProps() { var props = new RiakBucketProperties(); props.Consistent.HasValue.ShouldBeFalse(); }
public void ResettingBucketPropertiesWorksCorrectly() { var props = new RiakBucketProperties() .SetAllowMultiple(true) .SetDw(10) .SetW(5) .SetLastWriteWins(true); var setPropsResult = Client.SetBucketProperties(bucket, props); setPropsResult.IsSuccess.ShouldBeTrue(setPropsResult.ErrorMessage); Func<RiakResult<RiakBucketProperties>> getFunc = () => { var getResult = Client.GetBucketProperties(bucket); getResult.IsSuccess.ShouldBeTrue(getResult.ErrorMessage); return getResult; }; Func<RiakResult<RiakBucketProperties>, bool> successFunc = (r) => { bool rv = false; if (r.Value.AllowMultiple == props.AllowMultiple && r.Value.LastWriteWins == props.LastWriteWins) { rv = true; } return rv; }; getFunc.WaitUntil(successFunc); var resetResult = Client.ResetBucketProperties(bucket); resetResult.IsSuccess.ShouldBeTrue(resetResult.ErrorMessage); RiakBucketProperties resetProps = null; successFunc = (r) => { bool rv = false; if (r.Value.AllowMultiple != props.AllowMultiple && r.Value.LastWriteWins != props.LastWriteWins) { rv = true; resetProps = r.Value; } return rv; }; getFunc.WaitUntil(successFunc); resetProps.AllowMultiple.ShouldNotEqual(props.AllowMultiple); resetProps.Dw.ShouldNotEqual(props.Dw); resetProps.W.ShouldNotEqual(props.W); resetProps.LastWriteWins.ShouldNotEqual(props.LastWriteWins); }
private ICollection<RiakObjectId> PutAnimals() { var properties = new RiakBucketProperties(); properties.SetSearchIndex("famous"); var bucketPropsResult = client.SetBucketProperties("animals", "cats", properties); CheckResult(bucketPropsResult); // Note: objects will be deleted on teardown unless CLEANUP is *undefined* var ids = new List<RiakObjectId>(); var lionoId = new RiakObjectId("animals", "cats", "liono"); ids.Add(lionoId); var lionoObj = new { name_s = "Lion-o", age_i = 30, leader_b = true }; var lionoRiakObj = new RiakObject(lionoId, lionoObj); var cheetaraId = new RiakObjectId("animals", "cats", "cheetara"); ids.Add(cheetaraId); var cheetaraObj = new { name_s = "Cheetara", age_i = 30, leader_b = false }; var cheetaraRiakObj = new RiakObject(cheetaraId, cheetaraObj); var snarfId = new RiakObjectId("animals", "cats", "snarf"); ids.Add(snarfId); var snarfObj = new { name_s = "Snarf", age_i = 43, leader_b = false }; var snarfRiakObj = new RiakObject(snarfId, snarfObj); var panthroId = new RiakObjectId("animals", "cats", "panthro"); ids.Add(panthroId); var panthroObj = new { name_s = "Panthro", age_i = 36, leader_b = false }; var panthroRiakObj = new RiakObject(panthroId, panthroObj); var rslts = client.Put(new[] { lionoRiakObj, cheetaraRiakObj, snarfRiakObj, panthroRiakObj }); foreach (var rslt in rslts) { CheckResult(rslt); } Thread.Sleep(2000); return ids; }
public void SetBucketProperties(string bucket, RiakBucketProperties properties, Action <RiakResult> callback) { ExecAsync(() => callback(_client.SetBucketProperties(bucket, properties))); }
public Task <RiakResult> SetBucketProperties(string bucket, RiakBucketProperties properties) { return(Task.Factory.StartNew(() => _client.SetBucketProperties(bucket, properties))); }
public override void SetUp() { base.SetUp(); Bucket = System.Guid.NewGuid().ToString(); CreateObjects(Bucket); var props = new RiakBucketProperties().SetAllowMultiple(true); Client.SetBucketProperties(Bucket, props); }
public override void SetUp() { base.SetUp(); CreateLinkedObjects(TestBucket); var props = new RiakBucketProperties().SetAllowMultiple(false); Client.SetBucketProperties(TestBucket, props); }
public void ResettingBucketPropertiesWorksCorrectly() { var props = new RiakBucketProperties() .SetAllowMultiple(true) .SetDw(10) .SetW(5) .SetLastWriteWins(true); var setPropsResult = Client.SetBucketProperties(bucket, props); setPropsResult.IsSuccess.ShouldBeTrue(setPropsResult.ErrorMessage); Func <RiakResult <RiakBucketProperties> > getFunc = () => { var getResult = Client.GetBucketProperties(bucket); getResult.IsSuccess.ShouldBeTrue(getResult.ErrorMessage); return(getResult); }; Func <RiakResult <RiakBucketProperties>, bool> successFunc = (r) => { bool rv = false; if (r.Value.AllowMultiple == props.AllowMultiple && r.Value.LastWriteWins == props.LastWriteWins) { rv = true; } return(rv); }; getFunc.WaitUntil(successFunc); var resetResult = Client.ResetBucketProperties(bucket); resetResult.IsSuccess.ShouldBeTrue(resetResult.ErrorMessage); RiakBucketProperties resetProps = null; successFunc = (r) => { bool rv = false; if (r.Value.AllowMultiple != props.AllowMultiple && r.Value.LastWriteWins != props.LastWriteWins) { rv = true; resetProps = r.Value; } return(rv); }; getFunc.WaitUntil(successFunc); resetProps.AllowMultiple.ShouldNotEqual(props.AllowMultiple); resetProps.Dw.ShouldNotEqual(props.Dw); resetProps.W.ShouldNotEqual(props.W); resetProps.LastWriteWins.ShouldNotEqual(props.LastWriteWins); }