Skip to content

Commit 994c3c6

Browse files
Merge pull request #2681 from Nordix/nuhakala/e2e_irso_deployment
🌱 Replace ironic deployment with IrSO in e2e
2 parents 7085ea4 + 286796d commit 994c3c6

File tree

24 files changed

+395
-45
lines changed

24 files changed

+395
-45
lines changed

config/overlays/e2e/ironic.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
IRONIC_ENDPOINT=https://192.168.222.1:6385/v1/
1+
IRONIC_ENDPOINT=https://192.168.222.2:6385/v1/

hack/ci-e2e.sh

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ echo "BMO_E2E_EMULATOR=${BMO_E2E_EMULATOR}"
3333
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/ironic.yaml"
3434
export 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)
6060
IMG=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
6899
sudo 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.
71103
IP_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
78106
make build-vbmctl
79107
# Create VMs to act as BMHs in the tests.
80108
./bin/vbmctl --yaml-source-file "${E2E_BMCS_CONF_FILE}"
81109

82110
if [[ "${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"
118146
mkdir -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
---
145177
global:
146178
nofirewall: true
@@ -149,9 +181,10 @@ sysconfig:
149181
"[email protected]": "${pub_ssh_key}"
150182
EOF
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
153187
export ISO_IMAGE_URL="http://${IP_ADDRESS}/sysrescue-out.iso"
154-
popd
155188

156189
# Generate credentials
157190
BMO_OVERLAYS=(
@@ -189,6 +222,12 @@ for overlay in "${IRONIC_OVERLAYS[@]}"; do
189222
"${overlay}/ironic-auth-config"
190223
done
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
193232
set +e
194233

hack/e2e/net.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<bridge name='metal3'/>
99
<ip address='192.168.222.1' netmask='255.255.255.0'>
1010
<dhcp>
11-
<range start='192.168.222.2' end='192.168.222.99'/>
12-
<bootp file='http://192.168.222.1:6180/boot.ipxe'/>
11+
<range start='192.168.222.3' end='192.168.222.99'/>
12+
<bootp file='http://192.168.222.2:6180/boot.ipxe'/>
1313
</dhcp>
1414
</ip>
1515
</network>

test/e2e/common.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strings"
2323

2424
metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
25+
irsov1alpha1 "github.com/metal3-io/ironic-standalone-operator/api/v1alpha1"
2526
. "github.com/onsi/ginkgo/v2"
2627
. "github.com/onsi/gomega"
2728
"golang.org/x/crypto/ssh"
@@ -686,3 +687,36 @@ func dumpIronicNodes(ctx context.Context, e2eConfig *Config, artifactFolder stri
686687
_, err = file.Write(logOutput.Bytes())
687688
Expect(err).ToNot(HaveOccurred(), "Error writing JSON to file")
688689
}
690+
691+
// WaitForIronicReady waits until the given Ironic resource has Ready condition = True.
692+
func WaitForIronicReady(ctx context.Context, input WaitForIronicInput) {
693+
Logf("Waiting for Ironic %q to be Ready", input.Name)
694+
695+
Eventually(func(g Gomega) {
696+
ironic := &irsov1alpha1.Ironic{}
697+
err := input.Client.Get(ctx, client.ObjectKey{
698+
Namespace: input.Namespace,
699+
Name: input.Name,
700+
}, ironic)
701+
g.Expect(err).ToNot(HaveOccurred())
702+
703+
ready := false
704+
for _, cond := range ironic.Status.Conditions {
705+
if cond.Type == string(irsov1alpha1.IronicStatusReady) && cond.Status == metav1.ConditionTrue && ironic.Status.InstalledVersion != "" {
706+
ready = true
707+
break
708+
}
709+
}
710+
g.Expect(ready).To(BeTrue(), "Ironic %q is not Ready yet", input.Name)
711+
}, input.Intervals...).Should(Succeed())
712+
713+
Logf("Ironic %q is Ready", input.Name)
714+
}
715+
716+
// WaitForIronicInput bundles the parameters for WaitForIronicReady.
717+
type WaitForIronicInput struct {
718+
Client client.Client
719+
Name string
720+
Namespace string
721+
Intervals []interface{} // e.g. []interface{}{time.Minute * 15, time.Second * 5}
722+
}

test/e2e/config/ironic.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ images:
1717
loadBehavior: tryLoad
1818
- name: quay.io/jetstack/cert-manager-controller:v1.17.1
1919
loadBehavior: tryLoad
20+
- name: quay.io/metal3-io/ironic-standalone-operator:v0.5.1
21+
loadBehavior: tryLoad
22+
- name: quay.io/metal3-io/ironic-ipa-downloader:main
23+
loadBehavior: tryLoad
2024

2125
# These variables can be overridden with environment variables.
2226
variables:
@@ -47,8 +51,15 @@ variables:
4751
FETCH_IRONIC_NODES: "true"
4852
IRONIC_USERNAME: "changeme"
4953
IRONIC_PASSWORD: "changeme"
50-
IRONIC_PROVISIONING_IP: "localhost"
54+
IRONIC_PROVISIONING_IP: "192.168.222.2"
5155
IRONIC_PROVISIONING_PORT: "6385"
56+
IRSO_OPERATOR_LATEST: "data/ironic-standalone-operator/operator"
57+
# IRSO_IRONIC_27.0: "data/ironic-standalone-operator/ironic/overlays/e2e-release-27.0"
58+
# IRSO_IRONIC_28.0: "data/ironic-standalone-operator/ironic/overlays/e2e-release-28.0"
59+
# IRSO_IRONIC_29.0: "data/ironic-standalone-operator/ironic/overlays/e2e-release-29.0"
60+
# IRSO_IRONIC_30.0: "data/ironic-standalone-operator/ironic/overlays/e2e-release-30.0"
61+
# IRSO_IRONIC_31.0: "data/ironic-standalone-operator/ironic/overlays/e2e-release-31.0"
62+
IRSO_IRONIC_MAIN: "data/ironic-standalone-operator/ironic/overlays/e2e"
5263

5364
NAMESPACE_SCOPED: "true"
5465

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: ironic.metal3.io/v1alpha1
2+
kind: Ironic
3+
metadata:
4+
name: ironic
5+
namespace: baremetal-operator-system
6+
spec:
7+
apiCredentialsName: ironic-auth
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
patches:
5+
- path: auth-patch.yaml
6+
7+
generatorOptions:
8+
disableNameSuffixHash: true
9+
10+
# NOTE: These credentials are generated automatically in hack/ci-e2e.sh
11+
secretGenerator:
12+
- name: ironic-auth
13+
behavior: create
14+
files:
15+
- username=ironic-username
16+
- password=ironic-password
17+
type: Opaque
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Issuer
3+
metadata:
4+
name: selfsigned-issuer
5+
namespace: baremetal-operator-system
6+
spec:
7+
selfSigned: {}
8+
---
9+
apiVersion: cert-manager.io/v1
10+
kind: Certificate
11+
metadata:
12+
name: ironic-cacert
13+
namespace: baremetal-operator-system
14+
spec:
15+
commonName: ironic-ca
16+
isCA: true
17+
issuerRef:
18+
kind: Issuer
19+
name: selfsigned-issuer
20+
secretName: ironic-cacert
21+
---
22+
apiVersion: cert-manager.io/v1
23+
kind: Issuer
24+
metadata:
25+
name: ca-issuer
26+
namespace: baremetal-operator-system
27+
spec:
28+
ca:
29+
secretName: ironic-cacert
30+
---
31+
apiVersion: cert-manager.io/v1
32+
kind: Certificate
33+
metadata:
34+
name: ironic-cert
35+
namespace: baremetal-operator-system
36+
spec:
37+
commonName: ironic-cert
38+
ipAddresses:
39+
- 192.168.222.2
40+
issuerRef:
41+
kind: Issuer
42+
name: ca-issuer
43+
secretName: ironic-cert
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
resources:
5+
- certificate.yaml
6+
7+
patches:
8+
- path: tls.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: ironic.metal3.io/v1alpha1
2+
kind: Ironic
3+
metadata:
4+
name: ironic
5+
namespace: baremetal-operator-system
6+
spec:
7+
tls:
8+
certificateName: ironic-cert

0 commit comments

Comments
 (0)