Skip to content

Commit fe55660

Browse files
committed
Fix hack/ci-e2e.sh script installations
Edit Makefile to add run-e2e-script, fix installations, and add documentation. Signed-off-by: Siiri Kemppainen <[email protected]>
1 parent afd8f3c commit fe55660

File tree

7 files changed

+58
-10
lines changed

7 files changed

+58
-10
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ unit-verbose: ## Run unit tests with verbose output
120120

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

123+
## Checking that required tools exist and running e2e script on a VM
124+
##
125+
## To note: Run this on your VM and not your local machine. These installations
126+
## work for linux amd64, at least on Ubuntu 24.04. You may need to log out and
127+
## log in to apply all changes if the installations are done for the first time.
128+
.PHONY: run-e2e-script
129+
run-e2e-script:
130+
./hack/ci-e2e.sh
131+
123132
.PHONY: test-e2e
124133
test-e2e: $(GINKGO) ## Run the end-to-end tests
125134
$(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \

hack/ci-e2e.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,20 @@ export E2E_BMCS_CONF_FILE="${REPO_ROOT}/test/e2e/config/bmcs-${BMC_PROTOCOL}.yam
4545
;;
4646
esac
4747

48+
sudo apt-get install -y build-essential tar
49+
4850
# Ensure requirements are installed
4951
export PATH="/usr/local/go/bin:${PATH}"
5052
"${REPO_ROOT}/hack/e2e/ensure_go.sh"
5153
"${REPO_ROOT}/hack/e2e/ensure_htpasswd.sh"
5254
# CAPI test framework uses kubectl in the background
5355
"${REPO_ROOT}/hack/e2e/ensure_kubectl.sh"
5456
"${REPO_ROOT}/hack/e2e/ensure_yq.sh"
57+
"${REPO_ROOT}/hack/e2e/ensure_docker.sh"
5558

5659
sudo apt-get update
57-
sudo apt-get install -y libvirt-dev pkg-config
60+
sudo apt-get install -y libvirt-daemon-system qemu-kvm virt-manager libvirt-dev
61+
make build
5862

5963
# Build the container image with e2e tag (used in tests)
6064
IMG=quay.io/metal3-io/baremetal-operator:e2e make docker

hack/e2e/ensure_docker.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC1091
3+
4+
set -eux
5+
6+
# Check if docker is installed and install it if not.
7+
# This is optimized to install on Ubuntu.
8+
# The `newgrp` will stop a non-interactive script run.
9+
verify_docker()
10+
{
11+
if ! [ -x "$(command -v docker)" ]; then
12+
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
13+
echo "docker not found, installing"
14+
sudo apt-get install ca-certificates
15+
sudo install -m 0755 -d /etc/apt/keyrings
16+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
17+
sudo chmod a+r /etc/apt/keyrings/docker.asc
18+
echo \
19+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
20+
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
21+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
22+
sudo apt-get update
23+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
24+
sudo usermod -aG docker "${USER}"
25+
newgrp docker
26+
else
27+
echo "Missing required binary in path: docker"
28+
return 2
29+
fi
30+
fi
31+
}
32+
33+
verify_docker

hack/e2e/ensure_go.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ verify_go_version()
1313
echo 'go not found, installing'
1414
curl -sLo "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz" "https://go.dev/dl/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz"
1515
sudo tar -C /usr/local -xzf "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz"
16-
export PATH=/usr/local/go/bin:$PATH
16+
export PATH="${PATH}:/usr/local/go/bin"
1717
else
1818
echo "Missing required binary in path: go"
1919
return 2

hack/e2e/ensure_kubectl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ verify_kubectl_version()
2626
if ! [ -x "$(command -v kubectl)" ]; then
2727
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
2828
echo "kubectl not found, installing"
29-
curl -LO "https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
30-
sudo install kubectl "${USR_LOCAL_BIN}/kubectl"
29+
curl --create-dirs -LO --output-dir "${HOME}" "https://dl.k8s.io/release/${MINIMUM_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
30+
sudo install "${HOME}/kubectl" "${USR_LOCAL_BIN}/kubectl"
3131
else
3232
echo "Missing required binary in path: kubectl"
3333
return 2

hack/e2e/ensure_yq.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ verify_yq()
1111
if ! [[ -x "$(command -v yq)" ]]; then
1212
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
1313
echo "yq not found, installing"
14-
curl -LO "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64.tar.gz"
15-
tar xvf yq_linux_amd64.tar.gz
16-
sudo install yq_linux_amd64 "${USR_LOCAL_BIN}/yq"
14+
curl --create-dirs -LO --output-dir "${HOME}" "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64.tar.gz"
15+
sudo tar -xvf "${HOME}/yq_linux_amd64.tar.gz" -C "${HOME}"
16+
sudo install "${HOME}/yq_linux_amd64" "${USR_LOCAL_BIN}/yq"
1717
else
1818
echo "Missing required binary in path: yq"
1919
return 2

test/e2e/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ as BMC. Ironic runs in the "host network" of the kind cluster in the test. The
1515
kind cluster is then configured to expose the relevant ports on the actual host
1616
so that they can be reached from the BareMetalHost VMs.
1717

18+
There is a Makefile target for running this e2e script called `run-e2e-script`.
19+
1820
Currently there are two sets of tests, which cannot be ran together in the same
1921
cluster. One is the "optional" set, currently consists of only the
2022
[upgrade tests](upgrade_test.go), and the "main" set, which are the ones
@@ -25,14 +27,14 @@ setting, the script sets `GINKGO_SKIP` to `upgrade`.
2527
E.g. Here is how to run the E2E main tests:
2628

2729
```bash
28-
./hack/ci-e2e.sh
30+
make run-e2e-script
2931
```
3032

3133
And here is how to run the E2E optional tests:
3234

3335
```bash
3436
export GINKGO_FOCUS="upgrade"
35-
./hack/ci-e2e.sh
37+
make run-e2e-script
3638
```
3739

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

70-
`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)
72+
`BMC_PROTOCOL` can also be set manually. By default the [ci-e2e.sh](../../hack/ci-e2e.sh)
7173
script runs it as `redfish`, but it can also be set to `redfish-virtualmedia`,
7274
`redfish`, or `ipmi`. Ipmi uses `vbmc` as the BMO e2e emulator, whereas the
7375
others use `sushy-tools`.

0 commit comments

Comments
 (0)