diff --git a/src/driver/controller_test.go b/src/driver/controller_test.go index 8c4aa7d..1f59176 100644 --- a/src/driver/controller_test.go +++ b/src/driver/controller_test.go @@ -5,6 +5,7 @@ import ( "net/url" "strings" "testing" + "fmt" "github.com/container-storage-interface/spec/lib/go/csi" mock_quobyte_api "github.com/quobyte/api/mocks" @@ -78,6 +79,26 @@ func TestDeleteVolume(t *testing.T) { assert.Nil(err) assert.NotNil(got) assert.Equal(&csi.DeleteVolumeResponse{}, got) + + // Erase volume failure should send back error to upper layer + ctrl = gomock.NewController(t) + quoybteClient = mock_quobyte_api.NewMockExtendedQuobyteApi(ctrl) + quoybteClient.EXPECT().EraseVolumeByResolvingNamesToUUID( + gomock.Eq(volume), gomock.Eq(tenant), gomock.Any()).Return(fmt.Errorf("Erase volume error")) + quobyteClientProvider = mocks.NewMockQuobyteApiClientProvider(ctrl) + quobyteClientProvider.EXPECT().NewQuobyteApiClient(gomock.Any(), gomock.Any()).DoAndReturn( + func (_ *url.URL, _ map[string]string) (quobyte.ExtendedQuobyteApi, error) { + return quoybteClient, nil + }).AnyTimes() + d.quoybteClientFactory = quobyteClientProvider + req = &csi.DeleteVolumeRequest{ + VolumeId: tenant + SEPARATOR + volume, + Secrets: secrets, + } + got, err = d.DeleteVolume(context.TODO(), req) + assert.NotNil(err) + assert.Contains(err.Error(), "Erase volume error") + assert.Nil(got) // TODO(venkat): add snapshots and subdir (shared volume) tests } diff --git a/src/go.mod b/src/go.mod index 02dd53f..9c8a495 100644 --- a/src/go.mod +++ b/src/go.mod @@ -24,4 +24,5 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/quobyte/api => /home/venkat/go/src/github.com/quobyte/api +// Uncomment only during testing with local version of Quobyte API +//replace github.com/quobyte/api => /home/venkat/go/src/github.com/quobyte/api diff --git a/src/go.sum b/src/go.sum index 68740f3..a85d517 100644 --- a/src/go.sum +++ b/src/go.sum @@ -11,6 +11,8 @@ github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iP github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/quobyte/api v1.3.0 h1:4Qto1m+dgoqSH9o3C8TvwpN+08lmEiOxEBcQOPzmg9s= +github.com/quobyte/api v1.3.0/go.mod h1:+TJmul6UJXpU0QLE0Rq2lFCYcr7GNyKrVOdMJCnZkY0= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=