Skip to content

Commit

Permalink
Merge pull request #2 from adrianriobo/fix-4040
Browse files Browse the repository at this point in the history
[qe] change e2e image to inherit fom deliverest
  • Loading branch information
adrianriobo authored Mar 14, 2024
2 parents fcbb3e6 + 43f18cc commit 9ab523f
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 233 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/windows-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ jobs:
- name: Build and archive e2e image
# use github.sha as ID to correlate various workflows triggered by the same event
run: |
CRC_E2E_IMG_VERSION=gh make containerized_e2e
podman save -o ${{ env.IMAGE_NAME_E2E }}.tar quay.io/crcont/${{ env.IMAGE_NAME_E2E}}:gh
CRC_E2E_IMG_VERSION=gh ARCH=amd64 OS=darwin make containerized_e2e
CRC_E2E_IMG_VERSION=gh ARCH=arm64 OS=darwin make containerized_e2e
CRC_E2E_IMG_VERSION=gh ARCH=amd64 OS=windows make containerized_e2e
CRC_E2E_IMG_VERSION=gh ARCH=amd64 OS=linux make containerized_e2e
podman save -o ${{ env.IMAGE_NAME_E2E }}.tar quay.io/crcont/${{ env.IMAGE_NAME_E2E}}:gh-windows-amd64
- name: Upload e2e image
uses: actions/upload-artifact@v4
Expand Down
34 changes: 12 additions & 22 deletions .github/workflows/windows-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,29 +139,19 @@ jobs:
# load crc-e2e image from tar file
podman load -i crc-e2e.tar
mkdir output
# id_rsa for the host should be in pwd
HOST=$(cat host)
USER=$(cat username)
# platform tag is inferred from the image
# empty runs the entire suite
E2E_TAGS=""
TARGET_FOLDER="crc-e2e"
# run e2e
podman run --rm -d --name crc-e2e \
-e PLATFORM=windows \
-e TARGET_HOST=${HOST} \
-e TARGET_HOST_USERNAME=${USER} \
-e TARGET_HOST_KEY_PATH=/opt/crc/id_rsa \
-e PULL_SECRET_FILE_PATH=/opt/crc/pull-secret \
-e E2E_TAG_EXPRESSION=${E2E_TAGS} \
-v $PWD/pull-secret:/opt/crc/pull-secret:Z \
-v $PWD/output:/output:Z \
-v $PWD/id_rsa:/opt/crc/id_rsa:Z \
quay.io/crcont/crc-e2e:gh \
-targetFolder ${TARGET_FOLDER} \
-junitResultsPath ${TARGET_FOLDER}/junit
-e TARGET_HOST==$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-e2e \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-e2e:gh-dev-windows-amd64 \
crc-e2e/run.ps1 -junitFilename crc-e2e-junit.xml
# Check logs
podman logs -f crc-e2e
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ clean: clean_docs clean_macos_package clean_windows_msi

.PHONY: build_e2e
build_e2e: $(SOURCES)
GOARCH=amd64 GOOS=linux go test ./test/e2e/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/linux-amd64/e2e.test
GOARCH=amd64 GOOS=windows go test ./test/e2e/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/windows-amd64/e2e.test.exe
GOARCH=amd64 GOOS=darwin go test ./test/e2e/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/macos-amd64/e2e.test
GOARCH=arm64 GOOS=darwin go test ./test/e2e/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/macos-arm64/e2e.test
go test ./test/e2e/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/e2e.test

.PHONY: build_integration
build_integration: $(SOURCES)
Expand All @@ -200,7 +197,7 @@ CRC_E2E_IMG_VERSION=v$(CRC_VERSION)-$(COMMIT_SHA)
endif
IMG_E2E = quay.io/crcont/crc-e2e:$(CRC_E2E_IMG_VERSION)
containerized_e2e: clean
$(CONTAINER_RUNTIME) build -t $(IMG_E2E) -f images/build-e2e/Dockerfile .
${CONTAINER_RUNTIME} build -t ${IMG_E2E}-${OS}-${ARCH} -f images/build-e2e/Containerfile --build-arg=OS=${OS} --build-arg=ARCH=${ARCH} .

# Build the container image for integration
.PHONY: containerized_integration
Expand Down
28 changes: 28 additions & 0 deletions images/build-e2e/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS builder

USER root

ARG OS
ARG ARCH
WORKDIR /workspace
COPY . .
RUN GOARCH=${ARCH} GOOS=${OS} make build_e2e

FROM quay.io/rhqp/deliverest:v0.0.5

LABEL org.opencontainers.image.authors="CRCQE <[email protected]>"

ARG OS
ARG ARCH

ENV ASSETS_FOLDER=/opt/crc \
OS=${OS} \
ARCH=${ARCH}

COPY --from=builder /workspace/out ${ASSETS_FOLDER}/bin
COPY --from=builder /workspace/test/e2e/features ${ASSETS_FOLDER}/bin/features
COPY --from=builder /workspace/test/testdata ${ASSETS_FOLDER}/testdata

COPY images/build-e2e/lib/${OS}/* ${ASSETS_FOLDER}/

24 changes: 0 additions & 24 deletions images/build-e2e/Dockerfile

This file was deleted.

119 changes: 78 additions & 41 deletions images/build-e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,87 @@
# Overview

The container includes the e2e binary for all 3 platforms plus the required resources to run it.
This image contains the e2e suite of tests, and it is intended to run them agaisnt a target host, the logic to run the tests remotely is inherit from its base image: [deliverest](https://github.com/adrianriobo/deliverest), each platform and os has its own image.

The container connects through ssh to the target host and copy the right binary for the platform, run e2e tests and pick the results and logs back.
## Run

## Envs
The image version contains the specs about the plaftorm and the arch; then the test customization is made by the command executed within the image; as we can see the cmd should be defined depending on the platform:

**PLATFORM**:*define target platform (windows, macos, linux).*
**ARCH**:*define target arch (amd64, arm64). Default amd64
**TARGET_HOST**:*dns or ip for the target host.*
**TARGET_HOST_USERNAME**:*username for target host.*
**TARGET_HOST_KEY_PATH**:*private key for user. (Mandatory if not TARGET_HOST_PASSWORD).*
**TARGET_HOST_PASSWORD**:*password for user. (Mandatory if not TARGET_HOST_KEY_PATH).*
**PULL_SECRET_FILE_PATH**: *pull secret file path (local to container).*
**BUNDLE_VERSION**:*(Mandatory if not BUNDLE_LOCATION). Testing agaisnt crc released version bundle version for crc released version.*
**BUNDLE_LOCATION**:*(Mandatory if not BUNDLE_VERSION). When testing crc with custom bundle set the bundle location on target server.*
**RESULTS_PATH**:*(Optional). Path inside container to pick results and logs from e2e execution.*
**RESULTS_FILE**:*(Optional). File name for results xunit results. Default value: e2e.*
**CLEANUP_HOME**:*(Optional). Cleanup crc home folder or keep as it is to run test.*
**E2E_TAG_EXPRESSION**:*(Optional). Define e2e tag expression to select tests. If empty all tests available for the platform will be executed.*
* crc-e2e/run.ps1 ... (windows)
* crc-e2e/run.sh ... (linux/darwin)

## Samples
And the execution is customized by the params addded, available params:

* bundleLocation When testing a custom bundle we should pass the paht on the target host
* e2eTagExpression To set an specific set of tests based on annotations
* targetFolder Name of the folder on the target host under $HOME where all the content will be copied
* junitFilename Name for the junit file with the tests results
* crcMemory Customize memory for the cluster to run the tests

### Windows amd64

```bash
podman run --rm -d --name crc-e2e-windows \
-e TARGET_HOST=XXXX \
-e TARGET_HOST_USERNAME=XXXX \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-e2e \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-e2e:v2.34.0-windows-amd64 \
crc-e2e/run.ps1 -junitFilename crc-e2e-junit.xml
```

### Mac arm64

```bash
podman run --rm -d --name crc-e2e-darwin \
-e TARGET_HOST=XXXX \
-e TARGET_HOST_USERNAME=XXXX \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-e2e \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-e2e:v2.34.0-darwin-arm64 \
crc-e2e/run.sh --junitFilename crc-e2e-junit.xml
```

### Mac amd64

```bash
# Run e2e on macos platform with ssh key and custom bundle
podman run --rm -it --name crc-e2e \
-e PLATFORM=macos \
-e TARGET_HOST=$IP \
-e TARGET_HOST_USERNAME=$USER \
-e TARGET_HOST_KEY_PATH=/opt/crc/id_rsa \
-e PULL_SECRET_FILE_PATH=/opt/crc/pull-secret \
-e BUNDLE_LOCATION=/bundles/crc_hyperv_4.8.0-rc.3.crcbundle \
-v $PWD/pull-secret:/opt/crc/pull-secret:Z \
-v $PWD/id_rsa:/opt/crc/id_rsa:Z \
-v $PWD/output:/output:Z \
quay.io/crcont/crc-e2e:v1.29.0-465452f4

# Run e2e on windows platform with ssh password and crc released version
podman run --rm -it --name crc-e2e \
-e PLATFORM=windows \
-e TARGET_HOST=$IP \
-e TARGET_HOST_USERNAME=$USER \
-e TARGET_HOST_PASSWORD=$PASSWORD \
-e PULL_SECRET_FILE_PATH=/opt/crc/pull-secret \
-e BUNDLE_VERSION=4.7.18 \
-v $PWD/pull-secret:/opt/crc/pull-secret:Z \
-v $PWD/output:/output:Z \
quay.io/crcont/crc-e2e:v1.29.0-465452f4
podman run --rm -d --name crc-e2e-darwin \
-e TARGET_HOST=XXXX \
-e TARGET_HOST_USERNAME=XXXX \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-e2e \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-e2e:v2.34.0-darwin-amd64 \
crc-e2e/run.sh --junitFilename crc-e2e-junit.xml
```


### Linux amd64

```bash
podman run --rm -d --name crc-e2e-linux \
-e TARGET_HOST=XXXX \
-e TARGET_HOST_USERNAME=XXXX \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-e2e \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-e2e:v2.34.0-linux-amd64 \
crc-e2e/run.sh --junitFilename crc-e2e-junit.xml
```
Loading

0 comments on commit 9ab523f

Please sign in to comment.