Example #1
0
        public async Task UpdatePolicyAsyncTest1Async()
        {
            var propertyManager = new MockPropertyManagerWrapper
            {
                SubmitPropertyBatchAsyncFunc = WorkflowForUpdatePolicyAsyncTest1
            };

            // mock a result where we return ok on initialize, then an error for the first operation
            // and return okay when an internal Read is called

            IJobBlockingPolicyManager jobPolicyManager = await CreateAsync(propertyManager).ConfigureAwait(false);

            try
            {
                await jobPolicyManager.UpdatePolicyAsync(JobBlockingPolicy.BlockNone).ConfigureAwait(false);

                Assert.Fail("Expected to throw an exception");
            }
            catch (FabricException ex)
            {
                Assert.AreEqual(
                    ex.ErrorCode,
                    FabricErrorCode.WriteConflict,
                    "Throwing FabricException as expected because of version mismatch");
            }

            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockAllJobs,
                "Update policy failed as expected, but reading policy from store succeeded");
        }
Example #2
0
        public async Task UpdatePolicyAsyncTest3Async()
        {
            var propertyManager = new MockPropertyManagerWrapper();

            propertyManager.SubmitPropertyBatchAsyncFunc = WorkflowForUpdatePolicyAsyncTest3;

            IJobBlockingPolicyManager jobPolicyManager = await CreateAsync(propertyManager).ConfigureAwait(false);

            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockNone,
                "Verifying if starting state of policy is as expected");

            await jobPolicyManager.UpdatePolicyAsync(JobBlockingPolicy.BlockAllJobs).ConfigureAwait(false);

            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockAllJobs,
                "Verifying if new policy has been successfully applied");
        }
Example #3
0
        public async Task MigrationToNamespacePrefixTestAsync()
        {
            var mockVersionedPropertyStore = new MockVersionedPropertyStore();

            IJobBlockingPolicyManager jobPolicyManager = await JobBlockingPolicyManager.CreateAsync(
                TraceType, mockVersionedPropertyStore).ConfigureAwait(false);

            Assert.AreEqual(jobPolicyManager.Policy, JobBlockingPolicy.BlockNone);

            await jobPolicyManager.UpdatePolicyAsync(JobBlockingPolicy.BlockAllJobs).ConfigureAwait(false);

            Assert.AreEqual(jobPolicyManager.Policy, JobBlockingPolicy.BlockAllJobs);

            // IS is migrated to parallel mode with per-tenant jobblocking policy option
            var mockTenantSpecificVersionedPropertyStore = new MockVersionedPropertyStore();
            IJobBlockingPolicyManager jobPolicyManager2  = await JobBlockingPolicyManager.CreateAsync(
                TraceType, mockTenantSpecificVersionedPropertyStore, mockVersionedPropertyStore).ConfigureAwait(false);

            // the namespace properties should have the same policy as the existing old properties
            Assert.AreEqual(jobPolicyManager2.Policy, JobBlockingPolicy.BlockAllJobs);

            var activityId = Guid.NewGuid();
            var vkv        = await mockVersionedPropertyStore
                             .GetValueAsync(activityId, JobBlockingPolicyManager.PolicyPropertyName, JobBlockingPolicyManager.PolicyVersionName)
                             .ConfigureAwait(false);

            Assert.IsNotNull(vkv);

            var vkv2 = await mockTenantSpecificVersionedPropertyStore
                       .GetValueAsync(activityId, JobBlockingPolicyManager.PolicyPropertyName, JobBlockingPolicyManager.PolicyVersionName)
                       .ConfigureAwait(false);

            Assert.IsNotNull(vkv2);

            Assert.AreEqual(vkv.Value, vkv2.Value);
        }