summaryrefslogtreecommitdiffhomepage
path: root/test/image
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-11 13:35:25 -0700
commit9cc683af1e5c003ccc4f5a72e6b5b207e8426e1a (patch)
tree60a6a891af2dbe40cef0d77a5fe2fc520470d9e7 /test/image
parent3bd85840c8f0364083c88d65c2bc1f968069b04e (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')
-rw-r--r--test/image/BUILD1
-rw-r--r--test/image/image_test.go52
2 files changed, 53 insertions, 0 deletions
diff --git a/test/image/BUILD b/test/image/BUILD
index e749e47d4..e270c52ac 100644
--- a/test/image/BUILD
+++ b/test/image/BUILD
@@ -24,6 +24,7 @@ go_test(
deps = [
"//pkg/test/dockerutil",
"//pkg/test/testutil",
+ "@com_github_docker_docker//api/types/mount:go_default_library",
],
)
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)