split out correct metric changes
This commit is contained in:
parent
e1edb64d09
commit
206aa75eca
|
@ -178,31 +178,36 @@ func TestSolanaCollector_WatchSlots_Dynamic(t *testing.T) {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
final := getSlotMetricValues()
|
final := getSlotMetricValues()
|
||||||
|
|
||||||
// make sure that things have increased
|
// make sure things are changing correctly:
|
||||||
assert.Greaterf(
|
assertSlotMetricsChangeCorrectly(t, initial, final)
|
||||||
|
|
||||||
|
// sense check to make sure the exporter is not "ahead" of the client (due to double counting or whatever)
|
||||||
|
assert.LessOrEqualf(
|
||||||
t,
|
t,
|
||||||
final.SlotHeight,
|
int(final.SlotHeight),
|
||||||
initial.SlotHeight,
|
client.Slot,
|
||||||
"Slot has not increased! (%v -> %v)",
|
"Exporter slot (%v) ahead of client slot (%v)!",
|
||||||
initial.SlotHeight,
|
int(final.SlotHeight),
|
||||||
final.SlotHeight,
|
client.Slot,
|
||||||
)
|
)
|
||||||
assert.Greaterf(
|
assert.LessOrEqualf(
|
||||||
t,
|
t,
|
||||||
final.TotalTransactions,
|
int(final.TotalTransactions),
|
||||||
initial.TotalTransactions,
|
client.TransactionCount,
|
||||||
"Total transactions have not increased! (%v -> %v)",
|
"Exporter transaction count (%v) ahead of client transaction count (%v)!",
|
||||||
initial.TotalTransactions,
|
int(final.TotalTransactions),
|
||||||
final.TotalTransactions,
|
client.TransactionCount,
|
||||||
)
|
)
|
||||||
assert.GreaterOrEqualf(
|
assert.LessOrEqualf(
|
||||||
t,
|
t,
|
||||||
final.EpochNumber,
|
int(final.EpochNumber),
|
||||||
initial.EpochNumber,
|
client.Epoch,
|
||||||
"Epoch number has decreased! (%v -> %v)",
|
"Exporter epoch (%v) ahead of client epoch (%v)!",
|
||||||
initial.EpochNumber,
|
int(final.EpochNumber),
|
||||||
final.EpochNumber,
|
client.Epoch,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// check if epoch changed
|
||||||
if final.EpochNumber > initial.EpochNumber {
|
if final.EpochNumber > initial.EpochNumber {
|
||||||
epochChanged = true
|
epochChanged = true
|
||||||
}
|
}
|
||||||
|
@ -219,3 +224,31 @@ func TestSolanaCollector_WatchSlots_Dynamic(t *testing.T) {
|
||||||
runCancel()
|
runCancel()
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertSlotMetricsChangeCorrectly(t *testing.T, initial slotMetricValues, final slotMetricValues) {
|
||||||
|
// make sure that things have increased
|
||||||
|
assert.Greaterf(
|
||||||
|
t,
|
||||||
|
final.SlotHeight,
|
||||||
|
initial.SlotHeight,
|
||||||
|
"Slot has not increased! (%v -> %v)",
|
||||||
|
initial.SlotHeight,
|
||||||
|
final.SlotHeight,
|
||||||
|
)
|
||||||
|
assert.Greaterf(
|
||||||
|
t,
|
||||||
|
final.TotalTransactions,
|
||||||
|
initial.TotalTransactions,
|
||||||
|
"Total transactions have not increased! (%v -> %v)",
|
||||||
|
initial.TotalTransactions,
|
||||||
|
final.TotalTransactions,
|
||||||
|
)
|
||||||
|
assert.GreaterOrEqualf(
|
||||||
|
t,
|
||||||
|
final.EpochNumber,
|
||||||
|
initial.EpochNumber,
|
||||||
|
"Epoch number has decreased! (%v -> %v)",
|
||||||
|
initial.EpochNumber,
|
||||||
|
final.EpochNumber,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue