Skip to content

Commit

Permalink
Generic improvements (#88)
Browse files Browse the repository at this point in the history
* Fix Quobyte API version used.

Do not build with local version of API (currently
works as go builds single monolith with all the deps).
However, include API from the declared dependencies.

* Add deletion test for api failure

Errors triggered by the api should be propagated back to
higher caller (k8s), add a test to confirm that.
  • Loading branch information
venkatsc authored Aug 8, 2024
1 parent b74d165 commit 1ca926f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 1ca926f

Please sign in to comment.