summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2021-02-01 12:28:31 -0800
committergVisor bot <gvisor-bot@google.com>2021-02-01 12:30:45 -0800
commit0da3c72c9d24c322af8203511142462fab3b1bd9 (patch)
tree437f1eafc868dcf3e9043e9c0572c2ab9152d2c6
parentebd3912c0f7e4255f100a00d2ab27304dac70daa (diff)
[infra] Consolidate all ubuntu tests into one image.
This makes it easier to add more tests that run on Ubuntu. We can now just add a bash script and call that from integration_test without having to set up another image. PiperOrigin-RevId: 355000410
-rw-r--r--images/basic/hostoverlaytest/Dockerfile8
-rw-r--r--images/basic/integrationtest/Dockerfile7
-rw-r--r--images/basic/integrationtest/copy_up_testfile.txt (renamed from images/basic/hostoverlaytest/copy_up_testfile.txt)0
-rw-r--r--images/basic/integrationtest/link_test.c (renamed from images/basic/linktest/link_test.c)0
-rw-r--r--images/basic/integrationtest/ping4.sh (renamed from images/basic/ping4test/ping4.sh)0
-rw-r--r--images/basic/integrationtest/ping6.sh (renamed from images/basic/ping6test/ping6.sh)0
-rw-r--r--images/basic/integrationtest/test_copy_up.c (renamed from images/basic/hostoverlaytest/test_copy_up.c)0
-rw-r--r--images/basic/integrationtest/test_rewinddir.c (renamed from images/basic/hostoverlaytest/test_rewinddir.c)0
-rw-r--r--images/basic/linktest/Dockerfile7
-rw-r--r--images/basic/ping4test/Dockerfile7
-rw-r--r--images/basic/ping6test/Dockerfile7
-rw-r--r--test/e2e/integration_test.go74
12 files changed, 25 insertions, 85 deletions
diff --git a/images/basic/hostoverlaytest/Dockerfile b/images/basic/hostoverlaytest/Dockerfile
deleted file mode 100644
index 6cef1a542..000000000
--- a/images/basic/hostoverlaytest/Dockerfile
+++ /dev/null
@@ -1,8 +0,0 @@
-FROM ubuntu:bionic
-
-WORKDIR /root
-COPY . .
-
-RUN apt-get update && apt-get install -y gcc
-RUN gcc -O2 -o test_copy_up test_copy_up.c
-RUN gcc -O2 -o test_rewinddir test_rewinddir.c
diff --git a/images/basic/integrationtest/Dockerfile b/images/basic/integrationtest/Dockerfile
new file mode 100644
index 000000000..e80e17527
--- /dev/null
+++ b/images/basic/integrationtest/Dockerfile
@@ -0,0 +1,7 @@
+FROM ubuntu:bionic
+
+WORKDIR /root
+COPY . .
+RUN chmod +x *.sh
+
+RUN apt-get update && apt-get install -y gcc iputils-ping iproute2
diff --git a/images/basic/hostoverlaytest/copy_up_testfile.txt b/images/basic/integrationtest/copy_up_testfile.txt
index e4188c841..e4188c841 100644
--- a/images/basic/hostoverlaytest/copy_up_testfile.txt
+++ b/images/basic/integrationtest/copy_up_testfile.txt
diff --git a/images/basic/linktest/link_test.c b/images/basic/integrationtest/link_test.c
index 45ab00abe..45ab00abe 100644
--- a/images/basic/linktest/link_test.c
+++ b/images/basic/integrationtest/link_test.c
diff --git a/images/basic/ping4test/ping4.sh b/images/basic/integrationtest/ping4.sh
index 2a343712a..2a343712a 100644
--- a/images/basic/ping4test/ping4.sh
+++ b/images/basic/integrationtest/ping4.sh
diff --git a/images/basic/ping6test/ping6.sh b/images/basic/integrationtest/ping6.sh
index 4268951d0..4268951d0 100644
--- a/images/basic/ping6test/ping6.sh
+++ b/images/basic/integrationtest/ping6.sh
diff --git a/images/basic/hostoverlaytest/test_copy_up.c b/images/basic/integrationtest/test_copy_up.c
index 010b261dc..010b261dc 100644
--- a/images/basic/hostoverlaytest/test_copy_up.c
+++ b/images/basic/integrationtest/test_copy_up.c
diff --git a/images/basic/hostoverlaytest/test_rewinddir.c b/images/basic/integrationtest/test_rewinddir.c
index f1a4085e1..f1a4085e1 100644
--- a/images/basic/hostoverlaytest/test_rewinddir.c
+++ b/images/basic/integrationtest/test_rewinddir.c
diff --git a/images/basic/linktest/Dockerfile b/images/basic/linktest/Dockerfile
deleted file mode 100644
index baebc9b76..000000000
--- a/images/basic/linktest/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ubuntu:bionic
-
-WORKDIR /root
-COPY . .
-
-RUN apt-get update && apt-get install -y gcc
-RUN gcc -O2 -o link_test link_test.c
diff --git a/images/basic/ping4test/Dockerfile b/images/basic/ping4test/Dockerfile
deleted file mode 100644
index 1536be376..000000000
--- a/images/basic/ping4test/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ubuntu:bionic
-
-WORKDIR /root
-COPY ping4.sh .
-RUN chmod +x ping4.sh
-
-RUN apt-get update && apt-get install -y iputils-ping
diff --git a/images/basic/ping6test/Dockerfile b/images/basic/ping6test/Dockerfile
deleted file mode 100644
index cb740bd60..000000000
--- a/images/basic/ping6test/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ubuntu:bionic
-
-WORKDIR /root
-COPY ping6.sh .
-RUN chmod +x ping6.sh
-
-RUN apt-get update && apt-get install -y iputils-ping iproute2
diff --git a/test/e2e/integration_test.go b/test/e2e/integration_test.go
index d07ed6ba5..aaffabfd0 100644
--- a/test/e2e/integration_test.go
+++ b/test/e2e/integration_test.go
@@ -434,18 +434,7 @@ func TestTmpMount(t *testing.T) {
// runsc to hide the incoherence of FDs opened before and after overlayfs
// copy-up on the host.
func TestHostOverlayfsCopyUp(t *testing.T) {
- ctx := context.Background()
- d := dockerutil.MakeContainer(ctx, t)
- defer d.CleanUp(ctx)
-
- if got, err := d.Run(ctx, dockerutil.RunOpts{
- Image: "basic/hostoverlaytest",
- WorkDir: "/root",
- }, "./test_copy_up"); err != nil {
- t.Fatalf("docker run failed: %v", err)
- } else if got != "" {
- t.Errorf("test failed:\n%s", got)
- }
+ runIntegrationTest(t, nil, "sh", "-c", "gcc -O2 -o test_copy_up test_copy_up.c && ./test_copy_up")
}
// TestHostOverlayfsRewindDir tests that rewinddir() "causes the directory
@@ -460,36 +449,14 @@ func TestHostOverlayfsCopyUp(t *testing.T) {
// automated tests yield newly-added files from readdir() even if the fsgofer
// does not explicitly rewinddir(), but overlayfs does not.
func TestHostOverlayfsRewindDir(t *testing.T) {
- ctx := context.Background()
- d := dockerutil.MakeContainer(ctx, t)
- defer d.CleanUp(ctx)
-
- if got, err := d.Run(ctx, dockerutil.RunOpts{
- Image: "basic/hostoverlaytest",
- WorkDir: "/root",
- }, "./test_rewinddir"); err != nil {
- t.Fatalf("docker run failed: %v", err)
- } else if got != "" {
- t.Errorf("test failed:\n%s", got)
- }
+ runIntegrationTest(t, nil, "sh", "-c", "gcc -O2 -o test_rewinddir test_rewinddir.c && ./test_rewinddir")
}
// Basic test for linkat(2). Syscall tests requires CAP_DAC_READ_SEARCH and it
// cannot use tricks like userns as root. For this reason, run a basic link test
// to ensure some coverage.
func TestLink(t *testing.T) {
- ctx := context.Background()
- d := dockerutil.MakeContainer(ctx, t)
- defer d.CleanUp(ctx)
-
- if got, err := d.Run(ctx, dockerutil.RunOpts{
- Image: "basic/linktest",
- WorkDir: "/root",
- }, "./link_test"); err != nil {
- t.Fatalf("docker run failed: %v", err)
- } else if got != "" {
- t.Errorf("test failed:\n%s", got)
- }
+ runIntegrationTest(t, nil, "sh", "-c", "gcc -O2 -o link_test link_test.c && ./link_test")
}
// This test ensures we can run ping without errors.
@@ -500,17 +467,7 @@ func TestPing4Loopback(t *testing.T) {
t.Skip("hostnet only supports TCP/UDP sockets, so ping is not supported.")
}
- ctx := context.Background()
- d := dockerutil.MakeContainer(ctx, t)
- defer d.CleanUp(ctx)
-
- if got, err := d.Run(ctx, dockerutil.RunOpts{
- Image: "basic/ping4test",
- }, "/root/ping4.sh"); err != nil {
- t.Fatalf("docker run failed: %s", err)
- } else if got != "" {
- t.Errorf("test failed:\n%s", got)
- }
+ runIntegrationTest(t, nil, "./ping4.sh")
}
// This test ensures we can enable ipv6 on loopback and run ping6 without
@@ -522,20 +479,25 @@ func TestPing6Loopback(t *testing.T) {
t.Skip("hostnet only supports TCP/UDP sockets, so ping6 is not supported.")
}
+ // The CAP_NET_ADMIN capability is required to use the `ip` utility, which
+ // we use to enable ipv6 on loopback.
+ //
+ // By default, ipv6 loopback is not enabled by runsc, because docker does
+ // not assign an ipv6 address to the test container.
+ runIntegrationTest(t, []string{"NET_ADMIN"}, "./ping6.sh")
+}
+
+func runIntegrationTest(t *testing.T, capAdd []string, args ...string) {
ctx := context.Background()
d := dockerutil.MakeContainer(ctx, t)
defer d.CleanUp(ctx)
if got, err := d.Run(ctx, dockerutil.RunOpts{
- Image: "basic/ping6test",
- // The CAP_NET_ADMIN capability is required to use the `ip` utility, which
- // we use to enable ipv6 on loopback.
- //
- // By default, ipv6 loopback is not enabled by runsc, because docker does
- // not assign an ipv6 address to the test container.
- CapAdd: []string{"NET_ADMIN"},
- }, "/root/ping6.sh"); err != nil {
- t.Fatalf("docker run failed: %s", err)
+ Image: "basic/integrationtest",
+ WorkDir: "/root",
+ CapAdd: capAdd,
+ }, args...); err != nil {
+ t.Fatalf("docker run failed: %v", err)
} else if got != "" {
t.Errorf("test failed:\n%s", got)
}