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

Add Makefile target to cleanup testing artifacts #1205

Merged
merged 1 commit into from
May 13, 2024

Conversation

sondavidb
Copy link
Contributor

Issue #, if available:
Fixes #1204

Description of changes:
Our integration testing suite can leave artifacts if it is prematurely quit. When run multiple times, this can lead to many artifacts left over, taking up unnecessary disk space, CPU usage, and Docker networks. This change uses a common base container name for all of our testing containers, and allows

As a compliment to this, I noticed that our Dockerfile, when manually built, would result in an improperly-tagged image. The first commit just moves the registry pull to its own line so that it can be properly tagged when built manually. Not necessary at all, and can remove from this commit if needed, I just thought it would be nice to have :p

Testing performed:
Ran a test (e.g. GO_TEST_FLAGS='-run TestNetworkRetry -count 1' make integration), cancelled it after it started running, and checked that appropriate artifacts were cleaned.

Testing workflow (redacted/truncated data denoted with "..."
$ docker image ls
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
$ docker container ls -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
49af465ba355   bridge    bridge    local
d8e5c2fe03b4   host      host      local
c02d09057b67   none      null      local
$ GO_TEST_FLAGS='-run TestNetworkRetry -count 1' make integration
...
=== RUN   TestNetworkRetry
=== RUN   TestNetworkRetry/No_network_interruption,_no_retries_allowed,_success
 Network soci-integration-compose-com2t3qbv6590n89blfg2509610158_default  Creating
 Network soci-integration-compose-com2t3qbv6590n89blfg2509610158_default  Created
 Container soci-integration-registry-com2t3qbv6590n89blf0.test  Creating
 Container soci-integration-compose-com2t3qbv6590n89blfg2509610158-testing-1  Creating
 Container soci-integration-registry-com2t3qbv6590n89blf0.test  Created
 Container soci-integration-compose-com2t3qbv6590n89blfg2509610158-testing-1  Created
 Container soci-integration-compose-com2t3qbv6590n89blfg2509610158-testing-1  Starting
 Container soci-integration-registry-com2t3qbv6590n89blf0.test  Starting
 Container soci-integration-compose-com2t3qbv6590n89blfg2509610158-testing-1  Started
 Container soci-integration-registry-com2t3qbv6590n89blf0.test  Started
    shell.go:88: 
...
^C
$ docker image ls
REPOSITORY      TAG         IMAGE ID       CREATED              SIZE
soci_base       soci_test   8a88120b4906   About a minute ago   2.24GB
registry        soci_test   669bda21b705   5 weeks ago          42.4MB
moby/buildkit   v0.10.3     a2c9241854f2   24 months ago        142MB
$ docker container ls -a 
CONTAINER ID   IMAGE                   COMMAND                  CREATED              STATUS              PORTS      NAMES
7d5840fcc5a0   soci_base:soci_test     "/integ_entrypoint.sh"   26 seconds ago       Up 12 seconds                  soci-integration-compose-com2t3qbv6590n89blfg2509610158-testing-1
b9359c852269   registry:soci_test      "/entrypoint.sh /etc…"   26 seconds ago       Up 12 seconds       5000/tcp   soci-integration-registry-com2t3qbv6590n89blf0.test
a8615d779eee   moby/buildkit:v0.10.3   "buildkitd"              About a minute ago   Up About a minute              buildx_buildkit_zstd-builder0
$ docker network ls 
NETWORK ID     NAME                                                              DRIVER    SCOPE
49af465ba355   bridge                                                            bridge    local
d8e5c2fe03b4   host                                                              host      local
c02d09057b67   none                                                              null      local
c49fc82e900b   soci-integration-compose-com2t3qbv6590n89blfg2509610158_default   bridge    local
$ make clean-integration
🧹 Cleaning leftover integration test artifacts...
🐳 Cleaning Docker artifacts...
docker stop 7d5840fcc5a0 b9359c852269
7d5840fcc5a0
b9359c852269
docker rm 7d5840fcc5a0 b9359c852269
7d5840fcc5a0
b9359c852269
docker network rm c49fc82e900b
c49fc82e900b
docker image rm 8a88120b4906 669bda21b705
Untagged: soci_base:soci_test
Deleted:
...
Untagged: registry:soci_test
Deleted: 
...
🐳 All SOCI containers, networks, and images cleaned!
All testing artifacts cleaned!
$ docker image ls 
REPOSITORY      TAG       IMAGE ID       CREATED         SIZE
moby/buildkit   v0.10.3   a2c9241854f2   24 months ago   142MB
$ docker container ls 
CONTAINER ID   IMAGE                   COMMAND       CREATED              STATUS              PORTS     NAMES
a8615d779eee   moby/buildkit:v0.10.3   "buildkitd"   About a minute ago   Up About a minute             buildx_buildkit_zstd-builder0
$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
49af465ba355   bridge    bridge    local
d8e5c2fe03b4   host      host      local
c02d09057b67   none      null      local

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sondavidb sondavidb requested a review from a team as a code owner April 26, 2024 23:02
Makefile Show resolved Hide resolved
@sondavidb sondavidb force-pushed the cleanup-testing-artifacts branch 2 times, most recently from 5ff7f8e to 07fce29 Compare May 6, 2024 19:21
Kern--
Kern-- previously approved these changes May 10, 2024
austinvazquez
austinvazquez previously approved these changes May 13, 2024
Kern--
Kern-- previously approved these changes May 13, 2024
@sondavidb sondavidb dismissed stale reviews from Kern-- and austinvazquez via 18b920e May 13, 2024 17:01
@sondavidb sondavidb force-pushed the cleanup-testing-artifacts branch from 516e0d8 to 18b920e Compare May 13, 2024 17:01
@sondavidb
Copy link
Contributor Author

Merge conflict, had to rebase

@sondavidb sondavidb merged commit 1142aec into awslabs:main May 13, 2024
12 checks passed
@sondavidb sondavidb deleted the cleanup-testing-artifacts branch May 13, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Clean up integration test artifacts
3 participants