Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Unit Test Coverage #456

Draft
wants to merge 33 commits into
base: usr/spark/unit-test-improvements
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5bbc29a
migrate snapCleaner global to svc struct member.
lukeatdell Feb 10, 2025
cc031ab
create admin clients for new service instances
lukeatdell Feb 10, 2025
f8d37c5
Fix race condition in node_connectivity_checker
tdawe Feb 10, 2025
f443e85
use safe error injector func from gopowermax mock pkg
lukeatdell Feb 10, 2025
2182099
Fix race condition in deletion worker
tdawe Feb 11, 2025
5853e49
update gopowermax module version.
lukeatdell Feb 11, 2025
8927281
Added storeProbeStatus to fix race condition
tdawe Feb 11, 2025
8977ecf
refactor makefile for easier use.
lukeatdell Feb 11, 2025
4395e8d
Fix race condition with induced error global variables
tdawe Feb 12, 2025
d190d29
Fix race conditions in metro.go
kumarp20 Feb 12, 2025
24dcaa7
fix race condition related to nvmeTCPtargets map access
kumarp20 Feb 12, 2025
4819f78
update gopowermax refs and module version
lukeatdell Feb 12, 2025
2f3de9d
Fix race condition when getting powermax client
tdawe Feb 13, 2025
a3353b9
go mod tidy
lukeatdell Feb 13, 2025
0e18ca0
adding some unit tests for mount.go
lukeatdell Feb 13, 2025
c43c860
Add tests for deletion_worker
tdawe Feb 13, 2025
5949783
Reset sync time after test
tdawe Feb 16, 2025
5414f74
Add tests thet increase coverage for node.go
kumarp20 Feb 17, 2025
381c449
Merge branch 'usr/spark/ut-svc-pkg' of https://github.com/dell/csi-po…
kumarp20 Feb 17, 2025
4121763
removing a test that is wip
kumarp20 Feb 17, 2025
0d48cc4
inc coverage for setArrayConfigEnvs
lukeatdell Feb 17, 2025
a359524
Improve migration test to 91.3%
xuluna Feb 18, 2025
d8c3153
Unit tests for csi_ctrl_to_node_connectivity.go file
harshitap26 Feb 18, 2025
4148266
Added Unit test for snap.go
harshitap26 Feb 18, 2025
0effc08
add a couple tests for snap.go
lukeatdell Feb 18, 2025
ba8ca88
Added UTs for interfaces.go
bharathsreekanth Feb 18, 2025
ea58eee
update mock package to active go.uber.org/mock/gomock
lukeatdell Feb 18, 2025
edcfff8
adding tests for controller.go
lukeatdell Feb 18, 2025
35c9d50
Refactor interfaces unit test
bharathsreekanth Feb 19, 2025
fdd4afb
update gomock mod provider in other pkgs
lukeatdell Feb 19, 2025
7c2a5fe
unit tests for node.go
kumarp20 Feb 19, 2025
8c05757
Merge branch 'usr/spark/ut-svc-pkg' of https://github.com/dell/csi-po…
kumarp20 Feb 19, 2025
da73130
Add tests for service.go
tdawe Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ require (
github.com/dell/gofsutil v1.18.0
github.com/dell/goiscsi v1.11.0
github.com/dell/gonvme v1.10.1
github.com/dell/gopowermax/v2 v2.9.0
github.com/dell/gopowermax/v2 v2.9.1-0.20250218220907-bf05e7e5d465
github.com/fsnotify/fsnotify v1.8.0
github.com/golang/mock v1.6.0
github.com/gorilla/mux v1.8.1
github.com/kubernetes-csi/csi-lib-utils v0.11.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
github.com/vmware/govmomi v0.47.1
go.uber.org/mock v0.5.0
golang.org/x/net v0.34.0
google.golang.org/grpc v1.69.4
google.golang.org/protobuf v1.36.3
Expand All @@ -50,7 +52,6 @@ require (
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ github.com/dell/goiscsi v1.11.0 h1:DkopmZ1HVa/lueAOgQLfl+z9pntjJzCDTm2ljx9wI5k=
github.com/dell/goiscsi v1.11.0/go.mod h1:uDXlWSh0w5BdLr5XhPKUyNpkJDTc0jmnz/u6QcPkIyA=
github.com/dell/gonvme v1.10.1 h1:SNSrp3aI/h2wL0x663iinxrqv5TCNGHgTb/lbYEd+Y4=
github.com/dell/gonvme v1.10.1/go.mod h1:FdClafOpCLMtvGMLgf7n3SPeDnweKV6eYsaD3AA3qsw=
github.com/dell/gopowermax/v2 v2.9.0 h1:hF8AI6+et/Rq4jbQQ/u8P64W/3dx/51i0shfGtF6R7o=
github.com/dell/gopowermax/v2 v2.9.0/go.mod h1:snOhGKDyMPO4rVUNwEMH2fOwwMNyPP8DtBtafIs8WCs=
github.com/dell/gopowermax/v2 v2.9.1-0.20250218220907-bf05e7e5d465 h1:pcG3fTXQEGuG+/lNtmeHHp67g+32UntahvcMuA91qys=
github.com/dell/gopowermax/v2 v2.9.1-0.20250218220907-bf05e7e5d465/go.mod h1:nPrviodvC5IvhJ4UWujFbLF8K2Nj49LrYVHkEma0ods=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
Expand Down Expand Up @@ -526,6 +526,8 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down
2 changes: 1 addition & 1 deletion pkg/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/dell/csi-powermax/v2/pkg/symmetrix/mocks"
"github.com/dell/gofsutil"
types "github.com/dell/gopowermax/v2/types/v100"
"github.com/golang/mock/gomock"
"go.uber.org/mock/gomock"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/migration/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/dell/csi-powermax/v2/pkg/symmetrix/mocks"
types "github.com/dell/gopowermax/v2/types/v100"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down
7 changes: 4 additions & 3 deletions pkg/symmetrix/metro.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"fmt"
"net/http"
"sync"
"sync/atomic"
"time"

pmax "github.com/dell/gopowermax/v2"
Expand All @@ -27,7 +28,7 @@
var metroClients sync.Map

const (
failoverThereshold int = 5
failoverThereshold int32 = 5
failureTimeThreshold time.Duration = 2 * time.Minute
)

Expand All @@ -46,7 +47,7 @@
primaryArray string
secondaryArray string
activeArray string
failureCount int
failureCount int32
lastFailure time.Time
mx sync.Mutex
}
Expand Down Expand Up @@ -84,7 +85,7 @@
log.Infof("Last failure was more than %f minutes ago; reseting the failure count", failureTimeThreshold.Minutes())
m.failureCount = 1
} else {
m.failureCount = m.failureCount + failureWeight
atomic.AddInt32(&(m.failureCount), int32(failureWeight))

Check failure on line 88 in pkg/symmetrix/metro.go

View workflow job for this annotation

GitHub Actions / Golang Validation / Lint golang code

G115: integer overflow conversion int -> int32 (gosec)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/symmetrix/metro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func TestMetroClient_healthHandler(t *testing.T) {
tests := []struct {
name string
failureWeight int
failureCount int
failureCount int32
lastFailure time.Time
expectedCount int
expectedCount int32
expectedActive string
}{
{
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestMetroClient_getActiveArray(t *testing.T) {
tests := []struct {
name string
failureWeight int
failureCount int
failureCount int32
lastFailure time.Time
expectedActive string
activeArray string
Expand Down
Loading