summaryrefslogtreecommitdiffhomepage
path: root/runsc/container/multi_container_test.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-11-07 21:30:11 -0800
committerShentubot <shentubot@google.com>2018-11-07 21:30:59 -0800
commitd12a0dd6b8afaca9fbb5fe60fb84a3ae0502261a (patch)
tree6512e9420c38e6f8cc50c474d66ff267d402fbf9 /runsc/container/multi_container_test.go
parent13b48f2e6a186321084fa8159e8cc2659ed221a2 (diff)
Fix test --race violation
SetupContainerInRoot was setting Config.RootDir unnecessarily and causing a --race violation in TestMultiContainerDestroyStarting. PiperOrigin-RevId: 220580073 Change-Id: Ie0b28c19846106c7458a92681b708ae70f87d25a
Diffstat (limited to 'runsc/container/multi_container_test.go')
-rw-r--r--runsc/container/multi_container_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/runsc/container/multi_container_test.go b/runsc/container/multi_container_test.go
index 8af3d535d..d1fe687a9 100644
--- a/runsc/container/multi_container_test.go
+++ b/runsc/container/multi_container_test.go
@@ -63,6 +63,7 @@ func startContainers(conf *boot.Config, specs []*specs.Spec, ids []string) ([]*C
if err != nil {
return nil, nil, fmt.Errorf("error creating root dir: %v", err)
}
+ conf.RootDir = rootDir
var containers []*Container
var bundles []string
@@ -76,7 +77,7 @@ func startContainers(conf *boot.Config, specs []*specs.Spec, ids []string) ([]*C
os.RemoveAll(rootDir)
}
for i, spec := range specs {
- bundleDir, err := testutil.SetupContainerInRoot(rootDir, spec, conf)
+ bundleDir, err := testutil.SetupBundleDir(spec)
if err != nil {
cleanup()
return nil, nil, fmt.Errorf("error setting up container: %v", err)
@@ -617,16 +618,16 @@ func TestMultiContainerDestroyNotStarted(t *testing.T) {
specs, ids := createSpecs(
[]string{"/bin/sleep", "100"},
[]string{"/bin/sleep", "100"})
- conf := testutil.TestConfig()
-
rootDir, err := testutil.SetupRootDir()
if err != nil {
t.Fatalf("error creating root dir: %v", err)
}
defer os.RemoveAll(rootDir)
+ conf := testutil.TestConfigWithRoot(rootDir)
+
// Create and start root container.
- rootBundleDir, err := testutil.SetupContainerInRoot(rootDir, specs[0], conf)
+ rootBundleDir, err := testutil.SetupBundleDir(specs[0])
if err != nil {
t.Fatalf("error setting up container: %v", err)
}
@@ -642,7 +643,7 @@ func TestMultiContainerDestroyNotStarted(t *testing.T) {
}
// Create and destroy sub-container.
- bundleDir, err := testutil.SetupContainerInRoot(rootDir, specs[1], conf)
+ bundleDir, err := testutil.SetupBundleDir(specs[1])
if err != nil {
t.Fatalf("error setting up container: %v", err)
}
@@ -667,7 +668,6 @@ func TestMultiContainerDestroyStarting(t *testing.T) {
cmds[i] = []string{"/bin/sleep", "100"}
}
specs, ids := createSpecs(cmds...)
- conf := testutil.TestConfig()
rootDir, err := testutil.SetupRootDir()
if err != nil {
@@ -675,8 +675,10 @@ func TestMultiContainerDestroyStarting(t *testing.T) {
}
defer os.RemoveAll(rootDir)
+ conf := testutil.TestConfigWithRoot(rootDir)
+
// Create and start root container.
- rootBundleDir, err := testutil.SetupContainerInRoot(rootDir, specs[0], conf)
+ rootBundleDir, err := testutil.SetupBundleDir(specs[0])
if err != nil {
t.Fatalf("error setting up container: %v", err)
}
@@ -697,7 +699,7 @@ func TestMultiContainerDestroyStarting(t *testing.T) {
continue // skip root container
}
- bundleDir, err := testutil.SetupContainerInRoot(rootDir, specs[i], conf)
+ bundleDir, err := testutil.SetupBundleDir(specs[i])
if err != nil {
t.Fatalf("error setting up container: %v", err)
}