Example #1
0
        public async Task PriorityQueueTimeToLive()
        {
            CancellationToken token        = this.TestToken;
            string            trcImage     = Context.Current.TestResultCoordinatorImage.Expect(() => new ArgumentException("testResultCoordinatorImage parameter is required for Priority Queues test"));
            string            loadGenImage = Context.Current.LoadGenImage.Expect(() => new ArgumentException("loadGenImage parameter is required for Priority Queues test"));
            string            relayerImage = Context.Current.RelayerImage.Expect(() => new ArgumentException("relayerImage parameter is required for Priority Queues test"));
            string            trackingId   = Guid.NewGuid().ToString();
            TestInfo          testInfo     = this.InitTestInfo(5, 20);

            Action <EdgeConfigBuilder> addLoadGenConfig = this.BuildAddLoadGenConfig(trackingId, loadGenImage, testInfo, false);
            Action <EdgeConfigBuilder> addTrcConfig     = TestResultCoordinatorUtil.BuildAddTestResultCoordinatorConfig(trackingId, trcImage, LoadGenModuleName, RelayerModuleName, false);

            EdgeDeployment deployment = await this.runtime.DeployConfigurationAsync(addLoadGenConfig + addTrcConfig, token, Context.Current.NestedEdge);

            PriorityQueueTestStatus loadGenTestStatus = await this.PollUntilFinishedAsync(LoadGenModuleName, token);

            await Profiler.Run(
                () => Task.Delay(testInfo.TtlThreshold * 1000),
                "Waited for message TTL to expire");

            Action <EdgeConfigBuilder> addRelayerConfig = this.BuildAddRelayerConfig(relayerImage, loadGenTestStatus);

            deployment = await this.runtime.DeployConfigurationAsync(addLoadGenConfig + addTrcConfig + addRelayerConfig, token, Context.Current.NestedEdge);

            await this.PollUntilFinishedAsync(RelayerModuleName, token);

            Assert.True(await TestResultCoordinatorUtil.IsResultValidAsync());
        }
Example #2
0
        public async Task PriorityQueueModuleToHubMessages()
        {
            CancellationToken token                  = this.TestToken;
            string            trcImage               = Context.Current.TestResultCoordinatorImage.Expect(() => new ArgumentException("testResultCoordinatorImage parameter is required for Priority Queues test"));
            string            loadGenImage           = Context.Current.LoadGenImage.Expect(() => new ArgumentException("loadGenImage parameter is required for Priority Queues test"));
            string            relayerImage           = Context.Current.RelayerImage.Expect(() => new ArgumentException("relayerImage parameter is required for Priority Queues test"));
            string            networkControllerImage = Context.Current.NetworkControllerImage.Expect(() => new ArgumentException("networkControllerImage parameter is required for Priority Queues test"));
            string            trackingId             = Guid.NewGuid().ToString();
            TestInfo          testInfo               = this.InitTestInfo(5, 1000, true, "00:00:40");

            var testResultReportingClient = new TestResultReportingClient {
                BaseUrl = "http://localhost:5001"
            };

            Action <EdgeConfigBuilder> addLoadGenConfig           = this.BuildAddLoadGenConfig(trackingId, loadGenImage, testInfo, true);
            Action <EdgeConfigBuilder> addTrcConfig               = TestResultCoordinatorUtil.BuildAddTestResultCoordinatorConfig(trackingId, trcImage, LoadGenModuleName, "hubtest", false);
            Action <EdgeConfigBuilder> addNetworkControllerConfig = TestResultCoordinatorUtil.BuildAddNetworkControllerConfig(trackingId, networkControllerImage);

            EdgeDeployment deployment = await this.runtime.DeployConfigurationAsync(addLoadGenConfig + addTrcConfig + addNetworkControllerConfig, token, Context.Current.NestedEdge);

            bool networkOn = true;

            await this.ToggleConnectivity(!networkOn, NetworkControllerModuleName, token);

            await Task.Delay(TimeSpan.Parse(LoadGenTestDuration) + TimeSpan.Parse(testInfo.LoadGenStartDelay) + TimeSpan.FromSeconds(10));

            await this.ToggleConnectivity(networkOn, NetworkControllerModuleName, token);

            PriorityQueueTestStatus loadGenTestStatus = await this.PollUntilFinishedAsync(LoadGenModuleName, token);

            ConcurrentQueue <MessageTestResult> messages = new ConcurrentQueue <MessageTestResult>();

            await this.ReceiveEventsFromIotHub(deployment.StartTime, messages, loadGenTestStatus, trackingId, token);

            while (messages.TryDequeue(out MessageTestResult messageTestResult))
            {
                await testResultReportingClient.ReportResultAsync(messageTestResult.ToTestOperationResultDto());
            }

            Assert.True(await TestResultCoordinatorUtil.IsResultValidAsync());
        }