Esempio n. 1
0
        public async Task PriorityQueueTimeToLive()
        {
            // TODO: Fix PriorityQueue TTL E2E tests for Windows and ARM32
            if (OsPlatform.IsWindows() || !OsPlatform.Is64Bit())
            {
                Assert.Ignore("Priority Queue time to live test has been disabled for Windows and Arm32 until we can fix it.");
            }

            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> addInitialConfig = this.BuildAddInitialConfig(trackingId, trcImage, loadGenImage, testInfo);
            EdgeDeployment             deployment       = await this.runtime.DeployConfigurationAsync(addInitialConfig, token);

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

            // Wait long enough for TTL to expire for some of the messages
            Log.Information($"Waiting for {testInfo.TtlThreshold} seconds for TTL's to expire");
            await Task.Delay(testInfo.TtlThreshold * 1000);

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

            deployment = await this.runtime.DeployConfigurationAsync(addInitialConfig + addRelayerConfig, token, false);

            await this.PollUntilFinishedAsync(RelayerModuleName, token);

            await this.ValidateResultsAsync();
        }
Esempio n. 2
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> addInitialConfig = this.BuildAddInitialConfig(trackingId, RelayerModuleName, trcImage, loadGenImage, testInfo, false);
            EdgeDeployment             deployment       = await this.runtime.DeployConfigurationAsync(addInitialConfig, token, Context.Current.NestedEdge);

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

            // Wait long enough for TTL to expire for some of the messages
            Log.Information($"Waiting for {testInfo.TtlThreshold} seconds for TTL's to expire");
            await Task.Delay(testInfo.TtlThreshold * 1000);

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

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

            await this.PollUntilFinishedAsync(RelayerModuleName, token);

            await this.ValidateResultsAsync();
        }
Esempio n. 3
0
        public async Task PriorityQueueModuleToModuleMessages()
        {
            // TODO: Fix PriorityQueue E2E tests for Windows and ARM32
            if (OsPlatform.IsWindows() || !OsPlatform.Is64Bit())
            {
                Assert.Ignore("Priority Queue module to module messages test has been disabled for Windows and Arm32 until we can fix it.");
            }

            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, 1000, true);

            Action <EdgeConfigBuilder> addInitialConfig = this.BuildAddInitialConfig(trackingId, trcImage, loadGenImage, testInfo);
            EdgeDeployment             deployment       = await this.runtime.DeployConfigurationAsync(addInitialConfig, token);

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

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

            deployment = await this.runtime.DeployConfigurationAsync(addInitialConfig + addRelayerConfig, token, false);

            await this.PollUntilFinishedAsync(RelayerModuleName, token);

            await this.ValidateResultsAsync();
        }
Esempio n. 4
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());
        }
Esempio n. 5
0
        public async Task PriorityQueueModuleToHubMessages()
        {
            // TODO: Add Windows and ARM32. Windows won't be able to work for this test until we add NetworkController Windows implementation
            if (OsPlatform.IsWindows() || !OsPlatform.Is64Bit())
            {
                Assert.Ignore("Priority Queue module to module messages test has been disabled for Windows and Arm32 until we can fix it.");
            }

            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);

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

            Action <EdgeConfigBuilder> addInitialConfig           = this.BuildAddInitialConfig(trackingId, "hubtest", trcImage, loadGenImage, testInfo, true);
            Action <EdgeConfigBuilder> addNetworkControllerConfig = this.BuildAddNetworkControllerConfig(trackingId, networkControllerImage);
            EdgeDeployment             deployment = await this.runtime.DeployConfigurationAsync(addInitialConfig + addNetworkControllerConfig, token);

            bool networkOn = true;

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

            await Task.Delay(TimeSpan.Parse(LoadGenTestDuration) + TimeSpan.Parse(LoadGenTestStartDelay) + 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, token);

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

            await this.ValidateResultsAsync();
        }
Esempio n. 6
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");
            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());
            }

            await TestResultCoordinatorUtil.ValidateResultsAsync();
        }
Esempio n. 7
0
        public async Task PriorityQueueModuleToModuleMessages()
        {
            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, 1000, true);

            Action <EdgeConfigBuilder> addInitialConfig = this.BuildAddInitialConfig(trackingId, RelayerModuleName, trcImage, loadGenImage, testInfo, false);
            EdgeDeployment             deployment       = await this.runtime.DeployConfigurationAsync(addInitialConfig, token, Context.Current.NestedEdge);

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

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

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

            await this.PollUntilFinishedAsync(RelayerModuleName, token);

            await this.ValidateResultsAsync();
        }
Esempio n. 8
0
 private Action <EdgeConfigBuilder> BuildAddRelayerConfig(string relayerImage, PriorityQueueTestStatus loadGenTestStatus)
 {
     return(new Action <EdgeConfigBuilder>(
                builder =>
     {
         builder.AddModule(RelayerModuleName, relayerImage)
         .WithEnvironment(new[]
         {
             ("receiveOnly", "true"),
             ("uniqueResultsExpected", loadGenTestStatus.ResultCount.ToString()),
             ("testResultCoordinatorUrl", TrcUrl)
         });
Esempio n. 9
0
        async Task ReceiveEventsFromIotHub(DateTime startTime, ConcurrentQueue <MessageTestResult> messages, PriorityQueueTestStatus loadGenTestStatus, string trackingId, CancellationToken token)
        {
            await Profiler.Run(
                async() =>
            {
                HashSet <int> results = new HashSet <int>();
                await this.IotHub.ReceiveEventsAsync(
                    this.runtime.DeviceId,
                    startTime,
                    data =>
                {
                    if (data.Properties.ContainsKey("trackingId") &&
                        data.Properties.ContainsKey("batchId") &&
                        data.Properties.ContainsKey("sequenceNumber"))
                    {
                        int sequenceNumber = int.Parse(data.Properties["sequenceNumber"].ToString());
                        Log.Verbose($"Received message from IoTHub with sequence number: {sequenceNumber}");

                        var receivedTrackingId = (string)data.Properties["trackingId"];
                        if (!receivedTrackingId.IsNullOrWhiteSpace() && receivedTrackingId.Equals(trackingId))
                        {
                            messages.Enqueue(new MessageTestResult("hubtest.receive", DateTime.UtcNow)
                            {
                                TrackingId     = data.Properties["trackingId"].ToString(),
                                BatchId        = data.Properties["batchId"].ToString(),
                                SequenceNumber = data.Properties["sequenceNumber"].ToString()
                            });
                            results.Add(sequenceNumber);
                        }
                        else
                        {
                            var message = receivedTrackingId.IsNullOrWhiteSpace() ? "EMPTY" : receivedTrackingId;
                            Log.Verbose($"Message contains incorrect tracking id: {message}. Ignoring.");
                        }
                    }
                    else
                    {
                        Log.Warning("Message is missing information. Needs to have trackingId, batchId, and sequenceNumber. Not enqueuing.");
                    }

                    return(results.Count == loadGenTestStatus.ResultCount);
                },
                    token);
            },
                "Received {ResultCount} unique results from IoTHub",
                loadGenTestStatus.ResultCount);
        }
Esempio n. 10
0
        async Task ReceiveEventsFromIotHub(DateTime startTime, ConcurrentQueue <MessageTestResult> messages, PriorityQueueTestStatus loadGenTestStatus, CancellationToken token)
        {
            await Profiler.Run(
                async() =>
            {
                HashSet <int> results = new HashSet <int>();
                await this.iotHub.ReceiveEventsAsync(
                    this.runtime.DeviceId,
                    startTime,
                    data =>
                {
                    int sequenceNumber = int.Parse(data.Properties["sequenceNumber"].ToString());
                    Log.Verbose($"Received message from IoTHub with sequence number: {sequenceNumber}");
                    messages.Enqueue(new MessageTestResult("hubtest.receive", DateTime.UtcNow)
                    {
                        TrackingId     = data.Properties["trackingId"].ToString(),
                        BatchId        = data.Properties["batchId"].ToString(),
                        SequenceNumber = data.Properties["sequenceNumber"].ToString()
                    });

                    results.Add(sequenceNumber);
                    return(results.Count == loadGenTestStatus.ResultCount);
                },
                    token);
            },
                "Received {ResultCount} unique results from IoTHub",
                loadGenTestStatus.ResultCount);
        }