Esempio n. 1
0
        public IEnumerator GetLockablePropertiesMultipleObjectsAndConditions()
        {
            // Given three scene objects,
            // one of them with one lockable property and one non-lockable property,
            // one of them with only one non-lockable property,
            // and one of them with only one lockable property,
            // used by three different conditions in a transition.
            ISceneObject         o1       = TestingUtils.CreateSceneObject("o1");
            LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>();

            o1.GameObject.AddComponent <PropertyMock>();

            ISceneObject o2 = TestingUtils.CreateSceneObject("o2");

            o2.GameObject.AddComponent <PropertyMock>();

            ISceneObject         o3        = TestingUtils.CreateSceneObject("o3");
            LockablePropertyMock property2 = o2.GameObject.AddComponent <LockablePropertyMock>();

            LockableReferencingConditionMock condition1 = new LockableReferencingConditionMock();

            condition1.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName);
            condition1.LockableProperties        = new[] { new LockablePropertyData(property, true) };

            ReferencingConditionMock condition2 = new ReferencingConditionMock();

            condition2.Data.PropertyMock = new ScenePropertyReference <PropertyMock>(o2.UniqueName);

            LockableReferencingConditionMock condition3 = new LockableReferencingConditionMock();

            condition3.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o3.UniqueName);
            condition3.LockableProperties        = new[] { new LockablePropertyData(property2, true) };

            Step step2 = new BasicStepBuilder("step2").Build();
            Step step  = new BasicStepBuilder("step")
                         .AddCondition(condition1)
                         .AddCondition(condition2)
                         .AddCondition(condition3)
                         .Build();
            Transition transition = (Transition)step.Data.Transitions.Data.Transitions[0];

            transition.Data.TargetStep = step2;

            // When counting the lockable properties in the transition.
            // Then there are exactly two lockable properties.
            Assert.IsTrue(transition.GetLockableProperties().Count() == 2);

            yield return(null);
        }
        public async Task SingleSendBatchConsume()
        {
            const int ExpectedConsumed = 30;
            Guid      streamGuid       = Guid.NewGuid();

            IStreamProvider       provider = this.fixture.Client.GetStreamProvider(StreamBatchingTestConst.ProviderName);
            IAsyncStream <string> stream   = provider.GetStream <string>(streamGuid, StreamBatchingTestConst.BatchingNameSpace);

            for (int i = 0; i < ExpectedConsumed; i++)
            {
                await stream.OnNextAsync(i.ToString());
            }
            var consumer = this.fixture.GrainFactory.GetGrain <IStreamBatchingTestConsumerGrain>(streamGuid);
            await TestingUtils.WaitUntilAsync(lastTry => CheckCounters(consumer, ExpectedConsumed, 2, lastTry), Timeout);
        }
Esempio n. 3
0
 public ISiloHostBuilder CreateSiloBuilder(string siloName, ClusterConfiguration clusterConfiguration)
 {
     return(new SiloHostBuilder()
            .ConfigureSiloName(siloName)
            .UseConfiguration(clusterConfiguration)
            .ConfigureLogging(builder => TestingUtils.ConfigureDefaultLoggingBuilder(builder, TestingUtils.CreateTraceFileName(siloName, clusterConfiguration.Globals.ClusterId)))
            .UseInClusterTransactionManager(new TransactionsConfiguration())
            .UseAzureTransactionLog(new AzureTransactionLogConfiguration()
     {
         // TODO: Find better way for test isolation.  Possibly different partition keys.
         TableName = $"TransactionLog{((uint)clusterConfiguration.Globals.ClusterId.GetHashCode())%100000}",
         ConnectionString = TestDefaultConfiguration.DataConnectionString
     })
            .UseTransactionalState());
 }
Esempio n. 4
0
        public async Task Recoverable100EventStreamsWith1NonTransientError(Func <string, int, int, Task> generateFn, string streamNamespace, int streamCount, int eventsInStream)
        {
            try
            {
                await generateFn(streamNamespace, streamCount, eventsInStream);

                // should eventually skip the faulted event, so event count should be one (faulted event) less that number of events in stream.
                await TestingUtils.WaitUntilAsync(assertIsTrue => this.CheckCounters(streamNamespace, streamCount, eventsInStream - 1, assertIsTrue), TimeSpan.FromSeconds(90));
            }
            finally
            {
                var reporter = this.grainFactory.GetGrain <IGeneratedEventReporterGrain>(GeneratedStreamTestConstants.ReporterId);
                reporter.Reset().Ignore();
            }
        }
        public ReminderTests_Base(BaseTestClusterFixture fixture)
        {
            HostedCluster = fixture.HostedCluster;
            GrainFactory  = fixture.GrainFactory;

            ClientConfiguration configuration = ClientConfiguration.LoadFromFile("ClientConfigurationForTesting.xml");
            var filters = new LoggerFilterOptions();

#if DEBUG
            filters.AddFilter("Storage", LogLevel.Trace);
            filters.AddFilter("Reminder", LogLevel.Trace);
#endif

            log = TestingUtils.CreateDefaultLoggerFactory(TestingUtils.CreateTraceFileName(configuration.ClientName, configuration.ClusterId), filters).CreateLogger <ReminderTests_Base>();
        }
Esempio n. 6
0
        public async Task EHStatistics_MonitorCalledAccordingly()
        {
            var streamId = new FullStreamIdentity(Guid.NewGuid(), StreamNamespace, StreamProviderName);
            //set up one slow consumer grain
            var slowConsumer = this.fixture.GrainFactory.GetGrain <ISlowConsumingGrain>(Guid.NewGuid());
            await slowConsumer.BecomeConsumer(streamId.Guid, StreamNamespace, StreamProviderName);

            //set up 30 healthy consumer grain to show how much we favor slow consumer
            int healthyConsumerCount = 30;
            var healthyConsumers     = await EHSlowConsumingTests.SetUpHealthyConsumerGrain(this.fixture.GrainFactory, streamId.Guid, StreamNamespace, StreamProviderName, healthyConsumerCount);

            //configure data generator for stream and start producing
            var mgmtGrain = this.fixture.GrainFactory.GetGrain <IManagementGrain>(0);
            var randomStreamPlacementArg = new EventDataGeneratorStreamProvider.AdapterFactory.StreamRandomPlacementArg(streamId, this.seed.Next(100));
            await mgmtGrain.SendControlCommandToProvider(typeof(EHStreamProviderForMonitorTests).FullName, StreamProviderName,
                                                         (int)EventDataGeneratorStreamProvider.AdapterFactory.Commands.Randomly_Place_Stream_To_Queue, randomStreamPlacementArg);

            //since there's an extreme slow consumer, so the back pressure algorithm should be triggered
            await TestingUtils.WaitUntilAsync(lastTry => AssertCacheBackPressureTriggered(true, lastTry), timeout);

            //make slow consumer stop consuming
            await slowConsumer.StopConsuming();

            //assert EventHubReceiverMonitor call counters
            var receiverMonitorCounters = await mgmtGrain.SendControlCommandToProvider(typeof(EHStreamProviderForMonitorTests).FullName, StreamProviderName,
                                                                                       (int)EHStreamProviderForMonitorTests.AdapterFactory.QueryCommands.GetReceiverMonitorCallCounters, null);

            foreach (var callCounter in receiverMonitorCounters)
            {
                AssertReceiverMonitorCallCounters(callCounter as EventHubReceiverMonitorCounters);
            }

            var cacheMonitorCounters = await mgmtGrain.SendControlCommandToProvider(typeof(EHStreamProviderForMonitorTests).FullName, StreamProviderName,
                                                                                    (int)EHStreamProviderForMonitorTests.AdapterFactory.QueryCommands.GetCacheMonitorCallCounters, null);

            foreach (var callCounter in cacheMonitorCounters)
            {
                AssertCacheMonitorCallCounters(callCounter as CacheMonitorCounters);
            }

            var objectPoolMonitorCounters = await mgmtGrain.SendControlCommandToProvider(typeof(EHStreamProviderForMonitorTests).FullName, StreamProviderName,
                                                                                         (int)EHStreamProviderForMonitorTests.AdapterFactory.QueryCommands.GetObjectPoolMonitorCallCounters, null);

            foreach (var callCounter in objectPoolMonitorCounters)
            {
                AssertObjectPoolMonitorCallCounters(callCounter as ObjectPoolMonitorCounters);
            }
        }
Esempio n. 7
0
        public void RequiredFieldNotSetTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                return(TestingUtils.GetResponse("number_lookup.json"));
            })
                );

            var mocean = TestingUtils.GetClientObj(apiRequestMock);

            Assert.Throws <RequiredFieldException>(() =>
            {
                mocean.NumberLookup.Inquiry(new NumberLookupRequest());
            });
        }
Esempio n. 8
0
        public ClaimServiceUT()
        {
            var testUtils = new TestingUtils();

            claimService = new ClaimService();

            user1 = testUtils.CreateUserInDb();
            user2 = testUtils.CreateUserInDb();

            service1 = testUtils.CreateServiceInDb(true);
            service2 = testUtils.CreateServiceInDb(true);

            _db = new DatabaseContext();

            claim1 = testUtils.CreateClaim(user1, service1, user2);
        }
Esempio n. 9
0
        public void RequiredFieldNotSetTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                return(TestingUtils.GetResponse("message.json"));
            })
                );

            var mocean = TestingUtils.GetClientObj(apiRequestMock);

            Assert.Throws <RequiredFieldException>(() =>
            {
                mocean.Sms.Send(new SmsRequest());
            });
        }
Esempio n. 10
0
        public static IClientBuilder CreateClientBuilder(ClientConfiguration configuration, ClusterConfiguration clusterConfiguration)
        {
            var primaryGw = clusterConfiguration.Overrides["Primary"].ProxyGatewayEndpoint.ToGatewayUri();

            return(new ClientBuilder()
                   .UseConfiguration(configuration)
                   .ConfigureServices(services => services.AddSingleton(sp =>
            {
                var gateway = new TestGatewayManager();
                gateway.Gateways.Add(primaryGw);
                return gateway;
            }))
                   .ConfigureServices(services => services.AddFromExisting <IGatewayListProvider, TestGatewayManager>())
                   .AddApplicationPartsFromBasePath()
                   .ConfigureLogging(builder => TestingUtils.ConfigureDefaultLoggingBuilder(builder, configuration.TraceFileName)));
        }
 public void GetValidRouteDefsTest_InvalidRouteTemplate()
 {
     TestingUtils.ResetRoutesRepository();
     try
     {
         RoutesUtils.GetValidRouteDefs(new List <IRouteDefinitions>()
         {
             new InvalidRouteTemplateRoutes()
         });
     }
     catch (Exception)
     {
         return;
     }
     Assert.True(false);
 }
Esempio n. 12
0
        internal static ILoggerFactory InitSchedulerLogging()
        {
            var filters = new LoggerFilterOptions();

            filters.AddFilter("Scheduler", LogLevel.Trace);
            filters.AddFilter("Scheduler.WorkerPoolThread", LogLevel.Trace);
            var orleansConfig = new ClusterConfiguration();

            orleansConfig.StandardLoad();
            NodeConfiguration config = orleansConfig.CreateNodeConfigurationForSilo("Primary");
            var loggerFactory        = TestingUtils.CreateDefaultLoggerFactory(TestingUtils.CreateTraceFileName(config.SiloName, orleansConfig.Globals.ClusterId), filters);

            StatisticsCollector.Initialize(StatisticsLevel.Info);
            SchedulerStatisticsGroup.Init(loggerFactory);
            return(loggerFactory);
        }
Esempio n. 13
0
        public async Task CacheIsOvertimedDueToSlowConsumer()
        {
            // get producer and consumer
            var firstProducer   = GrainClient.GrainFactory.GetGrain <ISampleStreaming_ProducerGrain>(Guid.NewGuid());
            var regularConsumer = GrainClient.GrainFactory.GetGrain <ITimedConsumerGrain>(Guid.NewGuid());
            var slowConsumer    = GrainClient.GrainFactory.GetGrain <ITimedConsumerGrain>(Guid.NewGuid());

            Guid   firstStream     = Guid.NewGuid();
            string streamNamespace = "RewindingTestNamespace";

            // subscribing to different streams on the same namespace
            await regularConsumer.BecomeConsumer(firstStream, streamNamespace, null, TimeSpan.Zero, _streamProviderName);

            // time to produce
            await firstProducer.BecomeProducer(firstStream, streamNamespace, _streamProviderName);

            // Starting to produce!
            int numToProduce = 4;

            for (int i = 1; i <= numToProduce; i++)
            {
                await firstProducer.Produce();
            }

            await Task.Delay(5);

            await
            TestingUtils.WaitUntilAsync(lastTry => CheckCounters(numToProduce, regularConsumer, lastTry),
                                        TimeSpan.FromSeconds(30));

            var wantedToken = (await regularConsumer.GetReceivedTokens()).Values.First();

            await slowConsumer.BecomeConsumer(firstStream, streamNamespace, wantedToken, TimeSpan.FromSeconds(3), _streamProviderName);

            int secondNumToProduce = 1;

            for (int i = 1; i <= secondNumToProduce; i++)
            {
                await firstProducer.Produce();
            }

            await
            Task.WhenAll(TestingUtils.WaitUntilAsync(lastTry => CheckCounters(numToProduce + secondNumToProduce, regularConsumer, lastTry), TimeSpan.FromSeconds(30)),
                         TestingUtils.WaitUntilAsync(lastTry => CheckCounters(numToProduce + secondNumToProduce, slowConsumer, lastTry), TimeSpan.FromSeconds(30)));

            await Task.WhenAll(slowConsumer.StopConsuming(), regularConsumer.StopConsuming());
        }
Esempio n. 14
0
        public void ErrorResponseWith4xxStatusCodeTest()
        {
            string jsonErrorResponse = TestingUtils.ReadFile("error_response.json");
            var    apiRequest        = new ApiRequest();

            try
            {
                apiRequest.FormatResponse(jsonErrorResponse, System.Net.HttpStatusCode.BadRequest, false, null);
                Assert.Fail();
            }
            catch (MoceanErrorException ex)
            {
                Assert.AreEqual(ex.Message, ex.ErrorResponse.ToString());
                Assert.AreEqual(jsonErrorResponse, ex.ErrorResponse.ToString());
                Assert.AreEqual("1", ex.ErrorResponse.Status);
            }
        }
        public async Task BatchSendBatchConsume()
        {
            const int BatchesSent      = 3;
            const int ItemsPerBatch    = 10;
            const int ExpectedConsumed = BatchesSent * ItemsPerBatch;
            Guid      streamGuid       = Guid.NewGuid();

            IStreamProvider       provider = this.fixture.Client.GetStreamProvider(StreamBatchingTestConst.ProviderName);
            IAsyncStream <string> stream   = provider.GetStream <string>(streamGuid, StreamBatchingTestConst.BatchingNameSpace);

            for (int i = 0; i < BatchesSent; i++)
            {
                await stream.OnNextBatchAsync(Enumerable.Range(i, ItemsPerBatch).Select(v => v.ToString()));
            }
            var consumer = this.fixture.GrainFactory.GetGrain <IStreamBatchingTestConsumerGrain>(streamGuid);
            await TestingUtils.WaitUntilAsync(lastTry => CheckCounters(consumer, ExpectedConsumed, ItemsPerBatch, lastTry), Timeout);
        }
Esempio n. 16
0
        private async Task ProducerConsumerTest(Guid producerGuid, Guid consumerGuid)
        {
            // producer joins first, consumer later
            IProducerEventCountingGrain producer = this.fixture.GrainFactory.GetGrain <IProducerEventCountingGrain>(producerGuid);
            await producer.BecomeProducer(_streamId, _streamProvider);

            IConsumerEventCountingGrain consumer = this.fixture.GrainFactory.GetGrain <IConsumerEventCountingGrain>(consumerGuid);
            await consumer.BecomeConsumer(_streamId, _streamProvider);

            await producer.SendEvent();

            await Task.Delay(1000);

            await TestingUtils.WaitUntilAsync(lastTry => CheckCounters(producer, consumer), Timeout);

            await consumer.StopConsuming();
        }
Esempio n. 17
0
        public void XmlSendTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                Assert.AreEqual(HttpMethod.Post, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/sms", "1"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("message.xml"));
            })
                );

            apiRequestMock.ApiRequestConfig.Version = "1";
            var mocean = TestingUtils.GetClientObj(apiRequestMock);
            var res    = mocean.Sms.Send(new SmsRequest
            {
                mocean_from        = "testing from",
                mocean_text        = "testing text",
                mocean_to          = "testing to",
                mocean_resp_format = "xml"
            });

            Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("message.xml"));
            TestObject(res);

            //V2 Test
            apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                Assert.AreEqual(HttpMethod.Post, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/sms"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("message_v2.xml"));
            })
                );

            apiRequestMock.ApiRequestConfig.Version = "2";
            mocean = TestingUtils.GetClientObj(apiRequestMock);
            res    = mocean.Sms.Send(new SmsRequest
            {
                mocean_from        = "testing from",
                mocean_text        = "testing text",
                mocean_to          = "testing to",
                mocean_resp_format = "xml"
            });
            Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("message_v2.xml"));
            TestObject(res);
        }
Esempio n. 18
0
        protected const string testDatabaseName = "OrleansReminderTest";//for relational storage

        protected ReminderTableTestsBase(ConnectionStringFixture fixture, TestEnvironmentFixture clusterFixture, LoggerFilterOptions filters)
        {
            this.connectionStringFixture = fixture;
            fixture.InitializeConnectionStringAccessor(GetConnectionString);
            loggerFactory       = TestingUtils.CreateDefaultLoggerFactory($"{this.GetType()}.log", filters);
            this.ClusterFixture = clusterFixture;
            logger = loggerFactory.CreateLogger <ReminderTableTestsBase>();
            var serviceId = Guid.NewGuid().ToString() + "/foo";
            var clusterId = "test-" + serviceId + "/foo2";

            logger.Info("ClusterId={0}", clusterId);
            this.clusterOptions = Options.Create(new ClusterOptions {
                ClusterId = clusterId, ServiceId = serviceId
            });

            this.remindersTable = this.CreateRemindersTable();
        }
Esempio n. 19
0
        public void Test_Put_ValidId()
        {
            // Arrange: set UserMaria as a currently logged in user
            TestingUtils.AssignCurrentUserForController(
                this.eventsController, this.testDb.UserMaria);

            // Create a new event in the database for editing
            var newEvent = new Event()
            {
                Name           = "Beach Party" + DateTime.Now.Ticks,
                Place          = "Ibiza",
                Start          = DateTime.Now.AddMonths(3),
                End            = DateTime.Now.AddMonths(3),
                TotalTickets   = 20,
                PricePerTicket = 120.00m,
                OwnerId        = this.testDb.UserMaria.Id
            };

            this.dbContext.Add(newEvent);
            this.dbContext.SaveChanges();

            // Create an event binding model with changed event name
            var changedEvent = new EventBindingModel()
            {
                Name           = "House Party" + DateTime.Now.Ticks,
                Place          = newEvent.Place,
                Start          = newEvent.Start,
                End            = newEvent.End,
                TotalTickets   = newEvent.TotalTickets,
                PricePerTicket = newEvent.PricePerTicket
            };

            // Act: invoke the controller method and cast the result
            var result = this.eventsController.PutEvent(newEvent.Id, changedEvent)
                         as NoContentResult;

            Assert.IsNotNull(result);

            // Assert a "NoContent" result is returned
            Assert.AreEqual((int)HttpStatusCode.NoContent, result.StatusCode);

            // Assert the event in the database has a changed name
            var newEventFromDb = this.dbContext.Events.Find(newEvent.Id);

            Assert.AreEqual(newEventFromDb.Name, changedEvent.Name);
        }
Esempio n. 20
0
        public async Task BatchTestMultipleProducers(int numProducers, int batchSize)
        {
            List <IBatchProducerGrain> producersList = new List <IBatchProducerGrain>(numProducers);

            for (int i = 0; i < numProducers; i++)
            {
                producersList.Add(GrainClient.GrainFactory.GetGrain <IBatchProducerGrain>(Guid.NewGuid()));
            }

            var consumer = GrainClient.GrainFactory.GetGrain <ISampleStreaming_ConsumerGrain>(Guid.NewGuid());

            var streamGuid      = Guid.NewGuid();
            var streamNamespace = "BatchTestStream";

            await consumer.BecomeConsumer(streamGuid, streamNamespace, _streamProviderName);

            foreach (var producer in producersList)
            {
                await producer.BecomeProducer(streamGuid, streamNamespace, _streamProviderName);
            }

            foreach (var producer in producersList)
            {
                await producer.StartPeriodicBatchProducing(batchSize);
            }

            _logger.Info("***************Starting to Produce!*****************");

            await Task.Delay(TimeSpan.FromSeconds(1));

            var sum = 0;

            foreach (var producer in producersList)
            {
                await producer.StopPeriodicBatchProducing();

                _logger.Info("Producer produced {0} messages", await producer.GetNumberProduced());
                var numProduced = await producer.GetNumberProduced();

                sum += numProduced;
            }

            await TestingUtils.WaitUntilAsync(lastTry => CheckCounter(sum, consumer, lastTry), Timeout);

            await consumer.StopConsuming();
        }
Esempio n. 21
0
        public void JsonInquiryTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                Assert.AreEqual(HttpMethod.Get, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/account/pricing"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("price.json"));
            })
                );

            var mocean = TestingUtils.GetClientObj(apiRequestMock);
            var res    = mocean.Pricing.Inquiry();

            Assert.AreEqual(res.ToString(), TestingUtils.ReadFile("price.json"));
            TestObject(res);
        }
        public async Task MultipleStreamsDifferentNamespcaeDifferentConsumers()
        {
            // get producer and consumer
            var firstProducer  = GrainClient.GrainFactory.GetGrain <ISampleStreaming_ProducerGrain>(Guid.NewGuid());
            var secondProducer = GrainClient.GrainFactory.GetGrain <ISampleStreaming_ProducerGrain>(Guid.NewGuid());
            var firstConsumer  = GrainClient.GrainFactory.GetGrain <IMultipleSubscriptionConsumerGrain>(Guid.NewGuid());
            var secondConsumer = GrainClient.GrainFactory.GetGrain <IMultipleSubscriptionConsumerGrain>(Guid.NewGuid());

            Guid firstStream  = Guid.NewGuid();
            Guid secondStream = Guid.NewGuid();

            var firstNamespace  = "MultipleStreamsDifferentNamepsaceFirst";
            var secondNamespace = "MultipleStreamsDifferentNamepsaceSecond";

            // subscribing to different streams on the same namespace
            StreamSubscriptionHandle <int> firstHandle = await firstConsumer.BecomeConsumer(firstStream, firstNamespace, _streamProviderName);

            StreamSubscriptionHandle <int> secondHandle = await secondConsumer.BecomeConsumer(secondStream, secondNamespace, _streamProviderName);

            // Becoming a producer
            Task.WaitAll(firstProducer.BecomeProducer(firstStream, firstNamespace, _streamProviderName), secondProducer.BecomeProducer(secondStream, secondNamespace, _streamProviderName));

            // Starting to produce!
            await Task.WhenAll(firstProducer.StartPeriodicProducing(), secondProducer.StartPeriodicProducing());

            // Waiting a bit..
            await Task.Delay(TimeSpan.FromMilliseconds(3000));

            // Stopping
            await Task.WhenAll(firstProducer.StopPeriodicProducing(), secondProducer.StopPeriodicProducing());

            _logger.Info("Producer number 1 produced {0} messages", await firstProducer.GetNumberProduced());
            _logger.Info("Producer number 2 produced {0} messages", await secondProducer.GetNumberProduced());

            // Checking
            await
            Task.WhenAll(
                TestingUtils.WaitUntilAsync(lastTry => CheckCounters(firstProducer, firstConsumer, 1, null, lastTry), Timeout),
                TestingUtils.WaitUntilAsync(lastTry => CheckCounters(secondProducer, secondConsumer, 1, null, lastTry), Timeout));

            // unsubscribe
            await firstConsumer.StopConsuming(firstHandle);

            await secondConsumer.StopConsuming(secondHandle);
        }
        public async Task LeaseBalancedQueueBalancer_SupportAutoScaleScenario()
        {
            var mgmtGrain = this.GrainFactory.GetGrain <IManagementGrain>(0);
            //6 queue and 4 silo, then each agent manager should own queues/agents in range of [1, 2]
            await TestingUtils.WaitUntilAsync(lastTry => AgentManagerOwnCorrectAmountOfAgents(1, 2, mgmtGrain, lastTry), TimeOut);

            //stop one silo, 6 queues, 3 silo, then each agent manager should own 2 queues
            this.HostedCluster.StopSilo(this.HostedCluster.SecondarySilos[0]);
            await TestingUtils.WaitUntilAsync(lastTry => AgentManagerOwnCorrectAmountOfAgents(2, 2, mgmtGrain, lastTry), TimeOut);

            //stop another silo, 6 queues, 2 silo, then each agent manager should own 3 queues
            this.HostedCluster.StopSilo(this.HostedCluster.SecondarySilos[0]);
            await TestingUtils.WaitUntilAsync(lastTry => AgentManagerOwnCorrectAmountOfAgents(3, 3, mgmtGrain, lastTry), TimeOut);

            //start one silo, 6 queues, 3 silo, then each agent manager should own 2 queues
            this.HostedCluster.StartAdditionalSilo();
            await TestingUtils.WaitUntilAsync(lastTry => AgentManagerOwnCorrectAmountOfAgents(2, 2, mgmtGrain, lastTry), TimeOut);
        }
Esempio n. 24
0
        public void ResendTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                Assert.AreEqual(HttpMethod.Post, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/verify/resend/sms"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("resend_code.json"));
            })
                );

            var mocean = TestingUtils.GetClientObj(apiRequestMock);

            mocean.SendCode.Resend(new SendCodeRequest
            {
                mocean_reqid = "test req id"
            });
        }
        public IEnumerator FastForwardInactiveBehavior()
        {
            // Given an active training scene object and a DisableGameObjectBehavior,
            TrainingSceneObject toDisable = TestingUtils.CreateSceneObject("ToDisable");

            DisableGameObjectBehavior behavior = new DisableGameObjectBehavior(toDisable);

            // When we mark it to fast-forward,
            behavior.LifeCycle.MarkToFastForward();

            // Then it doesn't autocomplete because it weren't activated yet.
            Assert.AreEqual(Stage.Inactive, behavior.LifeCycle.Stage);

            // Cleanup.
            TestingUtils.DestroySceneObject(toDisable);

            yield break;
        }
Esempio n. 26
0
        public IEnumerator ObjectInConditionIsNotInManualUnlockList()
        {
            // Given a step with a condition with a LockableProperty
            ISceneObject     o1 = TestingUtils.CreateSceneObject("o1");
            LockableProperty lockableProperty = o1.GameObject.AddComponent <LockablePropertyMock>();
            LockableReferencingConditionMock lockCondition = new LockableReferencingConditionMock();

            lockCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName);
            Step step = new BasicStepBuilder("step").AddCondition(lockCondition).Build();

            // When we create a collection referencing this step
            LockableObjectsCollection collection = new LockableObjectsCollection(step.Data);

            // Then the lockable property is not in the Manual Unlock List of the collection
            Assert.IsFalse(collection.IsInManualUnlockList(lockableProperty));

            yield return(null);
        }
Esempio n. 27
0
        public void SiloConfig_OldAzure()
        {
            const string filename = "Config_OldAzure.xml";

            TestingUtils.CreateDefaultLoggerFactory(new NodeConfiguration().TraceFileName);
            var siloConfig = new ClusterConfiguration();

            siloConfig.LoadFromFile(filename);

            Assert.Equal(GlobalConfiguration.LivenessProviderType.AzureTable, siloConfig.Globals.LivenessType);               // LivenessType
            Assert.Equal(GlobalConfiguration.ReminderServiceProviderType.AzureTable, siloConfig.Globals.ReminderServiceType); // ReminderServiceType

            Assert.NotNull(siloConfig.Globals.DataConnectionString);                                                          // DataConnectionString should not be null
            Assert.False(string.IsNullOrWhiteSpace(siloConfig.Globals.DataConnectionString), "DataConnectionString should not be blank");

            Assert.True(siloConfig.Globals.UseAzureSystemStore, "Should be using Azure storage");
            Assert.False(siloConfig.Globals.UseSqlSystemStore, "Should not be using SqlServer storage");
        }
Esempio n. 28
0
        //this is the function for clicking onto the next selection
        private void next_Click(object sender, EventArgs e)
        {
            //set all the pictureboxes to white
            TestingUtils.clearAll(this);

            //test to see if out of bounds
            if (selectedRow >= dataGridList.Rows.Count - 1)
            {
                //set to the very last row
                selectedRow = dataGridList.Rows.Count - 1;

                //call select
                Selectors.select(this);
            }
            //if the selected row is not the last
            selectedRow++;
            Selectors.select(this);
        }
Esempio n. 29
0
        public void RecordingErrorTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                Assert.AreEqual(HttpMethod.Get, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/voice/rec"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("error_response.json"));
            })
                );

            var mocean = TestingUtils.GetClientObj(apiRequestMock);

            Assert.Throws <MoceanErrorException>(() =>
            {
                mocean.Voice.Recording("xxx-xxx-xxx-xxx");
            });
        }
        public async Task ResubscriptionAfterDeactivationTest(Guid streamGuid, string streamNamespace)
        {
            // get producer and consumer
            var producer = GrainClient.GrainFactory.GetGrain <ISampleStreaming_ProducerGrain>(Guid.NewGuid());
            var consumer = GrainClient.GrainFactory.GetGrain <IMultipleSubscriptionConsumerGrain>(Guid.NewGuid());

            await producer.BecomeProducer(streamGuid, streamNamespace, streamProviderName);

            // setup one subscription and send messsages
            StreamSubscriptionHandle <int> firstSubscriptionHandle = await consumer.BecomeConsumer(streamGuid, streamNamespace, streamProviderName);

            await producer.StartPeriodicProducing();

            await Task.Delay(TimeSpan.FromMilliseconds(1000));

            await producer.StopPeriodicProducing();

            await TestingUtils.WaitUntilAsync(lastTry => CheckCounters(producer, consumer, 1, lastTry), Timeout);

            // Deactivate grain
            await consumer.Deactivate();

            // make sure grain has time to deactivate.
            await Task.Delay(TimeSpan.FromMilliseconds(100));

            // clear producer counts
            await producer.ClearNumberProduced();

            // Resume
            StreamSubscriptionHandle <int> resumeHandle = await consumer.Resume(firstSubscriptionHandle);

            Assert.AreEqual(firstSubscriptionHandle, resumeHandle, "Handle matches");

            await producer.StartPeriodicProducing();

            await Task.Delay(TimeSpan.FromMilliseconds(1000));

            await producer.StopPeriodicProducing();

            await TestingUtils.WaitUntilAsync(lastTry => CheckCounters(producer, consumer, 1, lastTry), Timeout);

            // remove subscription
            await consumer.StopConsuming(resumeHandle);
        }