Skip to content

Commit

Permalink
Fix transient timeout error in sanity tests (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladislav Volodkin <vlaad@amazon.co.uk>
  • Loading branch information
vladem and Vladislav Volodkin committed Oct 27, 2023
1 parent 35e6eb9 commit fcc3bce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/driver/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"

"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/protobuf/types/known/wrapperspb"
)

func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
Expand All @@ -40,5 +41,7 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa
}

func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
return &csi.ProbeResponse{}, nil
return &csi.ProbeResponse{
Ready: wrapperspb.Bool(true),
}, nil
}
26 changes: 26 additions & 0 deletions tests/sanity/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ limitations under the License.
package sanity

import (
"context"
"os"
"testing"
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

sanity "github.com/kubernetes-csi/csi-test/pkg/sanity"

Expand All @@ -40,11 +45,32 @@ func TestSanity(t *testing.T) {
RunSpecs(t, "Sanity Tests Suite")
}

// Waits for driver's grpc server to become up.
// Testing framework connects to UDS in a hacky way (which was required before grpc implemented support for UDS),
// which leads to a "Connection timed out" error if `grpc.Dial` was called before UDS created / server started listening:
// https://github.com/kubernetes-csi/csi-test/blob/master/utils/grpcutil.go#L37
func waitDriverIsUp(endpoint string) {
By("connecting to CSI driver")
dialOptions := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
}
conn, err := grpc.Dial(endpoint, dialOptions...)
Expect(err).NotTo(HaveOccurred())
defer conn.Close()
client := csi.NewIdentityClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
resp, err := client.Probe(ctx, &csi.ProbeRequest{}, grpc.WaitForReady(true))
Expect(err).NotTo(HaveOccurred())
Expect(resp.Ready.GetValue()).To(BeTrue())
}

var _ = BeforeSuite(func() {
s3Driver = driver.NewFakeDriver(endpoint)
go func() {
Expect(s3Driver.Run()).NotTo(HaveOccurred())
}()
waitDriverIsUp(endpoint)
})

var _ = AfterSuite(func() {
Expand Down

0 comments on commit fcc3bce

Please sign in to comment.