VOL-2880: Reduction of Unit Test Time
Unit Test time before these changes was around 90 seconds.
With these minor changes we could reduce it to around 40 seconds.
Change-Id: I3abe7dc487117e31275862a2d0172e2bc85c2969
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 4db1b93..9fd8127 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -965,6 +965,7 @@
if err := tt.devicehandler.doStateUp(ctx); (err != nil) != tt.wantErr {
t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
}
+ tt.devicehandler.stopCollector <- true //stop the stat collector invoked from doStateUp
})
}
}
@@ -1177,7 +1178,7 @@
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
go func() {
- time.Sleep(66 * time.Second) // startCollector inside waits for 1 min, so we stop it after 6 secs of running
+ time.Sleep(5 * time.Second) // simulated wait time to stop startCollector
tt.args.dh.stopCollector <- true
}()
startCollector(tt.args.dh)