示例#1
0
            public async Task AlwaysOverridesMetadata()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "somemetadata";
                var success1 = await TryOptimisticWrite(_location, m, data).ConfigureAwait(false);

                var oldMetadata = await _store.GetMetadata(_location).ConfigureAwait(false);

                var m2 = new Metadata();

                m2.ETag         = oldMetadata.ETag;
                m2["metadata2"] = "othermetadata";
                var success2 = await TryOptimisticWrite(_location, m2, data).ConfigureAwait(false);

                var newMetadata = await _store.GetMetadata(_location).ConfigureAwait(false);

                await _blob.FetchAttributesAsync().ConfigureAwait(false);

                Assert.IsTrue(success1.Result, "first write failed");
                Assert.IsTrue(success2.Result, "second write failed");
                Assert.AreEqual(success1.Metadata.Snapshot, oldMetadata.Snapshot);
                Assert.AreEqual(success2.Metadata.Snapshot, newMetadata.Snapshot);
                Assert.AreNotEqual(success1.Metadata.Snapshot, success2.Metadata.Snapshot);
                Assert.IsFalse(_blob.Metadata.ContainsKey("metadata1"));
                Assert.AreEqual("othermetadata", _blob.Metadata["metadata2"]);
            }
示例#2
0
        public virtual void Init()
        {
            _store = new AzureStore(AzureTestsHelper.GetDevelopentService(), true);

            _blob     = AzureTestsHelper.GetBlockBlob("kalix-leo-tests", "AzureStoreTests.testdata", true);
            _location = new StoreLocation("kalix-leo-tests", "AzureStoreTests.testdata");
        }
示例#3
0
            public void AlwaysOverridesMetadata()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "somemetadata";
                var success1    = TryOptimisticWrite(_location, m, data);
                var oldMetadata = _store.GetMetadata(_location).Result;

                var m2 = new Metadata();

                m2.ETag         = oldMetadata.ETag;
                m2["metadata2"] = "othermetadata";
                var success2    = TryOptimisticWrite(_location, m2, data);
                var newMetadata = _store.GetMetadata(_location).Result;

                var props = _blob.GetProperties().Value;

                Assert.IsTrue(success1.Result, "first write failed");
                Assert.IsTrue(success2.Result, "second write failed");
                Assert.AreEqual(success1.Metadata.Snapshot, oldMetadata.Snapshot);
                Assert.AreEqual(success2.Metadata.Snapshot, newMetadata.Snapshot);
                Assert.AreNotEqual(success1.Metadata.Snapshot, success2.Metadata.Snapshot);
                Assert.IsFalse(props.Metadata.ContainsKey("metadata1"));
                Assert.AreEqual("B64_b3RoZXJtZXRhZGF0YQ==", props.Metadata["metadata2"]);
            }
示例#4
0
            public async Task MultiUploadLargeFileIsSuccessful()
            {
                var data = AzureTestsHelper.RandomData(7);

                await WriteData(_location, null, data).ConfigureAwait(false);

                Assert.IsTrue(await _blob.ExistsAsync().ConfigureAwait(false));
            }
示例#5
0
            public void MultiUploadLargeFileIsSuccessful()
            {
                var data = AzureTestsHelper.RandomData(7);

                WriteData(_location, null, data);

                Assert.IsTrue(_blob.Exists());
            }
示例#6
0
            public void NoETagMustBeNewSave()
            {
                var data     = AzureTestsHelper.RandomData(1);
                var success1 = TryOptimisticWrite(_location, null, data);
                var success2 = TryOptimisticWrite(_location, null, data);

                Assert.IsTrue(success1.Result, "first write failed");
                Assert.IsFalse(success2.Result, "second write succeeded");
            }
示例#7
0
            public void MultiUploadLargeFileIsSuccessful()
            {
                var data    = AzureTestsHelper.RandomData(7);
                var success = TryOptimisticWrite(_location, null, data);

                Assert.IsTrue(success.Result);
                Assert.IsNotNull(success.Metadata.Snapshot);
                Assert.IsTrue(_blob.Exists());
            }
示例#8
0
            public async Task MultiUploadLargeFileIsSuccessful()
            {
                var data    = AzureTestsHelper.RandomData(7);
                var success = await TryOptimisticWrite(_location, null, data).ConfigureAwait(false);

                Assert.IsTrue(success.Result);
                Assert.IsNotNull(success.Metadata.Snapshot);
                Assert.IsTrue(await _blob.ExistsAsync().ConfigureAwait(false));
            }
示例#9
0
            public async Task NoETagMustBeNewSave()
            {
                var data     = AzureTestsHelper.RandomData(1);
                var success1 = await TryOptimisticWrite(_location, null, data).ConfigureAwait(false);

                var success2 = await TryOptimisticWrite(_location, null, data).ConfigureAwait(false);

                Assert.IsTrue(success1.Result, "first write failed");
                Assert.IsFalse(success2.Result, "second write succeeded");
            }
示例#10
0
            public async Task WritesStoreVersion()
            {
                var data = AzureTestsHelper.RandomData(1);

                await WriteData(_location, null, data).ConfigureAwait(false);

                await _blob.FetchAttributesAsync().ConfigureAwait(false);

                Assert.AreEqual("2.0", _blob.Metadata["leoazureversion"]);
            }
示例#11
0
            public void ETagDoesNotMatchFails()
            {
                var data     = AzureTestsHelper.RandomData(1);
                var metadata = new Metadata {
                    ETag = "notreal"
                };
                var success = TryOptimisticWrite(_location, metadata, data);

                Assert.IsFalse(success.Result, "write should not have succeeded with fake eTag");
            }
示例#12
0
            public async Task DoesNotReturnInternalVersion()
            {
                var data = AzureTestsHelper.RandomData(1);

                await WriteData(_location, null, data).ConfigureAwait(false);

                var result = await _store.LoadData(_location).ConfigureAwait(false);

                Assert.IsFalse(result.Metadata.ContainsKey("leoazureversion"));
            }
示例#13
0
            public async Task ETagDoesNotMatchFails()
            {
                var data     = AzureTestsHelper.RandomData(1);
                var metadata = new Metadata {
                    ETag = "\"0x8D49E94826A33D9\""
                };
                var success = await TryOptimisticWrite(_location, metadata, data).ConfigureAwait(false);

                Assert.IsFalse(success.Result, "write should not have succeeded with fake eTag");
            }
示例#14
0
            public void WritesStoreVersion()
            {
                var data = AzureTestsHelper.RandomData(1);

                WriteData(_location, null, data);

                var props = _blob.GetProperties().Value;

                Assert.AreEqual("2.0", props.Metadata["leoazureversion"]);
            }
示例#15
0
            public void DoesNotReturnInternalVersion()
            {
                var data = AzureTestsHelper.RandomData(1);

                WriteData(_location, null, data);

                var result = _store.LoadData(_location).Result;

                Assert.IsFalse(result.Metadata.ContainsKey("leoazureversion"));
            }
示例#16
0
 public void IfFileLockedReturnsFalse()
 {
     Assert.ThrowsAsync <LockException>(async() =>
     {
         using (var l = await _store.Lock(_location).ConfigureAwait(false))
         {
             var data = AzureTestsHelper.RandomData(1);
             await WriteData(_location, null, data).ConfigureAwait(false);
         }
     });
 }
示例#17
0
            public void HasMetadataCorrectlySavesIt()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "somemetadata";
                WriteData(_location, m, data);

                var props = _blob.GetProperties().Value;

                Assert.AreEqual("B64_c29tZW1ldGFkYXRh", props.Metadata["metadata1"]);
            }
示例#18
0
            public void SingleSnapshotCanBeFound()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "metadata";
                WriteData(_location, m, data);

                var snapshots = _store.FindSnapshots(_location).ToEnumerable();

                Assert.AreEqual(1, snapshots.Count());
            }
示例#19
0
            public void FileMarkedAsDeletedReturnsNull()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["leodeleted"] = DateTime.UtcNow.Ticks.ToString();
                WriteData(_location, m, data);

                var result = _store.LoadData(_location).Result;

                Assert.IsNull(result);
            }
示例#20
0
            public async Task HasMetadataCorrectlySavesIt()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "somemetadata";
                await WriteData(_location, m, data).ConfigureAwait(false);

                await _blob.FetchAttributesAsync().ConfigureAwait(false);

                Assert.AreEqual("somemetadata", _blob.Metadata["metadata1"]);
            }
示例#21
0
            public async Task SingleSnapshotCanBeFound()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "metadata";
                await WriteData(_location, m, data).ConfigureAwait(false);

                var snapshots = await _store.FindSnapshots(_location).ToList().ConfigureAwait(false);

                Assert.AreEqual(1, snapshots.Count());
            }
示例#22
0
            public async Task BlobThatIsSoftDeletedShouldNotBeLoadable()
            {
                var data = AzureTestsHelper.RandomData(1);

                await WriteData(_location, null, data).ConfigureAwait(false);

                await _store.PermanentDelete(_location).ConfigureAwait(false);

                var result = await _store.LoadData(_location).ConfigureAwait(false);

                Assert.IsNull(result);
            }
示例#23
0
            public async Task FileMarkedAsDeletedReturnsNull()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["leodeleted"] = DateTime.UtcNow.Ticks.ToString();
                await WriteData(_location, m, data).ConfigureAwait(false);

                var result = await _store.LoadData(_location).ConfigureAwait(false);

                Assert.IsNull(result);
            }
示例#24
0
            public void BlobThatIsSoftDeletedShouldNotBeLoadable()
            {
                var data = AzureTestsHelper.RandomData(1);

                WriteData(_location, null, data);

                _store.PermanentDelete(_location).Wait();

                var result = _store.LoadData(_location).Result;

                Assert.IsNull(result);
            }
示例#25
0
            public void MetadataIsTransferedWhenSelectingAStream()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "metadata";
                var shapshot = WriteData(_location, m, data);

                var res = _store.LoadData(_location, shapshot).Result;

                Assert.AreEqual(shapshot, res.Metadata.Snapshot);
                Assert.AreEqual("metadata", res.Metadata["metadata1"]);
            }
示例#26
0
            public void ShouldDeleteAllSnapshots()
            {
                var data = AzureTestsHelper.RandomData(1);

                WriteData(_location, null, data);
                var shapshot = _store.FindSnapshots(_location).ToEnumerable().Single().Id;

                _store.PermanentDelete(_location).Wait();

                var result = _store.LoadData(_location, shapshot).Result;

                Assert.IsNull(result);
            }
示例#27
0
            public async Task MetadataIsTransferedWhenSelectingAStream()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "metadata";
                var shapshot = await WriteData(_location, m, data).ConfigureAwait(false);

                var res = await _store.LoadData(_location, shapshot).ConfigureAwait(false);

                Assert.AreEqual(shapshot, res.Metadata.Snapshot);
                Assert.AreEqual("metadata", res.Metadata["metadata1"]);
            }
示例#28
0
            public async Task ShouldDeleteAllSnapshots()
            {
                var data = AzureTestsHelper.RandomData(1);

                await WriteData(_location, null, data).ConfigureAwait(false);

                var shapshot = (await _store.FindSnapshots(_location).ToList().ConfigureAwait(false)).Single().Id;

                await _store.PermanentDelete(_location).ConfigureAwait(false);

                var result = await _store.LoadData(_location, shapshot).ConfigureAwait(false);

                Assert.IsNull(result);
            }
示例#29
0
            public void HasMetadataCorrectlySavesIt()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "somemetadata";
                var success = TryOptimisticWrite(_location, m, data);

                var props = _blob.GetProperties().Value;

                Assert.IsTrue(success.Result);
                Assert.IsNotNull(success.Metadata.Snapshot);
                Assert.AreEqual("B64_c29tZW1ldGFkYXRh", props.Metadata["metadata1"]);
            }
示例#30
0
            public async Task HasMetadataCorrectlySavesIt()
            {
                var data = AzureTestsHelper.RandomData(1);
                var m    = new Metadata();

                m["metadata1"] = "somemetadata";
                var success = await TryOptimisticWrite(_location, m, data).ConfigureAwait(false);

                await _blob.FetchAttributesAsync().ConfigureAwait(false);

                Assert.IsTrue(success.Result);
                Assert.IsNotNull(success.Metadata.Snapshot);
                Assert.AreEqual("somemetadata", _blob.Metadata["metadata1"]);
            }