Exemple #1
0
        public async Task ClientInvokeCallback_SetActivityId()
        {
            Guid setActivityId = Guid.NewGuid();
            Guid activityId2   = Guid.NewGuid();

            RequestContextTestUtils.SetActivityId(activityId2);
            TestClientInvokeCallback callback = new TestClientInvokeCallback(output, setActivityId);

            this.runtimeClient.ClientInvokeCallback = callback.OnInvoke;
            IRequestContextProxyGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextProxyGrain>(GetRandomGrainId());

            Guid activityId = await grain.E2EActivityId();

            Assert.Equal(setActivityId, activityId); // "E2EActivityId Call#1"
            Assert.Equal(1, callback.TotalCalls);    // "Number of callbacks"

            RequestContextTestUtils.SetActivityId(Guid.Empty);
            RequestContext.Clear(); // Need this to clear out any old ActivityId value cached in RequestContext. Code optimization in RequestContext does not unset entry if Trace.CorrelationManager.ActivityId == Guid.Empty [which is the "normal" case]
            this.runtimeClient.ClientInvokeCallback = null;

            activityId = await grain.E2EActivityId();

            Assert.Equal(Guid.Empty, activityId);   // "E2EActivityId Call#2 == Zero"
            Assert.Equal(1, callback.TotalCalls);   // "Number of callbacks - should be unchanged"
        }
Exemple #2
0
        public async Task ClientInvokeCallback_SetActivityId()
        {
            Guid setActivityId = Guid.NewGuid();
            Guid activityId2   = Guid.NewGuid();

            Trace.CorrelationManager.ActivityId = activityId2; // Set up initial value that will be overridden by the callback function

            TestClientInvokeCallback callback = new TestClientInvokeCallback(setActivityId);

            GrainClient.ClientInvokeCallback = callback.OnInvoke;
            IRequestContextProxyGrain grain = GrainClient.GrainFactory.GetGrain <IRequestContextProxyGrain>(GetRandomGrainId());

            Guid activityId = await grain.E2EActivityId();

            Assert.AreEqual(setActivityId, activityId, "E2EActivityId Call#1");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks");

            Trace.CorrelationManager.ActivityId = Guid.Empty;
            RequestContext.Clear(); // Need this to clear out any old ActivityId value cached in RequestContext. Code optimization in RequestContext does not unset entry if Trace.CorrelationManager.ActivityId == Guid.Empty [which is the "normal" case]
            GrainClient.ClientInvokeCallback = null;

            activityId = await grain.E2EActivityId();

            Assert.AreEqual(Guid.Empty, activityId, "E2EActivityId Call#2 == Zero");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks - should be unchanged");
        }
Exemple #3
0
        public async Task ClientInvokeCallback_GrainObserver()
        {
            TestClientInvokeCallback callback = new TestClientInvokeCallback(Guid.Empty);
            GrainClient.ClientInvokeCallback = callback.OnInvoke;
            RequestContextGrainObserver observer = new RequestContextGrainObserver(null, null);
            // CreateObjectReference will result in system target call to IClientObserverRegistrar.
            // We want to make sure this does not invoke ClientInvokeCallback.
            ISimpleGrainObserver reference = await GrainClient.GrainFactory.CreateObjectReference<ISimpleGrainObserver>(observer);

            GC.KeepAlive(observer);
            Assert.AreEqual(0, callback.TotalCalls, "Number of callbacks");
        }
Exemple #4
0
        public async Task ClientInvokeCallback_CountCallbacks()
        {
            TestClientInvokeCallback callback = new TestClientInvokeCallback(Guid.Empty);
            GrainClient.ClientInvokeCallback = callback.OnInvoke;
            IRequestContextProxyGrain grain = GrainClient.GrainFactory.GetGrain<IRequestContextProxyGrain>(GetRandomGrainId());

            Trace.CorrelationManager.ActivityId = Guid.Empty;
            Guid activityId = await grain.E2EActivityId();
            Assert.AreEqual(Guid.Empty, activityId, "E2EActivityId Call#1");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks");

            GrainClient.ClientInvokeCallback = null;
            activityId = await grain.E2EActivityId();
            Assert.AreEqual(Guid.Empty, activityId, "E2EActivityId Call#2");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks - should be unchanged");
        }
Exemple #5
0
        public async Task ClientInvokeCallback_CountCallbacks()
        {
            TestClientInvokeCallback callback = new TestClientInvokeCallback(output, Guid.Empty);

            this.runtimeClient.ClientInvokeCallback = callback.OnInvoke;
            IRequestContextProxyGrain grain = this.fixture.GrainFactory.GetGrain <IRequestContextProxyGrain>(GetRandomGrainId());

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

            Assert.Equal(Guid.Empty, activityId);   // "E2EActivityId Call#1"
            Assert.Equal(1, callback.TotalCalls);   // "Number of callbacks"

            this.runtimeClient.ClientInvokeCallback = null;
            activityId = await grain.E2EActivityId();

            Assert.Equal(Guid.Empty, activityId);   // "E2EActivityId Call#2"
            Assert.Equal(1, callback.TotalCalls);   // "Number of callbacks - should be unchanged"
        }
        public async Task ClientInvokeCallback_GrainObserver()
        {
            TestClientInvokeCallback callback = new TestClientInvokeCallback(Guid.Empty);
            GrainClient.ClientInvokeCallback = callback.OnInvoke;
            RequestContextGrainObserver observer = new RequestContextGrainObserver(null, null);
            // CreateObjectReference will result in system target call to IClientObserverRegistrar.
            // We want to make sure this does not invoke ClientInvokeCallback.
            ISimpleGrainObserver reference = await GrainClient.GrainFactory.CreateObjectReference<ISimpleGrainObserver>(observer);

            GC.KeepAlive(observer);
            Assert.AreEqual(0, callback.TotalCalls, "Number of callbacks");
        }
        public async Task ClientInvokeCallback_SetActivityId()
        {
            Guid setActivityId = Guid.NewGuid();
            Guid activityId2 = Guid.NewGuid();

            Trace.CorrelationManager.ActivityId = activityId2; // Set up initial value that will be overridden by the callback function

            TestClientInvokeCallback callback = new TestClientInvokeCallback(setActivityId);
            GrainClient.ClientInvokeCallback = callback.OnInvoke;
            IRequestContextProxyGrain grain = GrainClient.GrainFactory.GetGrain<IRequestContextProxyGrain>(GetRandomGrainId());

            Guid activityId = await grain.E2EActivityId();
            Assert.AreEqual(setActivityId, activityId, "E2EActivityId Call#1");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks");

            Trace.CorrelationManager.ActivityId = Guid.Empty;
            RequestContext.Clear(); // Need this to clear out any old ActivityId value cached in RequestContext. Code optimization in RequestContext does not unset entry if Trace.CorrelationManager.ActivityId == Guid.Empty [which is the "normal" case]
            GrainClient.ClientInvokeCallback = null;

            activityId = await grain.E2EActivityId();
            Assert.AreEqual(Guid.Empty, activityId, "E2EActivityId Call#2 == Zero");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks - should be unchanged");
        }
        public async Task ClientInvokeCallback_CountCallbacks()
        {
            TestClientInvokeCallback callback = new TestClientInvokeCallback(Guid.Empty);
            GrainClient.ClientInvokeCallback = callback.OnInvoke;
            IRequestContextProxyGrain grain = GrainClient.GrainFactory.GetGrain<IRequestContextProxyGrain>(GetRandomGrainId());

            Trace.CorrelationManager.ActivityId = Guid.Empty;
            Guid activityId = await grain.E2EActivityId();
            Assert.AreEqual(Guid.Empty, activityId, "E2EActivityId Call#1");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks");

            GrainClient.ClientInvokeCallback = null;
            activityId = await grain.E2EActivityId();
            Assert.AreEqual(Guid.Empty, activityId, "E2EActivityId Call#2");
            Assert.AreEqual(1, callback.TotalCalls, "Number of callbacks - should be unchanged");
        }