private async Task MergeGrainResolverTestsImpl <T>(Type defaultPlacementStrategy, bool restartClient, Func <IGrain, Task> func, params Type[] blackListedTypes)
            where T : IGrainWithIntegerKey
        {
            SetupAndDeployCluster(defaultPlacementStrategy, blackListedTypes);

            var delayTimeout = RefreshInterval.Add(RefreshInterval);

            // Should fail
            var exception = Assert.Throws <ArgumentException>(() => this.cluster.GrainFactory.GetGrain <T>(0));

            Assert.Contains("Cannot find an implementation class for grain interface", exception.Message);

            // Start a new silo with TestGrain
            await cluster.StartAdditionalSiloAsync();

            await Task.Delay(delayTimeout);

            if (restartClient)
            {
                // Disconnect/Reconnect the client
                await cluster.Client.Close();

                cluster.Client.Dispose();
                cluster.InitializeClient();
            }
            else
            {
                await Task.Delay(ClientRefreshDelay.Multiply(3));
            }

            for (var i = 0; i < 5; i++)
            {
                // Success
                var g = this.cluster.GrainFactory.GetGrain <T>(i);
                await func(g);
            }

            // Stop the latest silos
            await cluster.StopSecondarySilosAsync();

            await Task.Delay(delayTimeout);

            if (restartClient)
            {
                // Disconnect/Reconnect the client
                await cluster.Client.Close();

                cluster.Client.Dispose();
                cluster.InitializeClient();
            }
            else
            {
                await Task.Delay(ClientRefreshDelay.Multiply(3));
            }

            // Should fail
            exception = Assert.Throws <ArgumentException>(() => this.cluster.GrainFactory.GetGrain <T>(0));
            Assert.Contains("Cannot find an implementation class for grain interface", exception.Message);
        }
Beispiel #2
0
        public async Task UserVerification_SiloDown_UserRegisteredWhenRestarted()
        {
            /*
             * Enable Verification service
             * Disable verification service
             * Send Registration
             * Assert that the state is pending
             * Switch on verification service
             * Assert that the state is verified
             */

            // Arrange
            await _registrationCluster.WaitForLivenessToStabilizeAsync();

            await _registrationStatusCluster.WaitForLivenessToStabilizeAsync();

            _verificationCluster = _testHelper.GenerateTestCluster <UserVerificationGrain>();
            await _verificationCluster.WaitForLivenessToStabilizeAsync();

            var userRegistrationGrain =
                _registrationCluster.Client.GetGrain <IUserRegistrationGrain>(_faker.Internet.Email());
            var userRegistrationKey =
                await userRegistrationGrain.RegisterAsync(_faker.Random.String2(5), _faker.Random.String2(5));

            await AssertRegistrationState(userRegistrationKey, UserRegistrationStatusEnum.Verified);

            await _verificationCluster.StopSiloAsync(_verificationCluster.Primary);

            var userRegistrationGrain1 =
                _registrationCluster.Client.GetGrain <IUserRegistrationGrain>(_faker.Internet.Email());
            var userRegistrationKey1 =
                await userRegistrationGrain1.RegisterAsync(_faker.Random.String2(5), _faker.Random.String2(5));

            await AssertRegistrationState(userRegistrationKey1, UserRegistrationStatusEnum.Pending);

            // Act
            // Build Verification Service
            await _verificationCluster.StartAdditionalSiloAsync();

            await _verificationCluster.WaitForLivenessToStabilizeAsync();

            // Assert
            await AssertRegistrationState(userRegistrationKey1, UserRegistrationStatusEnum.Verified);

            await _registrationCluster.StopAllSilosAsync();

            await _registrationStatusCluster.StopAllSilosAsync();

            await _verificationCluster.StopAllSilosAsync();
        }
        public async Task Should_send_message_to_new_member()
        {
            await _cluster.StartAdditionalSiloAsync();

            await PublishAsync(4, _key);
        }