Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ unit-verbose: ## Run unit tests with verbose output

ARTIFACTS ?= ${ROOT_DIR}/test/e2e/_artifacts

## Checking that required tools exist and running e2e script on a VM
##
## To note: Run this on your VM and not your local machine. These installations
## work for linux amd64, at least on Ubuntu 24.04. You may need to log out and
## log in to apply all changes if the installations are done for the first time.
.PHONY: run-e2e-script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not descriptive name for the target... setup-e2e or such would be nicer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the naming is a bit clunky, it's just that the "setup" would imply installations and anything more vague would imply it is used in actual e2e runs elsewhere no? Or maybe not?

run-e2e-script:
./hack/ci-e2e.sh

.PHONY: test-e2e
test-e2e: $(GINKGO) ## Run the end-to-end tests
$(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
Expand Down
8 changes: 6 additions & 2 deletions hack/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@ export E2E_BMCS_CONF_FILE="${REPO_ROOT}/test/e2e/config/bmcs-${BMC_PROTOCOL}.yam
;;
esac

sudo apt-get update
sudo apt-get install -y build-essential tar

# Ensure requirements are installed
export PATH="/usr/local/go/bin:${PATH}"
"${REPO_ROOT}/hack/e2e/ensure_go.sh"
"${REPO_ROOT}/hack/e2e/ensure_htpasswd.sh"
# CAPI test framework uses kubectl in the background
"${REPO_ROOT}/hack/e2e/ensure_kubectl.sh"
"${REPO_ROOT}/hack/e2e/ensure_yq.sh"
"${REPO_ROOT}/hack/e2e/ensure_docker.sh"

sudo apt-get update
sudo apt-get install -y libvirt-dev pkg-config
sudo apt-get install -y libvirt-daemon-system qemu-kvm virt-manager libvirt-dev
make build
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be repetition with L82, but this does some necessary steps also, just might slow down the script


# Build the container image with e2e tag (used in tests)
IMG=quay.io/metal3-io/baremetal-operator:e2e make docker
Expand Down
33 changes: 33 additions & 0 deletions hack/e2e/ensure_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to fix the shellcheck issue, this code is from the official installation instructions of installing Docker Engine on Ubuntu.


set -eux

# Check if docker is installed and install it if not.
# This is optimized to install on Ubuntu.
# The `newgrp` will stop a non-interactive script run.
verify_docker()
{
if ! [[ -x "$(command -v docker)" ]]; then
if [[ "${OSTYPE}" == "linux-gnu" ]] && [[ "$(. /etc/os-release && echo "${ID}")" == "ubuntu" ]]; then
echo "docker not found, installing"
sudo apt-get install ca-certificates
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker "${USER}"
newgrp docker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does nothing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to which part, since it works for me? The new docker group?

else
echo "Missing required binary in path: docker"
return 2
fi
fi
}

verify_docker
2 changes: 1 addition & 1 deletion hack/e2e/ensure_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ verify_go_version()
echo 'go not found, installing'
curl -sLo "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz" "https://go.dev/dl/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz"
sudo tar -C /usr/local -xzf "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz"
export PATH=/usr/local/go/bin:$PATH
export PATH="${PATH}:/usr/local/go/bin"
else
echo "Missing required binary in path: go"
return 2
Expand Down
4 changes: 2 additions & 2 deletions hack/e2e/ensure_kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ verify_kubectl_version()
if ! [ -x "$(command -v kubectl)" ]; then
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
echo "kubectl not found, installing"
curl -LO "https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
sudo install kubectl "${USR_LOCAL_BIN}/kubectl"
curl --create-dirs -LO --output-dir "${HOME}" "https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
sudo install "${HOME}/kubectl" "${USR_LOCAL_BIN}/kubectl"
else
echo "Missing required binary in path: kubectl"
return 2
Expand Down
6 changes: 3 additions & 3 deletions hack/e2e/ensure_yq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ verify_yq()
if ! [[ -x "$(command -v yq)" ]]; then
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
echo "yq not found, installing"
curl -LO "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64.tar.gz"
tar xvf yq_linux_amd64.tar.gz
sudo install yq_linux_amd64 "${USR_LOCAL_BIN}/yq"
curl --create-dirs -LO --output-dir "${HOME}" "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64.tar.gz"
sudo tar -xvf "${HOME}/yq_linux_amd64.tar.gz" -C "${HOME}"
sudo install "${HOME}/yq_linux_amd64" "${USR_LOCAL_BIN}/yq"
else
echo "Missing required binary in path: yq"
return 2
Expand Down
8 changes: 5 additions & 3 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ as BMC. Ironic runs in the "host network" of the kind cluster in the test. The
kind cluster is then configured to expose the relevant ports on the actual host
so that they can be reached from the BareMetalHost VMs.

There is a Makefile target for running this e2e script called `run-e2e-script`.

Currently there are two sets of tests, which cannot be ran together in the same
cluster. One is the "optional" set, currently consists of only the
[upgrade tests](upgrade_test.go), and the "main" set, which are the ones
Expand All @@ -25,14 +27,14 @@ setting, the script sets `GINKGO_SKIP` to `upgrade`.
E.g. Here is how to run the E2E main tests:

```bash
./hack/ci-e2e.sh
make run-e2e-script
```

And here is how to run the E2E optional tests:

```bash
export GINKGO_FOCUS="upgrade"
./hack/ci-e2e.sh
make run-e2e-script
```

`GINKGO_FOCUS` can be set manually to run specific tests. The options for these
Expand Down Expand Up @@ -67,7 +69,7 @@ Skipping tests works otherwise similiarly to adding focus, but in the Makefile
test-specific words with it or you can add another `--skip=` with a longer
string to the `test-e2e` target.

`BMC_PROTOCOL` can also be set manually. By default the [ci-e2e.sh](https://github.com/metal3-io/baremetal-operator/blob/main/hack/ci-e2e.sh)
`BMC_PROTOCOL` can also be set manually. By default the [ci-e2e.sh](../../hack/ci-e2e.sh)
script runs it as `redfish`, but it can also be set to `redfish-virtualmedia`,
`redfish`, or `ipmi`. Ipmi uses `vbmc` as the BMO e2e emulator, whereas the
others use `sushy-tools`.
Expand Down