summaryrefslogtreecommitdiffhomepage
path: root/test/image/image_test.go
diff options
context:
space:
mode:
authorBoyuan He & Ridwan Sharif <heboyuan@google.com>2020-08-26 15:26:46 -0400
committerAndrei Vagin <avagin@gmail.com>2020-09-16 12:19:30 -0700
commitcb9a2a1ad4f568a21382e949a592b621c11b5a2c (patch)
tree1b3a614ab27d6f22a7364113330ddde1fa21f34c /test/image/image_test.go
parent449986264f9277c4c6174fc82294fc6644923e8b (diff)
fuse: add benchmarking support for FUSE
This change adds the following: - Add support for containerizing syscall tests for FUSE - Mount tmpfs in the container so we can run benchmarks against it - Run the server in a background process - benchmarks for fuse syscall Co-authored-by: Ridwan Sharif <ridwanmsharif@google.com>
Diffstat (limited to 'test/image/image_test.go')
-rw-r--r--test/image/image_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/image/image_test.go b/test/image/image_test.go
index ac6186688..6b5928ef0 100644
--- a/test/image/image_test.go
+++ b/test/image/image_test.go
@@ -33,6 +33,7 @@ import (
"testing"
"time"
+ "github.com/docker/docker/api/types/mount"
"gvisor.dev/gvisor/pkg/test/dockerutil"
"gvisor.dev/gvisor/pkg/test/testutil"
)
@@ -63,6 +64,57 @@ func TestHelloWorld(t *testing.T) {
}
}
+// Test that the FUSE container is set up and being used properly.
+func TestFUSEInContainer(t *testing.T) {
+ if usingFUSE, err := dockerutil.UsingFUSE(); err != nil {
+ t.Fatalf("failed to read config for runtime %s: %v", dockerutil.Runtime(), err)
+ } else if !usingFUSE {
+ t.Skip("FUSE not being used.")
+ }
+
+ ctx := context.Background()
+ d := dockerutil.MakeContainer(ctx, t)
+ defer d.CleanUp(ctx)
+
+ tmpDir := "/tmpDir/"
+ // Run the basic container.
+ err := d.Spawn(ctx, dockerutil.RunOpts{
+ Image: "basic/fuse",
+ Privileged: true,
+ CapAdd: []string{"CAP_SYS_ADMIN"},
+
+ // Mount a tmpfs directory for benchmark.
+ Mounts: []mount.Mount{
+ {
+ Type: mount.TypeTmpfs,
+ Target: tmpDir,
+ ReadOnly: false,
+ },
+ },
+ }, "sleep", "1000")
+ if err != nil {
+ t.Fatalf("docker spawn failed: %v", err)
+ }
+
+ out, err := d.Exec(ctx, dockerutil.ExecOpts{
+ Privileged: true,
+ }, "/bin/sh", "-c", "ls")
+ if err != nil {
+ t.Fatalf("docker exec failed: %v, message %s", err, out)
+ }
+ if !strings.Contains(out, "server-bin") {
+ t.Fatalf("docker didn't find server binary: got %s", out)
+ }
+
+ // Run the server.
+ out, err = d.Exec(ctx, dockerutil.ExecOpts{
+ Privileged: true,
+ }, "/bin/sh", "-c", "./server-bin mountpoint")
+ if err != nil {
+ t.Fatalf("docker exec failed: %v, message %s", err, out)
+ }
+}
+
func runHTTPRequest(port int) error {
url := fmt.Sprintf("http://localhost:%d/not-found", port)
resp, err := http.Get(url)