@@ -60,6 +60,7 @@ type iperfReportInterval struct {
6060type 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