Esempio n. 1
0
        public async Task RequestContext_ActivityId_CM_E2E()
        {
            Guid activityId     = Guid.NewGuid();
            Guid activityId2    = Guid.NewGuid();
            Guid nullActivityId = Guid.Empty;

            IRequestContextTestGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            Trace.CorrelationManager.ActivityId = activityId;
            Assert.Null(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));
            Guid result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId not propagated correctly"
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = nullActivityId;
            Assert.Null(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));
            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                result = await grain.E2EActivityId();

                Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"
            }
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = activityId2;
            Assert.Null(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));
            result = await grain.E2EActivityId();

            Assert.Equal(activityId2, result);   // "E2E ActivityId 2 not propagated correctly"
            RequestContext.Clear();
        }
Esempio n. 2
0
        public async Task RequestContext_ActivityId_CM_None_E2E()
        {
            Guid nullActivityId = Guid.Empty;

            IRequestContextTestGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            Guid result = grain.E2EActivityId().Result;

            Assert.Equal(nullActivityId, result);   // "E2E ActivityId should not exist"

            RequestContextTestUtils.SetActivityId(nullActivityId);
            Assert.Null(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));
            result = await grain.E2EActivityId();

            Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"
            RequestContext.Clear();

            RequestContextTestUtils.SetActivityId(nullActivityId);
            Assert.Null(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));
            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                result = await grain.E2EActivityId();

                Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"
            }
            RequestContext.Clear();
            RequestContextTestUtils.SetActivityId(nullActivityId);
            Assert.Null(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));
            result = await grain.E2EActivityId();

            Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"
            RequestContext.Clear();
        }
Esempio n. 3
0
        public async Task RequestContext_ActivityId_CM_None_E2E()
        {
            Guid nullActivityId = Guid.Empty;

            IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            Guid result = grain.E2EActivityId().Result;

            Assert.AreEqual(nullActivityId, result, "E2E ActivityId should not exist");

            Trace.CorrelationManager.ActivityId = nullActivityId;
            Assert.IsNull(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER), "No ActivityId context should be set");
            result = await grain.E2EActivityId();

            Assert.AreEqual(nullActivityId, result, "Null ActivityId propagated E2E incorrectly");
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = nullActivityId;
            Assert.IsNull(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER), "No ActivityId context should be set");
            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                result = await grain.E2EActivityId();

                Assert.AreEqual(nullActivityId, result, "Null ActivityId propagated E2E incorrectly");
            }
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = nullActivityId;
            Assert.IsNull(RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER), "No ActivityId context should be set");
            result = await grain.E2EActivityId();

            Assert.AreEqual(nullActivityId, result, "Null ActivityId propagated E2E incorrectly");
            RequestContext.Clear();
        }
Esempio n. 4
0
        public async Task RequestContext_ActivityId_RC_Set_E2E()
        {
            Guid activityId     = Guid.NewGuid();
            Guid activityId2    = Guid.NewGuid();
            Guid nullActivityId = Guid.Empty;

            IRequestContextTestGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            RequestContext.Set(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER, activityId);
            Guid result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId not propagated correctly"
            RequestContext.Clear();

            RequestContext.Set(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER, nullActivityId);
            result = await grain.E2EActivityId();

            Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"
            RequestContext.Clear();

            RequestContext.Set(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER, activityId2);
            result = await grain.E2EActivityId();

            Assert.Equal(activityId2, result);   // "E2E ActivityId 2 not propagated correctly"
            RequestContext.Clear();
        }
Esempio n. 5
0
        public async Task RequestContext_ActivityId_DynamicChange_Client()
        {
            Guid activityId = Guid.NewGuid();
            Guid activityId2 = Guid.NewGuid();

            IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain<IRequestContextTestGrain>(GetRandomGrainId());

            Trace.CorrelationManager.ActivityId = activityId;
            Guid result = await grain.E2EActivityId();
            Assert.AreEqual(activityId, result, "E2E ActivityId #1 not propagated correctly");
            RequestContext.Clear();

            RequestContext.PropagateActivityId = false;
            Console.WriteLine("Set RequestContext.PropagateActivityId={0}", RequestContext.PropagateActivityId);

            Trace.CorrelationManager.ActivityId = activityId2;
            result = await grain.E2EActivityId();
            Assert.AreEqual(Guid.Empty, result, "E2E ActivityId #2 not not have been propagated");
            RequestContext.Clear();

            RequestContext.PropagateActivityId = true;
            Console.WriteLine("Set RequestContext.PropagateActivityId={0}", RequestContext.PropagateActivityId);

            Trace.CorrelationManager.ActivityId = activityId2;
            result = await grain.E2EActivityId();
            Assert.AreEqual(activityId2, result, "E2E ActivityId #2 should have been propagated");
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = activityId;
            result = await grain.E2EActivityId();
            Assert.AreEqual(activityId, result, "E2E ActivityId #1 not propagated correctly after #2");
            RequestContext.Clear();
        }
        public async Task RequestContext_ActivityId_RC_None_E2E()
        {
            Guid nullActivityId = Guid.Empty;

            RequestContext.Clear();

            IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            Guid result = await grain.E2EActivityId();

            Assert.Equal(nullActivityId, result);   // "E2E ActivityId should not exist"

            result = await grain.E2EActivityId();

            Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"
            RequestContext.Clear();

            result = await grain.E2EActivityId();

            Assert.Equal(nullActivityId, result);                                                   // "E2E ActivityId 2 should not exist"
            Assert.Equal(null, RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER)); // "No ActivityId context should be set"

            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                Assert.Equal(null, RequestContext.Get(RequestContext.E2_E_TRACING_ACTIVITY_ID_HEADER));   // "No ActivityId context should be set"

                result = await grain.E2EActivityId();

                Assert.Equal(nullActivityId, result);   // "Null ActivityId propagated E2E incorrectly"

                RequestContext.Clear();
            }
        }
Esempio n. 7
0
 public async Task RequestContext_ActivityId_Simple()
 {
     Guid activityId = Guid.NewGuid();
     IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain<IRequestContextTestGrain>(GetRandomGrainId());
     Trace.CorrelationManager.ActivityId = activityId;
     Guid result = await grain.E2EActivityId();
     Assert.AreEqual(activityId, result, "E2E ActivityId not propagated correctly");
 }
Esempio n. 8
0
        public async Task RequestContext_ActivityId_CM_DynamicChange_Server()
        {
            Guid activityId  = Guid.NewGuid();
            Guid activityId2 = Guid.NewGuid();

            const string PropagateActivityIdConfigKey = @"/OrleansConfiguration/Defaults/Tracing/@PropagateActivityId";
            var          changeConfig = new Dictionary <string, string>();

            IManagementGrain mgmtGrain = this.fixture.GrainFactory.GetGrain <IManagementGrain>(0);

            IRequestContextTestGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            RequestContextTestUtils.SetActivityId(activityId);
            Guid result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId #1 not propagated correctly"
            RequestContext.Clear();

            changeConfig[PropagateActivityIdConfigKey] = Boolean.FalseString;
            output.WriteLine("Set {0}={1}", PropagateActivityIdConfigKey, changeConfig[PropagateActivityIdConfigKey]);
            await mgmtGrain.UpdateConfiguration(null, changeConfig, null);

            RequestContextTestUtils.SetActivityId(activityId2);
            result = await grain.E2EActivityId();

            Assert.NotEqual(activityId2, result); // "E2E ActivityId #2 should not have been propagated"
            Assert.Equal(Guid.Empty, result);     // "E2E ActivityId #2 should not have been propagated"
            RequestContext.Clear();

            changeConfig[PropagateActivityIdConfigKey] = Boolean.TrueString;
            output.WriteLine("Set {0}={1}", PropagateActivityIdConfigKey, changeConfig[PropagateActivityIdConfigKey]);
            await mgmtGrain.UpdateConfiguration(null, changeConfig, null);

            RequestContextTestUtils.SetActivityId(activityId2);
            result = await grain.E2EActivityId();

            Assert.Equal(activityId2, result);   // "E2E ActivityId #2 should have been propagated"
            RequestContext.Clear();

            RequestContextTestUtils.SetActivityId(activityId);
            result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId #1 not propagated correctly after #2"
            RequestContext.Clear();
        }
Esempio n. 9
0
        public async Task RequestContext_ActivityId_DynamicChange_Server()
        {
            Guid activityId  = Guid.NewGuid();
            Guid activityId2 = Guid.NewGuid();

            const string PropagateActivityIdConfigKey = @"/OrleansConfiguration/Defaults/Tracing/@PropagateActivityId";
            var          changeConfig = new Dictionary <string, string>();

            IManagementGrain mgmtGrain = GrainClient.GrainFactory.GetGrain <IManagementGrain>(RuntimeInterfaceConstants.SYSTEM_MANAGEMENT_ID);

            IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            Trace.CorrelationManager.ActivityId = activityId;
            Guid result = await grain.E2EActivityId();

            Assert.AreEqual(activityId, result, "E2E ActivityId #1 not propagated correctly");
            RequestContext.Clear();

            changeConfig[PropagateActivityIdConfigKey] = Boolean.FalseString;
            output.WriteLine("Set {0}={1}", PropagateActivityIdConfigKey, changeConfig[PropagateActivityIdConfigKey]);
            await mgmtGrain.UpdateConfiguration(null, changeConfig, null);

            Trace.CorrelationManager.ActivityId = activityId2;
            result = await grain.E2EActivityId();

            Assert.AreNotEqual(activityId2, result, "E2E ActivityId #2 should not have been propagated");
            Assert.AreEqual(Guid.Empty, result, "E2E ActivityId #2 should not have been propagated");
            RequestContext.Clear();

            changeConfig[PropagateActivityIdConfigKey] = Boolean.TrueString;
            output.WriteLine("Set {0}={1}", PropagateActivityIdConfigKey, changeConfig[PropagateActivityIdConfigKey]);
            await mgmtGrain.UpdateConfiguration(null, changeConfig, null);

            Trace.CorrelationManager.ActivityId = activityId2;
            result = await grain.E2EActivityId();

            Assert.AreEqual(activityId2, result, "E2E ActivityId #2 should have been propagated");
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = activityId;
            result = await grain.E2EActivityId();

            Assert.AreEqual(activityId, result, "E2E ActivityId #1 not propagated correctly after #2");
            RequestContext.Clear();
        }
Esempio n. 10
0
        public async Task RequestContext_ActivityId_Simple()
        {
            Guid activityId = Guid.NewGuid();
            IRequestContextTestGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            RequestContextTestUtils.SetActivityId(activityId);
            Guid result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId not propagated correctly"
        }
Esempio n. 11
0
        public async Task RequestContext_ActivityId_DynamicChange_Client()
        {
            Guid activityId  = Guid.NewGuid();
            Guid activityId2 = Guid.NewGuid();

            IRequestContextTestGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            RequestContextTestUtils.SetActivityId(activityId);
            Guid result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId #1 not propagated correctly"
            RequestContext.Clear();

            RequestContext.PropagateActivityId = false;
            output.WriteLine("Set RequestContext.PropagateActivityId={0}", RequestContext.PropagateActivityId);

            RequestContextTestUtils.SetActivityId(activityId2);
            result = await grain.E2EActivityId();

            Assert.Equal(Guid.Empty, result);   // "E2E ActivityId #2 not not have been propagated"
            RequestContext.Clear();

            RequestContext.PropagateActivityId = true;
            output.WriteLine("Set RequestContext.PropagateActivityId={0}", RequestContext.PropagateActivityId);

            RequestContextTestUtils.SetActivityId(activityId2);
            result = await grain.E2EActivityId();

            Assert.Equal(activityId2, result);   // "E2E ActivityId #2 should have been propagated"
            RequestContext.Clear();

            RequestContextTestUtils.SetActivityId(activityId);
            result = await grain.E2EActivityId();

            Assert.Equal(activityId, result);   // "E2E ActivityId #1 not propagated correctly after #2"
            RequestContext.Clear();
        }