|
|
@@ -158,6 +158,44 @@ func TestLocalComposeRun(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+func TestNetworks(t *testing.T) {
|
|
|
+ c := NewParallelE2eCLI(t, binDir)
|
|
|
+
|
|
|
+ const projectName = "network_e2e"
|
|
|
+
|
|
|
+ t.Run("ensure we do not reuse previous networks", func(t *testing.T) {
|
|
|
+ c.RunDockerOrExitError("network", "rm", projectName+"_dbnet")
|
|
|
+ c.RunDockerOrExitError("network", "rm", "microservices")
|
|
|
+ })
|
|
|
+
|
|
|
+ t.Run("up", func(t *testing.T) {
|
|
|
+ c.RunDockerCmd("compose", "up", "-d", "-f", "./fixtures/network-test/docker-compose.yaml", "--project-name", projectName, "-d")
|
|
|
+ })
|
|
|
+
|
|
|
+ t.Run("check running project", func(t *testing.T) {
|
|
|
+ res := c.RunDockerCmd("compose", "ps", "-p", projectName)
|
|
|
+ res.Assert(t, icmd.Expected{Out: `web`})
|
|
|
+
|
|
|
+ endpoint := "http://localhost:80"
|
|
|
+ output := HTTPGetWithRetry(t, endpoint+"/words/noun", http.StatusOK, 2*time.Second, 20*time.Second)
|
|
|
+ assert.Assert(t, strings.Contains(output, `"word":`))
|
|
|
+
|
|
|
+ res = c.RunDockerCmd("network", "ls")
|
|
|
+ res.Assert(t, icmd.Expected{Out: projectName + "_dbnet"})
|
|
|
+ res.Assert(t, icmd.Expected{Out: "microservices"})
|
|
|
+ })
|
|
|
+
|
|
|
+ t.Run("down", func(t *testing.T) {
|
|
|
+ _ = c.RunDockerCmd("compose", "down", "--project-name", projectName)
|
|
|
+ })
|
|
|
+
|
|
|
+ t.Run("check networks after down", func(t *testing.T) {
|
|
|
+ res := c.RunDockerCmd("network", "ls")
|
|
|
+ assert.Assert(t, !strings.Contains(res.Combined(), projectName), res.Combined())
|
|
|
+ assert.Assert(t, !strings.Contains(res.Combined(), "microservices"), res.Combined())
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
func TestLocalComposeBuild(t *testing.T) {
|
|
|
c := NewParallelE2eCLI(t, binDir)
|
|
|
|
|
|
@@ -213,6 +251,7 @@ func TestLocalComposeVolume(t *testing.T) {
|
|
|
//ensure local test run does not reuse previously build image
|
|
|
c.RunDockerOrExitError("rmi", "compose-e2e-volume_nginx")
|
|
|
c.RunDockerOrExitError("volume", "rm", projectName+"_staticVol")
|
|
|
+ c.RunDockerOrExitError("volume", "rm", "myvolume")
|
|
|
c.RunDockerCmd("compose", "up", "-d", "--workdir", "fixtures/volume-test", "--project-name", projectName)
|
|
|
})
|
|
|
|
|
|
@@ -224,7 +263,7 @@ func TestLocalComposeVolume(t *testing.T) {
|
|
|
t.Run("check container volume specs", func(t *testing.T) {
|
|
|
res := c.RunDockerCmd("inspect", "compose-e2e-volume_nginx2_1", "--format", "{{ json .HostConfig.Mounts }}")
|
|
|
//nolint
|
|
|
- res.Assert(t, icmd.Expected{Out: `[{"Type":"volume","Source":"compose-e2e-volume_staticVol","Target":"/usr/share/nginx/html","ReadOnly":true},{"Type":"volume","Target":"/usr/src/app/node_modules"}]`})
|
|
|
+ res.Assert(t, icmd.Expected{Out: `[{"Type":"volume","Source":"compose-e2e-volume_staticVol","Target":"/usr/share/nginx/html","ReadOnly":true},{"Type":"volume","Target":"/usr/src/app/node_modules"},{"Type":"volume","Source":"myVolume","Target":"/usr/share/nginx/test"}]`})
|
|
|
})
|
|
|
|
|
|
t.Run("cleanup volume project", func(t *testing.T) {
|