MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / testFUSE

Function testFUSE

tests/fuse_test.go:49–88  ·  view source on GitHub ↗
(t *testing.T, tmpDir, host string, dsn string)

Source from the content-addressed store, hash-verified

47}
48
49func testFUSE(t *testing.T, tmpDir, host string, dsn string) {
50 tmpDir2, cleanup2 := createTempDir(t)
51 defer cleanup2()
52
53 waitForFUSE := func() error {
54 var err error
55 for i := 0; i < 10; i++ {
56 _, err = os.Stat(host)
57 if err == nil {
58 return nil
59 }
60 time.Sleep(500 * time.Millisecond)
61 }
62 return fmt.Errorf("failed to find FUSE mounted Unix socket: %v", err)
63 }
64
65 tcs := []struct {
66 desc string
67 dbUser string
68 args []string
69 }{
70 {
71 desc: "using default fuse",
72 args: []string{fmt.Sprintf("--fuse=%s", tmpDir), fmt.Sprintf("--fuse-tmp-dir=%s", tmpDir2)},
73 },
74 {
75 desc: "using fuse with auto-iam-authn",
76 args: []string{fmt.Sprintf("--fuse=%s", tmpDir), "--auto-iam-authn"},
77 },
78 }
79
80 for _, tc := range tcs {
81 t.Run(tc.desc, func(t *testing.T) {
82 proxyConnTestWithReady(t, tc.args, "pgx", dsn, waitForFUSE)
83 // given the kernel some time to unmount the fuse
84 time.Sleep(100 * time.Millisecond)
85 })
86 }
87
88}

Callers 1

TestPostgresFUSEConnectFunction · 0.85

Calls 3

proxyConnTestWithReadyFunction · 0.85
createTempDirFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected