Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix integration test failures #396

Merged
merged 29 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,34 @@ jobs:
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \
make integration-test
- name: Output Logs
if: failure()
run: |
docker ps -a
dockerid=$(docker ps -a --format "{{.ID}}")
docker logs "$dockerid"

- name: Archive install/uninstall integration test logs
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: integration-test-log-${{ matrix.container.image }}-${{ matrix.container.version }}
path: /tmp/nginx-agent-integration-test-install-uninstall.log
retention-days: 3
if: success() || failure()
- name: Archive api integration test logs
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: integration-test-log-${{ matrix.container.image }}-${{ matrix.container.version }}
path: /tmp/nginx-agent-integration-test-api.log
retention-days: 3
if: success() || failure()
- name: Archive features integration test logs
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: features-test-log-${{ matrix.container.image }}-${{ matrix.container.version }}
name: integration-test-log-${{ matrix.container.image }}-${{ matrix.container.version }}
path: /tmp/nginx-agent-integration-test-features.log
retention-days: 3
if: success() || failure()

performance-test:
name: Performance Tests
Expand Down
5 changes: 1 addition & 4 deletions scripts/docker/agentless-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ trap 'handle_term' TERM

# Launch nginx
echo "starting nginx ..."
nginx -g "daemon off;" &
/usr/sbin/nginx -g "daemon off;" &

nginx_pid=$!

wait_term()
{
trap - TERM
kill -QUIT "${nginx_pid}" 2>/dev/null
echo "waiting for nginx to stop..."
wait ${nginx_pid}
}

Expand Down
3 changes: 0 additions & 3 deletions scripts/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ fi
wait_term()
{
wait ${agent_pid}
trap - TERM
kill -QUIT "${nginx_pid}" 2>/dev/null
echo "waiting for nginx to stop..."
wait ${nginx_pid}
}

Expand Down
26 changes: 15 additions & 11 deletions test/integration/utils/test_container_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,31 @@ func SetupTestContainerWithoutAgent(t *testing.T) *testcontainers.DockerContaine
comp, err := compose.NewDockerCompose(os.Getenv("DOCKER_COMPOSE_FILE"))
assert.NoError(t, err, "NewDockerComposeAPI()")

ctx := context.Background()

ctxCancel, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

assert.NoError(t, comp.WaitForService("agent", wait.ForHTTP("/").WithStartupTimeout(agentServiceTimeout)).WithEnv(
map[string]string{
err = comp.
WithEnv(map[string]string{
"PACKAGE_NAME": os.Getenv("PACKAGE_NAME"),
"PACKAGES_REPO": os.Getenv("PACKAGES_REPO"),
"INSTALL_FROM_REPO": os.Getenv("INSTALL_FROM_REPO"),
"BASE_IMAGE": os.Getenv("BASE_IMAGE"),
"OS_RELEASE": os.Getenv("OS_RELEASE"),
"OS_VERSION": os.Getenv("OS_VERSION"),
},
).Up(ctxCancel, compose.Wait(true)), "compose.Up()")
}).
WaitForService("agent", wait.NewLogStrategy("nginx_pid").WithOccurrence(1)).
Up(ctx, compose.Wait(true))

testContainer, err := comp.ServiceContainer(ctxCancel, "agent")
require.NoError(t, err)
assert.NoError(t, err, "compose.Up()")

testContainer, err := comp.ServiceContainer(ctx, "agent")
serviceNames := comp.Services()

assert.Equal(t, 1, len(serviceNames))
assert.Contains(t, serviceNames, "agent")

t.Cleanup(func() {
logReader, err := testContainer.Logs(ctxCancel)
logReader, err := testContainer.Logs(ctx)
assert.NoError(t, err)
defer logReader.Close()

Expand All @@ -92,7 +96,7 @@ func SetupTestContainerWithoutAgent(t *testing.T) *testcontainers.DockerContaine
err = os.WriteFile("/tmp/nginx-agent-integration-test-install-uninstall.log", testContainerLogs, 0o660)
assert.NoError(t, err)

assert.NoError(t, comp.Down(ctxCancel, compose.RemoveOrphans(true), compose.RemoveImagesLocal), "compose.Down()")
assert.NoError(t, comp.Down(ctx, compose.RemoveOrphans(true), compose.RemoveImagesLocal), "compose.Down()")
})

return testContainer
Expand Down