Skip to content

Commit fea8260

Browse files
authored
update/integration-tests (#267)
* refactor: update Docker images and improve test cases for Pumba commands * Add comprehensive test coverage and documentation for nettools images This commit includes several improvements: 1. Enhanced test coverage: - Added tests for combined netem and iptables usage - Added tests for extended netem features (duplicate, corrupt, etc.) - Added tests for global parameters and error handling - Added testing documentation for future contributors 2. Improved documentation: - Added examples of using combined nettools images - Created advanced network chaos documentation - Added diagram illustrating nettools architecture - Added examples for complex network degradation scenarios 3. Made tests more robust and environment-agnostic to ensure they run reliably across different systems and configurations * Fix integration tests to work in CI environment * Fix unit tests for tcContainerCommands to reflect entrypoint changes * update static version
1 parent a1591c2 commit fea8260

37 files changed

+2736
-294
lines changed
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Push Network Tools Images
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
paths:
9+
- 'docker/alpine-nettools.Dockerfile'
10+
- 'docker/debian-nettools.Dockerfile'
11+
- '.github/workflows/nettools-images.yaml'
12+
pull_request:
13+
paths:
14+
- 'docker/alpine-nettools.Dockerfile'
15+
- 'docker/debian-nettools.Dockerfile'
16+
- '.github/workflows/nettools-images.yaml'
17+
workflow_dispatch:
18+
19+
jobs:
20+
build-and-push:
21+
name: Build and Push Multi-Arch Images
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
image:
26+
- name: alpine-nettools
27+
file: docker/alpine-nettools.Dockerfile
28+
base: alpine
29+
- name: debian-nettools
30+
file: docker/debian-nettools.Dockerfile
31+
base: debian
32+
permissions:
33+
contents: read
34+
packages: write
35+
36+
steps:
37+
- name: Checkout Code
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v3
44+
with:
45+
platforms: linux/amd64,linux/arm64
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
with:
50+
driver: docker-container
51+
platforms: linux/amd64,linux/arm64
52+
53+
- name: Login to GitHub Container Registry
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Extract metadata for Docker
61+
id: meta
62+
uses: docker/metadata-action@v5
63+
with:
64+
images: ghcr.io/${{ github.repository }}/pumba-${{ matrix.image.name }}
65+
tags: |
66+
type=semver,pattern={{version}}
67+
type=raw,value=latest
68+
type=raw,value=${{ matrix.image.base }}
69+
type=sha,format=short
70+
71+
- name: Build and Push Docker Image
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
file: ${{ matrix.image.file }}
76+
platforms: linux/amd64,linux/arm64
77+
push: ${{ github.event_name != 'pull_request' }}
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
provenance: true
83+
sbom: true

Makefile

+54-2
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,17 @@ test-coverage: setup-go-junit-report setup-gocov setup-gocov-xml; $(info $(M) ru
112112
$Q $(GO) tool cover -func="$(COVERAGE_PROFILE)"
113113
$Q $(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML)
114114

115-
# urun integration tests
115+
# run integration tests
116116
.PHONY: integration-tests
117117
integration-tests: build ; $(info $(M) running integration tests with bats...) @ ## Run bats tests
118118
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) pumba --version
119-
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(BATS) tests
119+
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(SHELL) tests/run_tests.sh
120+
121+
# run all integration tests including stress tests
122+
.PHONY: integration-tests-all
123+
integration-tests-all: build ; $(info $(M) running all integration tests with bats...) @ ## Run all bats tests including stress tests
124+
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) pumba --version
125+
$Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(SHELL) tests/run_tests.sh --all
120126

121127
.PHONY: lint
122128
lint: setup-lint; $(info $(M) running golangci-lint...) @ ## Run golangci-lint
@@ -157,6 +163,52 @@ debug:
157163
@echo $(BIN)/$(basename $(MODULE))
158164
@echo $(TARGETOS)/$(TARGETARCH)
159165

166+
# NetTools Docker images
167+
NETTOOLS_REPO := ghcr.io/alexei-led/pumba
168+
NETTOOLS_PLATFORMS := linux/amd64,linux/arm64
169+
170+
.PHONY: build-nettools-images
171+
build-nettools-images: ; $(info $(M) building multi-arch nettools images...) @ ## Build multi-arch nettools images
172+
$Q $(DOCKER) buildx create --use --name nettools-builder --driver docker-container --bootstrap || true
173+
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
174+
-t $(NETTOOLS_REPO)/pumba-alpine-nettools:latest \
175+
-f $(CURDIR)/docker/alpine-nettools.Dockerfile \
176+
$(CURDIR)
177+
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
178+
-t $(NETTOOLS_REPO)/pumba-debian-nettools:latest \
179+
-f $(CURDIR)/docker/debian-nettools.Dockerfile \
180+
$(CURDIR)
181+
$Q $(DOCKER) buildx rm nettools-builder
182+
183+
.PHONY: build-local-nettools
184+
build-local-nettools: ; $(info $(M) building local nettools images for local architecture...) @ ## Build local nettools images
185+
$Q $(DOCKER) build \
186+
-t pumba-alpine-nettools:local \
187+
-f $(CURDIR)/docker/alpine-nettools.Dockerfile \
188+
$(CURDIR)
189+
$Q $(DOCKER) build \
190+
-t pumba-debian-nettools:local \
191+
-f $(CURDIR)/docker/debian-nettools.Dockerfile \
192+
$(CURDIR)
193+
194+
.PHONY: push-nettools-images
195+
push-nettools-images: ; $(info $(M) building and pushing multi-arch nettools images...) @ ## Build and push multi-arch nettools images
196+
@echo "Using repository: $(NETTOOLS_REPO)"
197+
@echo "Checking if already logged in to ghcr.io..."
198+
@$(DOCKER) buildx ls >/dev/null
199+
$Q $(DOCKER) buildx create --use --name nettools-builder --driver docker-container --bootstrap || true
200+
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
201+
-t $(NETTOOLS_REPO)/pumba-alpine-nettools:latest \
202+
--push \
203+
-f $(CURDIR)/docker/alpine-nettools.Dockerfile \
204+
$(CURDIR)
205+
$Q $(DOCKER) buildx build --platform $(NETTOOLS_PLATFORMS) \
206+
-t $(NETTOOLS_REPO)/pumba-debian-nettools:latest \
207+
--push \
208+
-f $(CURDIR)/docker/debian-nettools.Dockerfile \
209+
$(CURDIR)
210+
$Q $(DOCKER) buildx rm nettools-builder
211+
160212
# helper function: find module path
161213
define source_of
162214
$(shell go mod download -json | jq -r 'select(.Path == "$(1)").Dir' | tr '\\' '/' 2> /dev/null)

0 commit comments

Comments
 (0)