public async Task StartAsync(
            DateTime runExpirationTime,
            DateTime edgeHubRestartedTime,
            CancellationToken cancellationToken)
        {
            (DateTime dmCompletedTime, HttpStatusCode dmStatusCode) = await this.SendDirectMethodAsync(
                Settings.Current.DeviceId,
                this.directMethodTargetModuleId,
                Settings.Current.DirectMethodName,
                runExpirationTime,
                cancellationToken);

            TestResultBase dmTestResult = new EdgeHubRestartDirectMethodResult(
                this.GetSource(),
                DateTime.UtcNow,
                Settings.Current.TrackingId,
                this.batchId,
                this.directMethodCount,
                edgeHubRestartedTime,
                dmCompletedTime,
                dmStatusCode);

            await ModuleUtil.ReportTestResultAsync(
                this.GetReportClient(),
                this.logger,
                dmTestResult,
                cancellationToken);
        }
예제 #2
0
        // (sequenceNumber) is only valid if and only if (hasValue) is true
        async Task <(ulong resultCount, bool hasValue, ulong sequenceNumber)> MoveNextSenderResultAsync(ulong senderResultCount)
        {
            bool hasValue = await this.SenderTestResults.MoveNextAsync();

            ulong seqNum = 0;

            if (!hasValue)
            {
                return(resultCount : senderResultCount,
                       hasValue : hasValue,
                       sequenceNumber : seqNum);
            }

            senderResultCount++;

            EdgeHubRestartDirectMethodResult senderResult = JsonConvert.DeserializeObject <EdgeHubRestartDirectMethodResult>(this.SenderTestResults.Current.Result);

            seqNum = senderResult.SequenceNumber;

            this.AddEntryToCompletedStatusHistogram(senderResult);

            return(resultCount : senderResultCount,
                   hasValue : hasValue,
                   sequenceNumber : seqNum);
        }
예제 #3
0
        bool VerifyCurrentResult(
            ulong senderSeqNum,
            ulong receiverSeqNum,
            ulong previousSeqNum)
        {
            // Check if the current dm is passing
            bool isCurrentDirectMethodPassing             = true;
            EdgeHubRestartDirectMethodResult senderResult = JsonConvert.DeserializeObject <EdgeHubRestartDirectMethodResult>(this.SenderTestResults.Current.Result);

            // Verified the sequence numbers are the same
            isCurrentDirectMethodPassing &= senderSeqNum == receiverSeqNum;

            // Verified the sequence numbers are incremental
            isCurrentDirectMethodPassing &= senderSeqNum > previousSeqNum;

            // Make sure the status code is passing
            isCurrentDirectMethodPassing &= senderResult.DirectMethodCompletedStatusCode == HttpStatusCode.OK;

            // Log the data if the reportin result is failing
            if (!isCurrentDirectMethodPassing)
            {
                Logger.LogDebug($"\n SeqeunceNumber = {senderSeqNum} {receiverSeqNum}\n DirectMethodStatusCode = {senderResult.DirectMethodCompletedStatusCode}\n");
            }

            return(isCurrentDirectMethodPassing);
        }
예제 #4
0
        void AddEntryToCompletedStatusHistogram(EdgeHubRestartDirectMethodResult senderResult)
        {
            HttpStatusCode completedStatus = senderResult.DirectMethodCompletedStatusCode;
            TimeSpan       completedPeriod = senderResult.DirectMethodCompletedTime - senderResult.EdgeHubRestartedTime;

            // Try to allocate the list if it is the first time HttpStatusCode shows up
            this.completedStatusHistogram.TryAdd(completedStatus, new List <TimeSpan>());
            this.completedStatusHistogram[completedStatus].Add(completedPeriod);
        }