forked from kata-containers/ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kata-containers#39 from GabyCT/topic/dockerintegra…
…tion tests: Add docker integration test for attach, commit, cp and create.
- Loading branch information
Showing
4 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2018 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package docker | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("docker attach", func() { | ||
var ( | ||
id string | ||
exitCode int | ||
containerExitCode int | ||
destroyTimeout int | ||
) | ||
|
||
BeforeEach(func() { | ||
containerExitCode = 13 | ||
destroyTimeout = 3 | ||
id = randomDockerName() | ||
_, _, exitCode = dockerRun("--name", id, "-d", Image, "sh", "-c", | ||
fmt.Sprintf("sleep %d && exit %d", destroyTimeout, containerExitCode)) | ||
Expect(exitCode).To(Equal(0)) | ||
}) | ||
|
||
AfterEach(func() { | ||
Expect(RemoveDockerContainer(id)).To(BeTrue()) | ||
Expect(ExistDockerContainer(id)).NotTo(BeTrue()) | ||
}) | ||
|
||
Context("check attach functionality", func() { | ||
It("should attach exit code", func() { | ||
_, _, exitCode = dockerAttach(id) | ||
Expect(exitCode).To(Equal(containerExitCode)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2018 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package docker | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("docker commit", func() { | ||
var ( | ||
id string | ||
exitCode int | ||
stdout string | ||
) | ||
|
||
BeforeEach(func() { | ||
id = randomDockerName() | ||
_, _, exitCode = dockerRun("-td", "--name", id, Image, "sh") | ||
Expect(exitCode).To(Equal(0)) | ||
}) | ||
|
||
AfterEach(func() { | ||
Expect(RemoveDockerContainer(id)).To(BeTrue()) | ||
Expect(ExistDockerContainer(id)).NotTo(BeTrue()) | ||
}) | ||
|
||
Context("commit a container with new configurations", func() { | ||
It("should have the new configurations", func() { | ||
imageName := "test/container-test" | ||
_, _, exitCode = dockerCommit("-m", "test_commit", id, imageName) | ||
Expect(exitCode).To(Equal(0)) | ||
|
||
stdout, _, exitCode = dockerImages() | ||
Expect(exitCode).To(Equal(0)) | ||
Expect(stdout).To(ContainSubstring(imageName)) | ||
|
||
_, _, exitCode = dockerRmi(imageName) | ||
Expect(exitCode).To(Equal(0)) | ||
|
||
stdout, _, exitCode = dockerImages() | ||
Expect(exitCode).To(Equal(0)) | ||
Expect(stdout).NotTo(ContainSubstring(imageName)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2018 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package docker | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("docker cp", func() { | ||
var ( | ||
id string | ||
exitCode int | ||
stdout string | ||
) | ||
|
||
BeforeEach(func() { | ||
id = randomDockerName() | ||
_, _, exitCode = dockerRun("-td", "--name", id, Image, "sh") | ||
Expect(exitCode).To(Equal(0)) | ||
}) | ||
|
||
AfterEach(func() { | ||
Expect(RemoveDockerContainer(id)).To(BeTrue()) | ||
Expect(ExistDockerContainer(id)).NotTo(BeTrue()) | ||
}) | ||
|
||
Context("check files after a docker cp", func() { | ||
It("should have the corresponding files", func() { | ||
file, err := ioutil.TempFile(os.TempDir(), "file") | ||
Expect(err).ToNot(HaveOccurred()) | ||
err = file.Close() | ||
Expect(err).ToNot(HaveOccurred()) | ||
defer os.Remove(file.Name()) | ||
Expect(file.Name()).To(BeAnExistingFile()) | ||
|
||
_, _, exitCode = dockerCp(file.Name(), id+":/root/") | ||
Expect(exitCode).To(Equal(0)) | ||
|
||
stdout, _, exitCode = dockerExec(id, "ls", "/root/") | ||
Expect(exitCode).To(Equal(0)) | ||
testFile := path.Base(file.Name()) | ||
Expect(stdout).To(ContainSubstring(testFile)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2018 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package docker | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("docker create", func() { | ||
var ( | ||
id string | ||
exitCode int | ||
stdout string | ||
) | ||
|
||
BeforeEach(func() { | ||
id = randomDockerName() | ||
}) | ||
|
||
AfterEach(func() { | ||
Expect(RemoveDockerContainer(id)).To(BeTrue()) | ||
Expect(ExistDockerContainer(id)).NotTo(BeTrue()) | ||
}) | ||
|
||
Context("check create functionality", func() { | ||
It("create a container", func() { | ||
_, _, exitCode = dockerCreate("-t", "--name", id, Image) | ||
Expect(exitCode).To(Equal(0)) | ||
|
||
stdout, _, exitCode = dockerPs("--filter", "status=created") | ||
Expect(exitCode).To(Equal(0)) | ||
Expect(stdout).To(ContainSubstring(id)) | ||
}) | ||
}) | ||
}) |