Skip to content

Commit

Permalink
[qe] refactor qe images to make use of deliverest base image
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <ariobolo@redhat.com>
  • Loading branch information
adrianriobo authored and praveenkumar committed Apr 22, 2024
1 parent c948c26 commit ae4e57f
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 387 deletions.
55 changes: 36 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ vendorcheck:
./verify-vendor.sh

.PHONY: check
check: cross build_e2e $(HOST_BUILD_DIR)/crc-embedder test cross-lint vendorcheck build_integration
check: cross build_e2e_all $(HOST_BUILD_DIR)/crc-embedder test cross-lint vendorcheck build_integration_all

# Start of the actual build targets

Expand Down Expand Up @@ -178,39 +178,56 @@ clean: clean_docs clean_macos_package clean_windows_msi
rm -f $(GOPATH)/bin/crc
rm -rf $(RELEASE_DIR)

.PHONY: build_e2e
## e2e building section
.PHONY: build_e2e build_e2e_all containerized_e2e

## Function to build the e2e binary params: (os, param, binary_name)
e2e_builder = GOOS=$(1) GOARCH=$(2) go test ./test/e2e/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/$(1)-$(2)/$(3)

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
$(call e2e_builder,$(GOOS),$(GOARCH),e2e.test)

.PHONY: build_integration
build_integration: $(SOURCES)
GOARCH=amd64 GOOS=linux go test ./test/integration/ -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -c -o $(BUILD_DIR)/linux-amd64/integration.test
GOARCH=amd64 GOOS=windows go test -tags "$(BUILDTAGS)" --ldflags="-X $(MODULEPATH)/pkg/crc/version.installerBuild=true $(VERSION_VARIABLES)" ./test/integration/ -c -o $(BUILD_DIR)/windows-amd64/integration.test.exe
GOARCH=amd64 GOOS=darwin go test -tags "$(BUILDTAGS)" --ldflags="-X $(MODULEPATH)/pkg/crc/version.installerBuild=true $(VERSION_VARIABLES)" ./test/integration/ -c -o $(BUILD_DIR)/macos-amd64/integration.test
GOARCH=arm64 GOOS=darwin go test -tags "$(BUILDTAGS)" --ldflags="-X $(MODULEPATH)/pkg/crc/version.installerBuild=true $(VERSION_VARIABLES)" ./test/integration/ -c -o $(BUILD_DIR)/macos-arm64/integration.test
build_e2e_all: $(SOURCES)
$(call e2e_builder,linux,amd64,e2e.test)
$(call e2e_builder,windows,amd64,e2e.test.exe)
$(call e2e_builder,darwin,amd64,e2e.test)
$(call e2e_builder,darwin,arm64,e2e.test)

# Build the container image for e2e
.PHONY: containerized_e2e
containerized_e2e:
ifndef CRC_E2E_IMG_VERSION
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} .

## integration building section
.PHONY: build_integration build_integration_all containerized_integration

## Function to build the integration binary params: (os, param, ldflags, binary_name)
integration_builder = GOOS=$(1) GOARCH=$(2) go test ./test/integration/ -tags "$(BUILDTAGS)" --ldflags="$(3)" -c -o $(BUILD_DIR)/$(1)-$(2)/$(4)

build_integration:
ILDFLAGS=$(LDFLAGS)
ifneq ($(GOOS), linux)
ILDFLAGS=$(LDFLAGS) -X $(MODULEPATH)/pkg/crc/version.installerBuild=true
endif
build_integration: $(SOURCES)
$(call integration_builder,$(GOOS),$(GOARCH),$(ILDFLAGS),integration.test)

build_integration_all: $(SOURCES)
$(call integration_builder,linux,amd64,$(LDFLAGS),integration.test)
$(call integration_builder,windows,amd64,$(LDFLAGS) -X $(MODULEPATH)/pkg/crc/version.installerBuild=true,integration.test.exe)
$(call integration_builder,darwin,amd64,$(LDFLAGS) -X $(MODULEPATH)/pkg/crc/version.installerBuild=true,integration.test)
$(call integration_builder,darwin,arm64,$(LDFLAGS) -X $(MODULEPATH)/pkg/crc/version.installerBuild=true,integration.test)

# Build the container image for integration
.PHONY: containerized_integration
containerized_integration:
containerized_integration:
ifndef CRC_INTEGRATION_IMG_VERSION
CRC_INTEGRATION_IMG_VERSION=v$(CRC_VERSION)-$(COMMIT_SHA)
endif
IMG_INTEGRATION = quay.io/crcont/crc-integration:$(CRC_INTEGRATION_IMG_VERSION)
containerized_integration: clean
$(CONTAINER_RUNTIME) build -t $(IMG_INTEGRATION) -f images/build-integration/Dockerfile .
$(CONTAINER_RUNTIME) build -t $(IMG_INTEGRATION)-${OS}-${ARCH} -f images/build-integration/Containerfile --build-arg=OS=${OS} --build-arg=ARCH=${ARCH} .

.PHONY: integration ## Run integration tests in Ginkgo
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.6

LABEL org.opencontainers.image.authors="CRCQE <devtools-crc-qe@redhat.com>"

ARG OS
ARG ARCH

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

COPY --from=builder /workspace/out/${OS}-${ARCH} ${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 against 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 path 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
```

0 comments on commit ae4e57f

Please sign in to comment.