Skip to content

Commit

Permalink
feat(dockerCompose): remove deprecated tool (#43)
Browse files Browse the repository at this point in the history
* feat(dockerCompose): remove deprecated tool
  • Loading branch information
paologallinaharbur authored Aug 21, 2024
1 parent 45233e6 commit fd53fc9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ New Relic has two kinds of integrations:
- If the test fails, it's retried after the `retry_seconds` (default 30s) and up to the `retry_attempts` (default 10) defined for the action.
- It stops & removes the services if specified in the after step.
- If `verbose` is true it logs the agent logs with other debug information.

- The action is completed.

## Install
Expand Down Expand Up @@ -156,9 +157,9 @@ scenarios:
This scenario will verify that metrics froms PDNS authoritative
are correcly collected.
before:
- docker-compose -f "deps/docker-compose.yml" up -d
- docker compose -f "deps/docker-compose.yml" up -d
after:
- docker-compose -f "deps/docker-compose.yml" down -d
- docker compose -f "deps/docker-compose.yml" down -d
integrations:
- name: nri-powerdns
binary_path: bin/nri-powerdns
Expand Down
8 changes: 4 additions & 4 deletions internal/spec/definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ scenarios:
- description: |
Scenario Description.
before:
- docker-compose -f deps/docker-compose.yml up -d
- docker compose -f deps/docker-compose.yml up -d
after:
- docker-compose -f deps/docker-compose.yml down -v
- docker compose -f deps/docker-compose.yml down -v
integrations:
- name: nri-powerdns
binary_path: bin/nri-powerdns
Expand Down Expand Up @@ -88,8 +88,8 @@ scenarios:
},
},
},
Before: []string{"docker-compose -f deps/docker-compose.yml up -d"},
After: []string{"docker-compose -f deps/docker-compose.yml down -v"},
Before: []string{"docker compose -f deps/docker-compose.yml up -d"},
After: []string{"docker compose -f deps/docker-compose.yml down -v"},
Tests: Tests{
NRQLs: []TestNRQL{{Query: "a-query"}},
Entities: []TestEntity{
Expand Down
19 changes: 9 additions & 10 deletions pkg/dockercompose/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,41 @@ import (
)

const (
dockerComposeBin = "docker-compose"
dockerBin = "docker"
dockerBin = "docker"
)

func Run(path string, container string, envVars map[string]string) error {
if err := Build(path, container, envVars); err != nil {
return err
}
args := []string{"-f", path, "run"}
args := []string{"compose", "-f", path, "run"}
for k, v := range envVars {
args = append(args, "-e", fmt.Sprintf("%s=%s", k, v))
}
args = append(args, "-d", container)
cmd := exec.Command(dockerComposeBin, args...)
cmd := exec.Command(dockerBin, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

func Down(path string) error {
args := []string{"-f", path, "down", "-v"}
cmd := exec.Command(dockerComposeBin, args...)
args := []string{"compose", "-f", path, "down", "-v"}
cmd := exec.Command(dockerBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

return cmd.Run()
}

func Build(path, container string, envVars map[string]string) error {
args := []string{"-f", path, "build", "--no-cache"}
args := []string{"compose", "-f", path, "build", "--no-cache"}
for k, v := range envVars {
args = append(args, "--build-arg", fmt.Sprintf("%s=%s", k, v))
}
args = append(args, container)
cmd := exec.Command(dockerComposeBin, args...)
cmd := exec.Command(dockerBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
Expand All @@ -62,8 +61,8 @@ func Logs(path, containerName string) string {

func getContainerID(path, containerName string) string {
const shortContainerIDLength = 12
args := []string{"-f", path, "ps", "-q", containerName}
cmd := exec.Command(dockerComposeBin, args...)
args := []string{"compose", "-f", path, "ps", "-q", containerName}
cmd := exec.Command(dockerBin, args...)
containerID, _ := cmd.Output()
if len(containerID) > shortContainerIDLength {
return string(containerID)[:shortContainerIDLength]
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/kafka/kafka-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ scenarios:
This scenario will verify that metrics from a Kafka Cluster
are correcly collected.
before:
- docker-compose -f "deps/docker-compose.yml" up -d
- docker compose -f "deps/docker-compose.yml" up -d
after:
- docker-compose -f "deps/docker-compose.yml" down -v
- docker compose -f "deps/docker-compose.yml" down -v
integrations:
- name: nri-kafka
binary_path: bin/nri-kafka
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/powerdns/powerdns-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ scenarios:
This scenario will verify that metrics from both PDNS authoritative & PDNS recursor
are correcly collected.
before:
- docker-compose -f deps/docker-compose.yml up -d
- docker compose -f deps/docker-compose.yml up -d
after:
- docker-compose -f deps/docker-compose.yml down -v
- docker compose -f deps/docker-compose.yml down -v
integrations:
- name: nri-powerdns
binary_path: bin/nri-powerdns
Expand Down

0 comments on commit fd53fc9

Please sign in to comment.