summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-06-17 18:41:55 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-17 18:43:26 -0700
commit97f6b20e89d99c4d92d6491ef3fad0933c9ba53d (patch)
tree882af70a9f52ae1eefef23ed48014e09f160abd3 /test
parent57286eb642b9becc566f8e9c1dcbe24619f7772b (diff)
Move mount configutation to RunOpts
Separate mount configuration from links and move it to RunOpts, like the other options. PiperOrigin-RevId: 317010158
Diffstat (limited to 'test')
-rw-r--r--test/image/image_test.go35
-rw-r--r--test/iptables/iptables_test.go7
-rw-r--r--test/packetimpact/runner/packetimpact_test.go10
-rw-r--r--test/runtimes/runner/main.go7
4 files changed, 38 insertions, 21 deletions
diff --git a/test/image/image_test.go b/test/image/image_test.go
index 2e3543109..3e4321480 100644
--- a/test/image/image_test.go
+++ b/test/image/image_test.go
@@ -111,11 +111,12 @@ func TestHttpd(t *testing.T) {
defer d.CleanUp()
// Start the container.
- d.CopyFiles("/usr/local/apache2/htdocs", "test/image/latin10k.txt")
- if err := d.Spawn(dockerutil.RunOpts{
+ opts := dockerutil.RunOpts{
Image: "basic/httpd",
Ports: []int{80},
- }); err != nil {
+ }
+ d.CopyFiles(&opts, "/usr/local/apache2/htdocs", "test/image/latin10k.txt")
+ if err := d.Spawn(opts); err != nil {
t.Fatalf("docker run failed: %v", err)
}
@@ -138,11 +139,12 @@ func TestNginx(t *testing.T) {
defer d.CleanUp()
// Start the container.
- d.CopyFiles("/usr/share/nginx/html", "test/image/latin10k.txt")
- if err := d.Spawn(dockerutil.RunOpts{
+ opts := dockerutil.RunOpts{
Image: "basic/nginx",
Ports: []int{80},
- }); err != nil {
+ }
+ d.CopyFiles(&opts, "/usr/share/nginx/html", "test/image/latin10k.txt")
+ if err := d.Spawn(opts); err != nil {
t.Fatalf("docker run failed: %v", err)
}
@@ -183,11 +185,17 @@ func TestMysql(t *testing.T) {
// Tell mysql client to connect to the server and execute the file in
// verbose mode to verify the output.
- client.CopyFiles("/sql", "test/image/mysql.sql")
- client.Link("mysql", server)
- if _, err := client.Run(dockerutil.RunOpts{
+ opts := dockerutil.RunOpts{
Image: "basic/mysql",
- }, "mysql", "-hmysql", "-uroot", "-pfoobar123", "-v", "-e", "source /sql/mysql.sql"); err != nil {
+ Links: []dockerutil.Link{
+ {
+ Source: server,
+ Target: "mysql",
+ },
+ },
+ }
+ client.CopyFiles(&opts, "/sql", "test/image/mysql.sql")
+ if _, err := client.Run(opts, "mysql", "-hmysql", "-uroot", "-pfoobar123", "-v", "-e", "source /sql/mysql.sql"); err != nil {
t.Fatalf("docker run failed: %v", err)
}
@@ -236,11 +244,12 @@ func TestRuby(t *testing.T) {
defer d.CleanUp()
// Execute the ruby workload.
- d.CopyFiles("/src", "test/image/ruby.rb", "test/image/ruby.sh")
- if err := d.Spawn(dockerutil.RunOpts{
+ opts := dockerutil.RunOpts{
Image: "basic/ruby",
Ports: []int{8080},
- }, "/src/ruby.sh"); err != nil {
+ }
+ d.CopyFiles(&opts, "/src", "test/image/ruby.rb", "test/image/ruby.sh")
+ if err := d.Spawn(opts, "/src/ruby.sh"); err != nil {
t.Fatalf("docker run failed: %v", err)
}
diff --git a/test/iptables/iptables_test.go b/test/iptables/iptables_test.go
index 38319a3b2..340f9426e 100644
--- a/test/iptables/iptables_test.go
+++ b/test/iptables/iptables_test.go
@@ -41,11 +41,12 @@ func singleTest(t *testing.T, test TestCase) {
defer d.CleanUp()
// Create and start the container.
- d.CopyFiles("/runner", "test/iptables/runner/runner")
- if err := d.Spawn(dockerutil.RunOpts{
+ opts := dockerutil.RunOpts{
Image: "iptables",
CapAdd: []string{"NET_ADMIN"},
- }, "/runner/runner", "-name", test.Name()); err != nil {
+ }
+ d.CopyFiles(&opts, "/runner", "test/iptables/runner/runner")
+ if err := d.Spawn(opts, "/runner/runner", "-name", test.Name()); err != nil {
t.Fatalf("docker run failed: %v", err)
}
diff --git a/test/packetimpact/runner/packetimpact_test.go b/test/packetimpact/runner/packetimpact_test.go
index 75617f6de..3cac5915f 100644
--- a/test/packetimpact/runner/packetimpact_test.go
+++ b/test/packetimpact/runner/packetimpact_test.go
@@ -142,7 +142,7 @@ func TestOne(t *testing.T) {
}
const containerPosixServerBinary = "/packetimpact/posix_server"
- dut.CopyFiles("/packetimpact", "/test/packetimpact/dut/posix_server")
+ dut.CopyFiles(&runOpts, "/packetimpact", "/test/packetimpact/dut/posix_server")
if err := dut.Create(runOpts, containerPosixServerBinary, "--ip=0.0.0.0", "--port="+ctrlPort); err != nil {
t.Fatalf("unable to create container %s: %s", dut.Name, err)
@@ -193,7 +193,13 @@ func TestOne(t *testing.T) {
tbb := path.Base(*testbenchBinary)
containerTestbenchBinary := "/packetimpact/" + tbb
- testbench.CopyFiles("/packetimpact", "/test/packetimpact/tests/"+tbb)
+ runOpts = dockerutil.RunOpts{
+ Image: "packetimpact",
+ CapAdd: []string{"NET_ADMIN"},
+ Extra: []string{"--sysctl", "net.ipv6.conf.all.disable_ipv6=0", "--rm", "-v", tmpDir + ":" + testOutputDir},
+ Foreground: true,
+ }
+ testbench.CopyFiles(&runOpts, "/packetimpact", "/test/packetimpact/tests/"+tbb)
// Run tcpdump in the test bench unbuffered, without DNS resolution, just on
// the interface with the test packets.
diff --git a/test/runtimes/runner/main.go b/test/runtimes/runner/main.go
index 7989dca84..54d1169ef 100644
--- a/test/runtimes/runner/main.go
+++ b/test/runtimes/runner/main.go
@@ -79,10 +79,11 @@ func runTests() int {
// getTests executes all tests as table tests.
func getTests(d *dockerutil.Docker, excludes map[string]struct{}) ([]testing.InternalTest, error) {
// Start the container.
- d.CopyFiles("/proctor", "test/runtimes/proctor/proctor")
- if err := d.Spawn(dockerutil.RunOpts{
+ opts := dockerutil.RunOpts{
Image: fmt.Sprintf("runtimes/%s", *image),
- }, "/proctor/proctor", "--pause"); err != nil {
+ }
+ d.CopyFiles(&opts, "/proctor", "test/runtimes/proctor/proctor")
+ if err := d.Spawn(opts, "/proctor/proctor", "--pause"); err != nil {
return nil, fmt.Errorf("docker run failed: %v", err)
}