public void Can_Fetch_Preflist() { RiakMinVersion(2, 1, 0); var fetch = new FetchPreflist.Builder() .WithBucketType(BucketType) .WithBucket(Bucket) .WithKey("key_1") .Build(); RiakResult rslt = client.Execute(fetch); if (rslt.IsSuccess) { PreflistResponse response = fetch.Response; Assert.IsNotNull(response); Assert.AreEqual(3, response.Value.Count()); } else { // TODO: remove this else case when this fix is in Riak: // https://github.com/basho/riak_kv/pull/1116 // https://github.com/basho/riak_core/issues/706 bool foundMessage = (rslt.ErrorMessage.IndexOf("Permission denied") >= 0 && rslt.ErrorMessage.IndexOf("riak_kv.get_preflist") >= 0) || (rslt.ErrorMessage.IndexOf("error:badarg") >= 0 && rslt.ErrorMessage.IndexOf("characters_to_binary") >= 0); Assert.True(foundMessage, rslt.ErrorMessage); } }
public void Should_Construct_PreflistResponse_From_Resp() { string node_name = "node-foo"; long partitionId = long.MaxValue; var preflistItem = new RpbBucketKeyPreflistItem(); preflistItem.node = RiakString.ToBytes(node_name); preflistItem.partition = partitionId; preflistItem.primary = true; var fetchResp = new RpbGetBucketKeyPreflistResp(); fetchResp.preflist.Add(preflistItem); var fetch = new FetchPreflist.Builder() .WithBucketType(BucketType) .WithBucket(Bucket) .WithKey(Key) .Build(); fetch.OnSuccess(fetchResp); Assert.AreEqual(1, fetch.Response.Value.Count()); }
public void Should_Build_Req_Correctly() { var fetch = new FetchPreflist.Builder() .WithBucketType(BucketType) .WithBucket(Bucket) .WithKey(Key) .Build(); RpbGetBucketKeyPreflistReq protobuf = (RpbGetBucketKeyPreflistReq)fetch.ConstructPbRequest(); Assert.AreEqual(BucketType, RiakString.FromBytes(protobuf.type)); Assert.AreEqual(Bucket, RiakString.FromBytes(protobuf.bucket)); Assert.AreEqual(Key, RiakString.FromBytes(protobuf.key)); }