Beispiel #1
0
        public void PolicyAgentDocSerDeTest()
        {
            var job  = TenantJobHelper.CreateNewTenantJob();
            var jobs = new List <ITenantJob> {
                job
            };
            var doc = TenantJobHelper.CreateNewPolicyAgentDocumentForTenant(jobs, 1);

            // Note: do not use ToJson() since it uses public settings for serialization which means
            // that the object cannot be deserialized.
            string json = JsonConvert.SerializeObject(doc, internalSerializationSettings);
            var    doc2 = json.FromJson <MockPolicyAgentDocumentForTenant>();

            Assert.AreEqual(doc.Incarnation, doc2.Incarnation);
            Assert.AreEqual(doc.JobDocumentIncarnation, doc2.JobDocumentIncarnation);
            Assert.AreEqual(doc.RoleInstanceHealthInfoIncarnation, doc2.RoleInstanceHealthInfoIncarnation);
            Assert.AreEqual(doc.RoleInstanceHealthInfoTimestamp, doc2.RoleInstanceHealthInfoTimestamp);
            Assert.AreEqual(doc.Jobs.Count, doc2.Jobs.Count);
            Assert.AreEqual(doc.RoleInstanceHealthInfos.Count, doc2.RoleInstanceHealthInfos.Count);

            for (int i = 0; i < doc.Jobs.Count; i++)
            {
                Assert.AreEqual(doc.Jobs[i].Id, doc2.Jobs[i].Id);
                Assert.AreEqual(doc.Jobs[i].ContextStringGivenByTenant, doc2.Jobs[i].ContextStringGivenByTenant);
                Assert.AreEqual(doc.Jobs[i].JobStatus, doc2.Jobs[i].JobStatus);
                Assert.IsTrue(doc.Jobs[i].RoleInstancesToBeImpacted.SequenceEqual(doc2.Jobs[i].RoleInstancesToBeImpacted));
            }

            string json3 = JsonConvert.SerializeObject(doc2, internalSerializationSettings);

            Assert.AreEqual(json, json3);
        }
Beispiel #2
0
        public async Task BasicTest1Async()
        {
            var activityId = Guid.NewGuid();
            var job        = TenantJobHelper.CreateNewTenantJob();
            var jobs       = new List <ITenantJob> {
                job
            };

            var doc = TenantJobHelper.CreateNewPolicyAgentDocumentForTenant(jobs, 1);

            var coordinatorContext = new CoordinatorContext {
                Doc = doc
            };

            ActionHelper.CreateMappedWorkItems(jobs, new List <IRepairTask>(), coordinatorContext);

            await CreateReconciler().ReconcileAsync(activityId, coordinatorContext).ConfigureAwait(false);

            Assert.AreEqual(coordinatorContext.MappedTenantJobs[job.Id].Actions.Count, 1);
            var action = coordinatorContext.MappedTenantJobs[job.Id].Actions[0];

            Assert.IsTrue(action is CreateInPreparingAction, "Verifying if new repair task is being created");
        }
        public virtual Task <IPolicyAgentDocumentForTenant> GetDocumentAsync(Guid activityId, CancellationToken cancellationToken)
        {
            var doc = TenantJobHelper.CreateNewPolicyAgentDocumentForTenant(tenantJobs.Values.ToList(), jobDocIncarnation);

            return(Task.FromResult(doc));
        }