Skip to content

Commit 817e8b5

Browse files
authored
Clean up images during tests (#718)
* Clean up images during CI build * Change user UID in persistence tests
1 parent 56bea75 commit 817e8b5

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ jobs:
118118
run: make all
119119

120120
- name: Load Images to KinD
121-
# Load the images just built to the KinD cluster
122121
shell: bash
123122
run: |
124123
make kind-load
124+
make remove-all-images
125125
126126
- name: Unit Tests
127127
shell: bash

Makefile

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,33 @@ build-client-image: ## Build the test client image
657657
.PHONY: build-all-images
658658
build-all-images: $(BUILD_TARGETS)/build-operator build-test-images build-compatibility-image ## Build all images (including tests)
659659

660+
.PHONY: remove-all-images
661+
remove-all-images: remove-operator-image remove-test-images ## Remove the Operator image and all test images from the local Podman or Docker
662+
663+
.PHONY: remove-operator-image
664+
remove-operator-image:
665+
$(DOCKER_CMD) rmi $(OPERATOR_IMAGE) || true
666+
$(DOCKER_CMD) rmi $(OPERATOR_IMAGE_AMD) || true
667+
$(DOCKER_CMD) rmi $(OPERATOR_IMAGE_ARM) || true
668+
$(DOCKER_CMD) rmi $($(DOCKER_CMD) images -q -f "dangling=true") || true
669+
rm $(BUILD_TARGETS)/build-operator || true
670+
671+
.PHONY: remove-test-images
672+
remove-test-images:
673+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE) || true
674+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_CLIENT) || true
675+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_HELIDON) || true
676+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_HELIDON_2) || true
677+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_HELIDON_3) || true
678+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_SPRING) || true
679+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_SPRING_2) || true
680+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_SPRING_FAT) || true
681+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_SPRING_FAT_2) || true
682+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_SPRING_CNBP) || true
683+
$(DOCKER_CMD) rmi $(TEST_APPLICATION_IMAGE_SPRING_CNBP_2) || true
684+
$(DOCKER_CMD) rmi $(TEST_COMPATIBILITY_IMAGE) || true
685+
$(DOCKER_CMD) rmi $($(DOCKER_CMD) images -q -f "dangling=true") || true
686+
660687
# ----------------------------------------------------------------------------------------------------------------------
661688
# Ensure Operator SDK is at the correct version
662689
# ----------------------------------------------------------------------------------------------------------------------
@@ -1253,7 +1280,7 @@ e2e-local-test: export MVN_VERSION := $(MVN_VERSION)
12531280
e2e-local-test: export OPERATOR_IMAGE := $(OPERATOR_IMAGE)
12541281
e2e-local-test: export COHERENCE_IMAGE := $(COHERENCE_IMAGE)
12551282
e2e-local-test: export SKIP_SPRING_CNBP := $(SKIP_SPRING_CNBP)
1256-
e2e-local-test: $(BUILD_TARGETS)/build-operator undeploy reset-namespace create-ssl-secrets gotestsum install-crds ensure-pull-secret ## Run the Operator end-to-end 'local' functional tests using a local Operator instance
1283+
e2e-local-test: undeploy reset-namespace create-ssl-secrets gotestsum install-crds ensure-pull-secret ## Run the Operator end-to-end 'local' functional tests using a local Operator instance
12571284
$(GOTESTSUM) --format standard-verbose --junitfile $(TEST_LOGS_DIR)/operator-e2e-local-test.xml \
12581285
-- $(GO_TEST_FLAGS_E2E) ./test/e2e/local/...
12591286

@@ -1273,7 +1300,7 @@ e2e-test: prepare-e2e-test ## Run the Operator end-to-end 'remote' functional te
12731300
; exit $$rc
12741301

12751302
.PHONY: prepare-e2e-test
1276-
prepare-e2e-test: $(BUILD_TARGETS)/build-operator reset-namespace create-ssl-secrets deploy-and-wait
1303+
prepare-e2e-test: reset-namespace create-ssl-secrets deploy-and-wait
12771304

12781305
.PHONY: run-e2e-test
12791306
run-e2e-test: export CGO_ENABLED = 0
@@ -1364,7 +1391,7 @@ e2e-client-test: export VERSION := $(VERSION)
13641391
e2e-client-test: export MVN_VERSION := $(MVN_VERSION)
13651392
e2e-client-test: export OPERATOR_IMAGE := $(OPERATOR_IMAGE)
13661393
e2e-client-test: export COHERENCE_IMAGE := $(COHERENCE_IMAGE)
1367-
e2e-client-test: build-operator-images build-client-image reset-namespace create-ssl-secrets gotestsum undeploy ## Run the end-to-end Coherence client tests using a local Operator deployment
1394+
e2e-client-test: build-client-image reset-namespace create-ssl-secrets gotestsum undeploy ## Run the end-to-end Coherence client tests using a local Operator deployment
13681395
$(GOTESTSUM) --format standard-verbose --junitfile $(TEST_LOGS_DIR)/operator-e2e-client-test.xml \
13691396
-- $(GO_TEST_FLAGS_E2E) ./test/e2e/clients/...
13701397

@@ -1397,7 +1424,7 @@ e2e-helm-test: $(BUILD_PROPS) $(BUILD_HELM)/coherence-operator-$(VERSION).tgz re
13971424
# ----------------------------------------------------------------------------------------------------------------------
13981425
.PHONY: e2e-prometheus-test
13991426
e2e-prometheus-test: export MF = $(MAKEFLAGS)
1400-
e2e-prometheus-test: reset-namespace install-prometheus $(BUILD_TARGETS)/build-operator create-ssl-secrets deploy-and-wait ## Run the Operator metrics/Prometheus end-to-end functional tests
1427+
e2e-prometheus-test: reset-namespace install-prometheus create-ssl-secrets deploy-and-wait ## Run the Operator metrics/Prometheus end-to-end functional tests
14011428
$(MAKE) run-prometheus-test $${MF} \
14021429
; rc=$$? \
14031430
; $(MAKE) uninstall-prometheus $${MF} \

test/e2e/remote/persistence-active-snapshot-security.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ spec:
88
image: ${TEST_APPLICATION_IMAGE}
99
imagePullPolicy: ${TEST_IMAGE_PULL_POLICY}
1010
securityContext:
11-
runAsUser: 1000
12-
runAsGroup: 1000
13-
fsGroup: 1000
11+
runAsUser: 1000850001
12+
runAsGroup: 1000850001
13+
fsGroup: 1000850001
1414
fsGroupChangePolicy: "OnRootMismatch"
1515
readinessProbe:
1616
initialDelaySeconds: 10

test/e2e/remote/persistence-on-demand.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ spec:
2323
port: 30000
2424
- name: rest
2525
port: 8080
26+
volumeMounts:
27+
- name: persistence
28+
mountPath: /coherence
29+
readOnly: false
30+
volumes:
31+
- name: persistence
32+
emptyDir: {}

0 commit comments

Comments
 (0)