@@ -33,7 +33,7 @@ echo "BMO_E2E_EMULATOR=${BMO_E2E_EMULATOR}"
3333export E2E_CONF_FILE=" ${REPO_ROOT} /test/e2e/config/ironic.yaml"
3434export E2E_BMCS_CONF_FILE=" ${REPO_ROOT} /test/e2e/config/bmcs-${BMC_PROTOCOL} .yaml"
3535
36- case " ${GINKGO_FOCUS,,} " in
36+ case " ${GINKGO_FOCUS,,} " in
3737 * upgrade* )
3838 export DEPLOY_IRONIC=" false"
3939 export DEPLOY_BMO=" false"
@@ -59,29 +59,57 @@ sudo apt-get install -y libvirt-dev pkg-config
5959# Build the container image with e2e tag (used in tests)
6060IMG=quay.io/metal3-io/baremetal-operator:e2e make docker
6161
62- virsh -c qemu:///system net-define " ${REPO_ROOT} /hack/e2e/net.xml"
63- virsh -c qemu:///system net-start baremetal-e2e
62+ if ! sudo virsh net-list --all | grep baremetal-e2e; then
63+ virsh -c qemu:///system net-define " ${REPO_ROOT} /hack/e2e/net.xml"
64+ virsh -c qemu:///system net-start baremetal-e2e
65+ fi
66+
67+ # We need to create veth pair to connect metal3 net (defined above) and kind
68+ # docker subnet. Let us start by creating a docker network with pre-defined
69+ # name for bridge, so that we can configure the veth pair correctly.
70+ # Also assume that if kind net exists, it is created by us.
71+ if ! docker network list | grep kind; then
72+ # These options are used by kind itself. It uses docker default mtu and
73+ # generates ipv6 subnet ULA, but we can fix the ULA. Only addition to kind
74+ # options is the network bridge name.
75+ docker network create -d=bridge \
76+ -o com.docker.network.bridge.enable_ip_masquerade=true \
77+ -o com.docker.network.driver.mtu=1500 \
78+ -o com.docker.network.bridge.name=" kind-bridge" \
79+ --ipv6 --subnet " fc00:f853:ccd:e793::/64" \
80+ kind
81+ fi
82+ docker network list
83+
84+ # Next create the veth pair
85+ if ! ip a | grep metalend; then
86+ sudo ip link add metalend type veth peer name kindend
87+ sudo ip link set metalend master metal3
88+ sudo ip link set kindend master kind-bridge
89+ sudo ip link set metalend up
90+ sudo ip link set kindend up
91+ fi
92+ ip a
6493
65- # Allow traffic between docker bridges and the metal3 interface
66- sudo iptables -I FORWARD -i br-+ -o metal3 -j ACCEPT
67- sudo iptables -I FORWARD -i metal3 -o br-+ -j ACCEPT
94+ # Then we need to set routing rules as well
95+ if ! sudo iptables -L FORWARD -v -n | grep kind-bridge; then
96+ sudo iptables -I FORWARD -i kind-bridge -o metal3 -j ACCEPT
97+ sudo iptables -I FORWARD -i metal3 -o kind-bridge -j ACCEPT
98+ fi
6899sudo iptables -L FORWARD -n -v
69100
70- # This IP is defined by the network we created above.
101+ # This IP is defined by the network we created above. It is sushy-tools / image
102+ # server endpoint, not ironic.
71103IP_ADDRESS=" 192.168.222.1"
72104
73- # This IP is also defined by the network above, and is used consistently in all of
74- # our e2e overlays
75- export IRONIC_PROVISIONING_IP=" ${IP_ADDRESS} "
76-
77105# Build vbmctl
78106make build-vbmctl
79107# Create VMs to act as BMHs in the tests.
80108./bin/vbmctl --yaml-source-file " ${E2E_BMCS_CONF_FILE} "
81109
82110if [[ " ${BMO_E2E_EMULATOR} " == " vbmc" ]]; then
83111 # Start VBMC
84- docker run --name vbmc --network host -d \
112+ docker start vbmc || docker run --name vbmc --network host -d \
85113 -v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
86114 -v /var/run/libvirt/libvirt-sock-ro:/var/run/libvirt/libvirt-sock-ro \
87115 quay.io/metal3-io/vbmc
@@ -98,7 +126,7 @@ elif [[ "${BMO_E2E_EMULATOR}" == "sushy-tools" ]]; then
98126 # Sushy-tools variables
99127 SUSHY_EMULATOR_FILE=" ${REPO_ROOT} " /test/e2e/sushy-tools/sushy-emulator.conf
100128 # Start sushy-tools
101- docker run --name sushy-tools -d --network host \
129+ docker start sushy-tools || docker run --name sushy-tools -d --network host \
102130 -v " ${SUSHY_EMULATOR_FILE} " :/etc/sushy/sushy-emulator.conf:Z \
103131 -v /var/run/libvirt:/var/run/libvirt:Z \
104132 -e SUSHY_EMULATOR_CONFIG=/etc/sushy/sushy-emulator.conf \
@@ -118,29 +146,33 @@ IMAGE_DIR="${REPO_ROOT}/test/e2e/images"
118146mkdir -p " ${IMAGE_DIR} "
119147
120148# # Download disk images
121- wget --quiet -P " ${IMAGE_DIR} /" https://artifactory.nordix.org/artifactory/metal3/images/iso/" ${IMAGE_FILE} "
122- wget --quiet -P " ${IMAGE_DIR} /" https://artifactory.nordix.org/artifactory/metal3/images/sysrescue/systemrescue-11.00-amd64.iso
149+ if [[ ! -f " ${IMAGE_DIR} /${IMAGE_FILE} " ]]; then
150+ wget --quiet -P " ${IMAGE_DIR} /" https://artifactory.nordix.org/artifactory/metal3/images/iso/" ${IMAGE_FILE} "
151+ wget --quiet -P " ${IMAGE_DIR} /" https://artifactory.nordix.org/artifactory/metal3/images/sysrescue/systemrescue-11.00-amd64.iso
152+ fi
123153
124154# # Start the image server
125- docker run --name image-server-e2e -d \
155+ docker start image-server-e2e || docker run --name image-server-e2e -d \
126156 -p 80:8080 \
127157 -v " ${IMAGE_DIR} :/usr/share/nginx/html" nginxinc/nginx-unprivileged
128158
129159# Generate ssh key pair for verifying provisioned BMHs
130- ssh-keygen -t ed25519 -f " ${IMAGE_DIR} /ssh_testkey" -q -N " "
160+ if [[ ! -f " ${IMAGE_DIR} /ssh_testkey" ]]; then
161+ ssh-keygen -t ed25519 -f " ${IMAGE_DIR} /ssh_testkey" -q -N " "
162+ fi
163+ pub_ssh_key=$( cut -d " " -f " 1,2" " ${IMAGE_DIR} /ssh_testkey.pub" )
131164
132165# Build an ISO image with baked ssh key
133166# See https://www.system-rescue.org/scripts/sysrescue-customize/
134167# We use the systemrescue ISO and their script for customizing it.
135- pushd " ${IMAGE_DIR} "
136- wget -O sysrescue-customize https://gitlab.com/systemrescue/systemrescue-sources/-/raw/main/airootfs/usr/share/sysrescue/bin/sysrescue-customize? inline=false
137- chmod +x sysrescue-customize
138-
139- pub_ssh_key=$( cut -d " " -f " 1,2" " ssh_testkey.pub" )
140-
141- mkdir -p recipe/iso_add/sysrescue.d
142- # Reference: https://www.system-rescue.org/manual/Configuring_SystemRescue/
143- cat << EOF > recipe/iso_add/sysrescue.d/90-config.yaml
168+ if [[ ! -f " ${IMAGE_DIR} /sysrescue-out.iso" ]]; then
169+ pushd " ${IMAGE_DIR} "
170+ wget -O sysrescue-customize https://gitlab.com/systemrescue/systemrescue-sources/-/raw/main/airootfs/usr/share/sysrescue/bin/sysrescue-customize? inline=false
171+ chmod +x sysrescue-customize
172+
173+ mkdir -p recipe/iso_add/sysrescue.d
174+ # Reference: https://www.system-rescue.org/manual/Configuring_SystemRescue/
175+ cat << EOF > recipe/iso_add/sysrescue.d/90-config.yaml
144176---
145177global:
146178 nofirewall: true
@@ -149,9 +181,10 @@ sysconfig:
149181 "[email protected] ": "${pub_ssh_key} " 150182EOF
151183
152- ./sysrescue-customize --auto --recipe-dir recipe --source systemrescue-11.00-amd64.iso --dest=sysrescue-out.iso
184+ ./sysrescue-customize --auto --recipe-dir recipe --source systemrescue-11.00-amd64.iso --dest=sysrescue-out.iso
185+ popd
186+ fi
153187export ISO_IMAGE_URL=" http://${IP_ADDRESS} /sysrescue-out.iso"
154- popd
155188
156189# Generate credentials
157190BMO_OVERLAYS=(
@@ -189,6 +222,12 @@ for overlay in "${IRONIC_OVERLAYS[@]}"; do
189222 " ${overlay} /ironic-auth-config"
190223done
191224
225+ IRSO_IRONIC_AUTH_DIR=" ${REPO_ROOT} /test/e2e/data/ironic-standalone-operator/components/basic-auth"
226+ echo " ${IRONIC_USERNAME} " > " ${IRSO_IRONIC_AUTH_DIR} /ironic-username"
227+ echo " ${IRONIC_PASSWORD} " > " ${IRSO_IRONIC_AUTH_DIR} /ironic-password"
228+
229+ sed -i " s|SSH_PUB_KEY_CONTENT|${pub_ssh_key} |" " ${REPO_ROOT} " /test/e2e/data/ironic-standalone-operator/ironic/base/ironic.yaml
230+
192231# We need to gather artifacts/logs before exiting also if there are errors
193232set +e
194233
0 commit comments