コード例 #1
0
ファイル: UpdateBlobTest.cs プロジェクト: ksunair/Yams
        public async Task TestRemoveInstanceId()
        {
            IUpdateBlob updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId");

            updateBlob.SetUpdateDomain("1");
            updateBlob.AddInstance("instanceId1");
            updateBlob.AddInstance("instanceId2");
            await updateBlob.FlushAndRelease();

            updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId");
            updateBlob.RemoveInstance("instanceId1");
            await updateBlob.FlushAndRelease();

            await updateBlob.TryLock();
            Assert.Equal("1", updateBlob.GetUpdateDomain());
            AssertUtils.ContainsSameElementsInAnyOrder(new[] { "instanceId2" }, updateBlob.GetInstanceIds());
            await updateBlob.Release();

            updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId");
            updateBlob.RemoveInstance("instanceId2");
            await updateBlob.FlushAndRelease();

            await updateBlob.TryLock();
            Assert.True(string.IsNullOrEmpty(updateBlob.GetUpdateDomain()));
            Assert.Empty(updateBlob.GetInstanceIds());
        }
コード例 #2
0
ファイル: UpdateBlobTest.cs プロジェクト: ksunair/Yams
 public async Task TestThatUpdateBlobMustBeLockedBeforeAnyOperation()
 {
     IUpdateBlob updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId");
     await updateBlob.FlushAndRelease();
     Assert.Throws<InvalidOperationException>(() => updateBlob.GetUpdateDomain());
     Assert.Throws<InvalidOperationException>(() => updateBlob.GetInstanceIds());
     Assert.Throws<InvalidOperationException>(() => updateBlob.AddInstance("1"));
     Assert.Throws<InvalidOperationException>(() => updateBlob.RemoveInstance("1"));
     Assert.Throws<InvalidOperationException>(() => updateBlob.SetUpdateDomain("1"));
     await Assert.ThrowsAsync<InvalidOperationException>(async () => await updateBlob.FlushAndRelease());
 }
コード例 #3
0
        public async Task EndUpdateSession(string applicationId)
        {
            using (IUpdateBlob updateBlob = await _updateBlobFactory.TryLockUpdateBlob(applicationId))
            {
                Trace.TraceInformation(
                    $"Instance {_instanceId} Will attempt to end the update session for " +
                    $"ApplicationId = {applicationId}, " +
                    $"UpdateDomain = {_instanceUpdateDomain}");

                updateBlob.RemoveInstance(_instanceId);
                await updateBlob.FlushAndRelease();

                Trace.TraceInformation(
                    $"Instance {_instanceId} successfully ended the update session for " +
                    $"ApplicationId = {applicationId}, " +
                    $"UpdateDomain = {_instanceUpdateDomain}");
            }
        }