-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and run functional tests all locally
The `jenkins/runlocal` script now builds a Pbench Server RPM from the checked-out sources in the current working tree, builds the Pbench Server CI container, and runs the functional tests against the CI container image. As a result, `jenkins/runlocal` no longer pushes images to a registry. It was necessary to support alternate base images for server container to allow for fully local builds. Prior to this change, if one tried to use `jenkins/runlocal` without setting `BASE_IMAGE`, the default of `UBI:9` would result in an error if the system on which this script was invoked did not have a RHEL entitlement. This change simplifies things so that the RPM built is truly local to the environment, and using the installed environment, derives the `BASE_IMAGE` is to work with the built RPM. For example, if running on a Fedora 37 box, a Fedora 37 RPM would be built and installed using the `fedora:37` base image. NOTE, we only support defaulting to a `ubi9:latest` or `centos:stream9` image in those respective environments. We now only perform "hard" cleanup on INT, QUIT, and TERM signals. If a functional test is successful, and `--cleanup` has been requested, we will have already removed the POD and container. There is no need to also run the "hard" cleanup script. Further, we emit a note when `--cleanup` is not requested after the functional tests have finished to alert the user that the POD and container are still running. We also emit the print statements for the clean up being performed. All arguments to `jenkins/runlocal` are passed along to `jenkins/run-server-unit-tests` as a simple way to support the `--cleanup` option on `jenkins/runlocal`. We also: * Fail running server functional tests if pod creation fails * Remove the need for the `jenkins/runner` * Remove the unnecessary use of `--format=docker` in the `buildah from` command * Drop specific linting references, add `isort` in `README.md` * Use local file to keep CI container image name This allows us to entirely remove all references to a specific container registry from the code so that developers can create a local file in which to store the registry want to use in parallel with what the CI jobs already do with Jenkins credentials. * Correct a comment in `jenkins/Pipeline.gy` * Correct `GITTOP` definition location * Use `/bin/bash -e` consistently, adding it to `run-pbench-in-a-can`
- Loading branch information
Showing
16 changed files
with
163 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,52 @@ | ||
#!/bin/bash -e | ||
|
||
# Build the RPM and then build the containers, pushing only the CI image | ||
# to the registry, and then run the fuctional tests against the built | ||
# container image. | ||
# Build the Pbench Server RPM and container, and run functional tests locally. | ||
# Requires a Fedora, CentOS, or RHEL environment to run. | ||
|
||
export PB_CONTAINER_REG=images.paas.redhat.com | ||
export PB_ORG_NAME=pbench | ||
# NOTE WELL: By default, when the functional tests are run, the infrastructure | ||
# pod and Pbench Server container are left running by default. Add the switch, | ||
# `--cleanup` to direct `jenkins/run-server-func-tests` to cleanup when | ||
# finished (success or failure). | ||
|
||
# Build the pbench-server RPM locally, then build the containers locally, and | ||
# then run the functional tests against the locally built CI container image. | ||
export PB_SERVER_IMAGE_NAME=pbench-server | ||
|
||
# We use the current user name as the tag to avoid any conflict with what the CI | ||
# environment does. | ||
export PB_SERVER_IMAGE_TAG=${USER} | ||
export PB_DASHBOARD_DIR=$(pwd)/dashboard/build | ||
|
||
# We use the image pull policy of `never` here to ensure our locally built image | ||
# is used by the pod. | ||
export PB_SERVER_IMAGE_PULL_POLICY=never | ||
|
||
# Create an RPM from the current source tree and double check it exists. | ||
make -C server/rpm clean rpm | ||
export RPM_PATH=${HOME}/rpmbuild/RPMS/noarch/pbench-server-*.rpm | ||
ls -ld ${RPM_PATH} | ||
|
||
source /etc/os-release | ||
|
||
if [[ -z ${BASE_IMAGE} ]]; then | ||
major=${VERSION_ID%%.*} | ||
if [[ ${ID} == "fedora" ]]; then | ||
# Any Fedora is okay. | ||
BASE_IMAGE=${ID}:${major} | ||
elif [[ ${ID} == "centos" && "${major}" == "9" ]]; then | ||
# Only CentOS 9 is supported | ||
BASE_IMAGE=${ID}:stream${major} | ||
elif [[ ${ID} == "rhel" && "" == "9" ]]; then | ||
# Only RHEL 9 is supported | ||
BASE_IMAGE=ubi${major}:latest | ||
else | ||
echo "Unsupported local OS, ${ID}:${VERSION_ID}" >&2 | ||
exit 1 | ||
fi | ||
export BASE_IMAGE | ||
fi | ||
|
||
# Build the canned Pbench Server container from the RPM built above. | ||
server/pbenchinacan/container-build.sh | ||
|
||
# Typically, one logs in to a container registery with automated scripts using | ||
# an "application" token. When using quay.io based container registries, the | ||
# application token uses the user name `$app` and the token is provided as the | ||
# password. | ||
# | ||
# For example, if you generate a token and set the value to the environment | ||
# variable named, __LOGIN_SECRET__, then the `buildah login` command below | ||
# demonstrates how to login with that token. | ||
# | ||
# $ buildah login -u='$app' -p="${__LOGIN_SECRET__}" ${PB_CONTAINER_REG} | ||
|
||
RPM_PATH=${HOME}/rpmbuild/RPMS/noarch/pbench-server-*.rpm bash -ex ./server/pbenchinacan/container-build.sh | ||
buildah push localhost/${PB_SERVER_IMAGE_NAME}:${PB_SERVER_IMAGE_TAG} ${PB_CONTAINER_REG}/${PB_ORG_NAME}/${PB_SERVER_IMAGE_NAME}:${PB_SERVER_IMAGE_TAG} | ||
|
||
jenkins/run-server-func-tests | ||
# Run the functional tests using the locally built image. | ||
jenkins/run-server-func-tests "${@}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.