Skip to content

Commit d4ba271

Browse files
fix test with iperf
Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 4cda61c commit d4ba271

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

test/e2e/release/current_release_smoke.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (t *currentReleaseSmokeTest) verifyIPerfContinuityAfterUpgrade() {
214214
Expect(startedAt).To(BeNumerically("<=", upgradeStartedAt), "iperf3 should start before the module upgrade")
215215
Expect(endedAt).To(BeNumerically(">", upgradeStartedAt), "iperf3 should continue after the module upgrade")
216216

217-
lowerIdx, upperIdx := continuityWindowBounds(startedAt, upgradeStartedAt, len(report.Intervals))
217+
lowerIdx, upperIdx := continuityWindowBounds(startedAt, upgradeStartedAt, report.Intervals)
218218
Expect(upperIdx).To(BeNumerically(">=", lowerIdx), "iperf3 report must include intervals around the module upgrade")
219219

220220
zeroIntervals := 0

test/e2e/release/iperf.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type iperfReportInterval struct {
6060
type iperfReportSummary struct {
6161
Bytes int64 `json:"bytes"`
6262
BitsPerSecond float64 `json:"bits_per_second"`
63+
Start float64 `json:"start,omitempty"`
6364
End float64 `json:"end,omitempty"`
6465
}
6566

@@ -141,22 +142,27 @@ func getIPerfClientReport(f *framework.Framework, vm *v1alpha2.VirtualMachine, r
141142
}
142143

143144
// continuityWindowBounds returns the index range [lower, upper] of iperf intervals
144-
// around the upgrade timestamp. Assumes default 1-second reporting intervals.
145-
func continuityWindowBounds(startedAt, upgradeStartedAt int64, intervalCount int) (int, int) {
146-
if intervalCount == 0 {
145+
// around the upgrade timestamp.
146+
func continuityWindowBounds(startedAt, upgradeStartedAt int64, intervals []iperfReportInterval) (int, int) {
147+
if len(intervals) == 0 {
147148
return 1, 0
148149
}
149150

150-
index := int(upgradeStartedAt - startedAt)
151-
if index < 0 {
152-
index = 0
153-
}
154-
if index >= intervalCount {
155-
index = intervalCount - 1
151+
upgradeOffset := float64(upgradeStartedAt - startedAt)
152+
index := len(intervals) - 1
153+
for idx, interval := range intervals {
154+
if upgradeOffset < interval.Sum.Start {
155+
index = idx
156+
break
157+
}
158+
if upgradeOffset >= interval.Sum.Start && upgradeOffset < interval.Sum.End {
159+
index = idx
160+
break
161+
}
156162
}
157163

158164
lower := max(index-1, 0)
159-
upper := min(index+1, intervalCount-1)
165+
upper := min(index+1, len(intervals)-1)
160166
return lower, upper
161167
}
162168

0 commit comments

Comments
 (0)