Skip to content

Commit

Permalink
chore(test): remove some incompatible in compose test
Browse files Browse the repository at this point in the history
Signed-off-by: Han Xu <suyanhanx@gmail.com>
  • Loading branch information
suyanhanx committed Nov 2, 2023
1 parent 13d6d9a commit d42b00b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 49 deletions.
11 changes: 0 additions & 11 deletions cmd/nerdctl/compose_create_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ services:
}

func TestComposeCreateDependency(t *testing.T) {
// docker-compose v1 depecreated this command
// docker-compose v2 reimplemented this command
testutil.DockerIncompatible(t)

base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down Expand Up @@ -79,9 +75,6 @@ services:
}

func TestComposeCreatePull(t *testing.T) {
// docker-compose v1 depecreated this command
// docker-compose v2 reimplemented this command
testutil.DockerIncompatible(t)

base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
Expand Down Expand Up @@ -111,10 +104,6 @@ services:
}

func TestComposeCreateBuild(t *testing.T) {
// docker-compose v1 depecreated this command
// docker-compose v2 reimplemented this command
testutil.DockerIncompatible(t)

const imageSvc0 = "composebuild_svc0"

dockerComposeYAML := fmt.Sprintf(`
Expand Down
11 changes: 6 additions & 5 deletions cmd/nerdctl/compose_down_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import (
func TestComposeDownRemoveUsedNetwork(t *testing.T) {
base := testutil.NewBase(t)

// The error output is different with docker
testutil.DockerIncompatible(t)

var (
dockerComposeYAMLOrphan = fmt.Sprintf(`
version: '3.1'
Expand Down Expand Up @@ -60,8 +57,12 @@ services:
base.ComposeCmd("-p", projectName, "-f", compFull.YAMLFullPath(), "up", "-d").AssertOK()
defer base.ComposeCmd("-p", projectName, "-f", compFull.YAMLFullPath(), "down", "--remove-orphans").AssertOK()

base.ComposeCmd("-p", projectName, "-f", compOrphan.YAMLFullPath(), "down", "-v").AssertCombinedOutContains("is in use")

// The error output is different with docker
if testutil.GetTarget() == testutil.Nerdctl {
base.ComposeCmd("-p", projectName, "-f", compOrphan.YAMLFullPath(), "down", "-v").AssertCombinedOutContains("is in use")
} else {
base.ComposeCmd("-p", projectName, "-f", compOrphan.YAMLFullPath(), "down", "-v").AssertCombinedOutContains("is still in use")
}
}

func TestComposeDownRemoveOrphans(t *testing.T) {
Expand Down
22 changes: 8 additions & 14 deletions cmd/nerdctl/compose_exec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import (
)

func TestComposeExec(t *testing.T) {
// disabling `-it` in `compose exec` is only supported in compose v2.
// Currently CI is using compose v1.
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down Expand Up @@ -62,9 +59,6 @@ services:
}

func TestComposeExecWithEnv(t *testing.T) {
// disabling `-it` in `compose exec` is only supported in compose v2.
// Currently CI is using compose v1.
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down Expand Up @@ -131,9 +125,6 @@ services:
}

func TestComposeExecWithUser(t *testing.T) {
// disabling `-it` in `compose exec` is only supported in compose v2.
// Currently CI is using compose v1.
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down Expand Up @@ -172,9 +163,6 @@ services:
}

func TestComposeExecTTY(t *testing.T) {
// `-i` in `compose run & exec` is only supported in compose v2.
// Currently CI is using compose v1.
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
if testutil.GetTarget() == testutil.Nerdctl {
testutil.RequireDaemonVersion(base, ">= 1.6.0-0")
Expand Down Expand Up @@ -206,8 +194,14 @@ services:
unbuffer := []string{"unbuffer"}
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "svc0", "stty").AssertOutContains(sttyPartialOutput) // `-it`
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-i=false", "svc0", "stty").AssertOutContains(sttyPartialOutput) // `-t`
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-t=false", "svc0", "stty").AssertFail() // `-i`
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-i=false", "-t=false", "svc0", "stty").AssertFail()
// `-i` in `compose run & exec` is only supported in compose v2
if testutil.GetTarget() == testutil.Nerdctl {
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-t=false", "svc0", "stty").AssertFail() // `-i`
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-i=false", "-t=false", "svc0", "stty").AssertFail()
} else {
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-t=false", "svc0", "stty").AssertOutContains(sttyPartialOutput) // `-i`
base.ComposeCmdWithHelper(unbuffer, "-f", comp.YAMLFullPath(), "exec", "-i=false", "-t=false", "svc0", "stty").AssertOutContains(sttyPartialOutput)
}
}

func TestComposeExecWithIndex(t *testing.T) {
Expand Down
4 changes: 0 additions & 4 deletions cmd/nerdctl/compose_images_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ volumes:
}

func TestComposeImagesJson(t *testing.T) {
// `--format` is only supported in docker compose v2.
// Currently, CI is using docker compose v1.
testutil.DockerIncompatible(t)

base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down
4 changes: 0 additions & 4 deletions cmd/nerdctl/compose_kill_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import (
)

func TestComposeKill(t *testing.T) {
// docker-compose v2 hides exited/killed containers in `compose ps`, and shows
// them if `-a` is passed, which is not supported yet by `nerdctl compose`.
testutil.DockerIncompatible(t)

base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down
4 changes: 0 additions & 4 deletions cmd/nerdctl/compose_port_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ services:
}

func TestComposePortFailure(t *testing.T) {
// when no port mapping is found, docker compose v1 prints `\n` while v2 prints `:0\n`
// both v1 and v2 have exit code 0 (succeess)
// nerdctl compose will fail with error (no public port found).
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)

var dockerComposeYAML = fmt.Sprintf(`
Expand Down
4 changes: 0 additions & 4 deletions cmd/nerdctl/compose_start_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ services:
}

func TestComposeStartFailWhenServicePause(t *testing.T) {
// Incompatible with docker compose v1. Currently CI is using compose v1.
// Starting a paused container triggers an error in v2 but is ignored in v1.
testutil.DockerIncompatible(t)

base := testutil.NewBase(t)
switch base.Info().CgroupDriver {
case "none", "":
Expand Down
3 changes: 0 additions & 3 deletions cmd/nerdctl/compose_stop_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import (
)

func TestComposeStop(t *testing.T) {
// docker-compose v2 hides exited/killed containers in `compose ps`, and shows
// them if `-a` is passed, which is not supported yet by `nerdctl compose`.
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
version: '3.1'
Expand Down

0 comments on commit d42b00b

Please sign in to comment.