Skip to content

Commit 5477d81

Browse files
Huy Maismoshiur1237
authored andcommitted
Stop using dev-env in E2E setup
This commit pushes changes needed so that we no longer need to run dev-env's make in preparation for E2E. Signed-off-by: Huy Mai <[email protected]> Signed-off-by: smoshiur1237 <[email protected]>
1 parent 505d77e commit 5477d81

File tree

38 files changed

+934
-161
lines changed

38 files changed

+934
-161
lines changed

.yamlfmt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
formatter:
2+
indentless_arrays: true

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ test-clusterclass-e2e: ## Run e2e tests with capi e2e testing framework
163163
GINKGO_NOCOLOR ?= false
164164
ARTIFACTS ?= $(ROOT_DIR)/_artifacts
165165
E2E_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/e2e_conf.yaml
166+
E2E_BMCS_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/bmcs-redfish-virtualmedia.yaml
166167
E2E_OUT_DIR ?= $(ROOT_DIR)/test/e2e/_out
167168
E2E_CONF_FILE_ENVSUBST ?= $(E2E_OUT_DIR)/$(notdir $(E2E_CONF_FILE))
168169
SKIP_CLEANUP ?= false
@@ -271,6 +272,7 @@ e2e-tests: $(GINKGO) e2e-substitutions cluster-templates # This target should be
271272
--focus="$(GINKGO_FOCUS)" $(_SKIP_ARGS) "$(ROOT_DIR)/$(TEST_DIR)/e2e/" -- \
272273
-e2e.artifacts-folder="$(ARTIFACTS)" \
273274
-e2e.config="$(E2E_CONF_FILE_ENVSUBST)" \
275+
-e2e.bmcsConfig="$(E2E_BMCS_CONF_FILE)" \
274276
-e2e.skip-resource-cleanup=$(SKIP_CLEANUP) \
275277
-e2e.trigger-ephemeral-test=$(EPHEMERAL_TEST) \
276278
-e2e.use-existing-cluster=$(SKIP_CREATE_MGMT_CLUSTER)

baremetal/metal3cluster_manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
func bmcSpec() *infrav1.Metal3ClusterSpec {
3636
return &infrav1.Metal3ClusterSpec{
3737
ControlPlaneEndpoint: infrav1.APIEndpoint{
38-
Host: "192.168.111.249",
38+
Host: "192.168.111.100",
3939
Port: 6443,
4040
},
4141
}

controllers/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func m3mObjectMetaWithOwnerRef() *metav1.ObjectMeta {
170170
func bmcSpec() *infrav1.Metal3ClusterSpec {
171171
return &infrav1.Metal3ClusterSpec{
172172
ControlPlaneEndpoint: infrav1.APIEndpoint{
173-
Host: "192.168.111.249",
173+
Host: "192.168.111.100",
174174
Port: 6443,
175175
},
176176
NoCloudProvider: ptr.To(true),

hack/e2e/external.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<network>
2+
<name>external</name>
3+
<forward mode='nat'>
4+
<nat>
5+
<port start='1024' end='65535'/>
6+
</nat>
7+
</forward>
8+
<bridge name='m3ex'/>
9+
<domain name='ostest.test.metalkube.org' localOnly='yes'/>
10+
<dns>
11+
<forwarder domain='apps.ostest.test.metalkube.org' addr='127.0.0.1'/>
12+
</dns>
13+
<ip address='192.168.100.1' netmask='255.255.255.0'>
14+
<dhcp>
15+
<range start='192.168.100.2' end='192.168.100.199'/>
16+
</dhcp>
17+
</ip>
18+
<dnsmasq:options>
19+
<dnsmasq:option value='cache-size=0'/>
20+
</dnsmasq:options>
21+
</network>

hack/e2e/fake-ipa.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
launch_fake_ipa()
6+
{
7+
# Create a folder to host fakeIPA config and certs
8+
mkdir -p "${WORKING_DIR}/fake-ipa"
9+
if [[ "${EPHEMERAL_CLUSTER}" = "kind" ]] && [[ "${IRONIC_TLS_SETUP}" = "true" ]]; then
10+
cp "${IRONIC_CACERT_FILE}" "${WORKING_DIR}/fake-ipa/ironic-ca.crt"
11+
elif [[ "${IRONIC_TLS_SETUP}" = "true" ]]; then
12+
# wait for ironic to be running to ensure ironic-cert is created
13+
kubectl -n baremetal-operator-system wait --for=condition=available deployment/baremetal-operator-ironic --timeout=900s
14+
# Extract ironic-cert to be used inside fakeIPA for TLS
15+
kubectl get secret -n baremetal-operator-system ironic-cert -o json -o=jsonpath="{.data.ca\.crt}" | base64 -d > "${WORKING_DIR}/fake-ipa/ironic-ca.crt"
16+
fi
17+
18+
# Create fake IPA custom config
19+
cat <<EOF > "${WORKING_DIR}/fake-ipa/config.py"
20+
FAKE_IPA_API_URL = "https://${CLUSTER_BARE_METAL_PROVISIONER_IP}:${IRONIC_API_PORT}"
21+
FAKE_IPA_INSPECTION_CALLBACK_URL = "${IRONIC_URL}/continue_inspection"
22+
FAKE_IPA_ADVERTISE_ADDRESS_IP = "${EXTERNAL_SUBNET_V4_HOST}"
23+
FAKE_IPA_INSECURE = ${FAKE_IPA_INSECURE:-False}
24+
FAKE_IPA_CAFILE = "${FAKE_IPA_CAFILE:-/root/cert/ironic-ca.crt}"
25+
FAKE_IPA_MIN_BOOT_TIME = ${FAKE_IPA_MIN_BOOT_TIME:-20}
26+
FAKE_IPA_MAX_BOOT_TIME = ${FAKE_IPA_MAX_BOOT_TIME:-30}
27+
EOF
28+
29+
# shellcheck disable=SC2086
30+
sudo "${CONTAINER_RUNTIME}" run -d --net host --name fake-ipa ${POD_NAME_INFRA} \
31+
-v "/opt/metal3-dev-env/fake-ipa":/root/cert -v "/root/.ssh":/root/ssh \
32+
-e CONFIG='/root/cert/config.py' \
33+
"${FAKE_IPA_IMAGE}"
34+
}

hack/e2e/net.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<network>
2+
<name>baremetal-e2e</name>
3+
<forward mode='nat'>
4+
<nat>
5+
<port start='1024' end='65535'/>
6+
</nat>
7+
</forward>
8+
<bridge name='metal3'/>
9+
<ip address='192.168.222.1' netmask='255.255.255.0'>
10+
<dhcp>
11+
<range start='192.168.222.2' end='192.168.222.199'/>
12+
<host mac='52:54:00:6c:3c:01' name='minikube' ip='192.168.222.199'/>
13+
<bootp file='http://192.168.222.199:6180/boot.ipxe'/>
14+
</dhcp>
15+
</ip>
16+
</network>

hack/e2e/provisioning.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<network>
2+
<name>provisioning</name>
3+
<forward mode='nat'>
4+
<nat>
5+
<port start='1024' end='65535'/>
6+
</nat>
7+
</forward>
8+
<bridge name='provisioning'/>
9+
<ip address='192.168.111.1' netmask='255.255.255.0'>
10+
</ip>
11+
</network>

hack/ensure-go.sh

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2021 The Kubernetes Authors.
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
3+
set -eux
164

17-
set -o errexit
18-
set -o nounset
19-
set -o pipefail
20-
21-
# Ensure the go tool exists and is a viable version.
5+
MINIMUM_GO_VERSION=go1.24.0
6+
# Ensure the go tool exists and is a viable version, or installs it
227
verify_go_version()
238
{
24-
if [[ -z "$(command -v go)" ]]; then
25-
cat << EOF
26-
Can't find 'go' in PATH, please fix and retry.
27-
See http://golang.org/doc/install for installation instructions.
28-
EOF
29-
return 2
9+
# If go is not available on the path, get it
10+
if ! [ -x "$(command -v go)" ]; then
11+
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
12+
echo 'go not found, installing'
13+
curl -sLo "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz" "https://go.dev/dl/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz"
14+
sudo tar -C /usr/local -xzf "/tmp/${MINIMUM_GO_VERSION}.linux-amd64.tar.gz"
15+
export PATH=/usr/local/go/bin:$PATH
16+
else
17+
echo "Missing required binary in path: go"
18+
return 2
19+
fi
3020
fi
3121

3222
local go_version
@@ -36,7 +26,7 @@ EOF
3626
if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]] && [[ "${go_version[2]}" != "devel" ]]; then
3727
cat << EOF
3828
Detected go version: ${go_version[*]}.
39-
Kubernetes requires ${minimum_go_version} or greater.
29+
Requires ${minimum_go_version} or greater.
4030
Please install ${minimum_go_version} or later.
4131
EOF
4232
return 2

hack/ensure_kubectl.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eux
18+
19+
USR_LOCAL_BIN="/usr/local/bin"
20+
MINIMUM_KUBECTL_VERSION=v1.32.0
21+
22+
# Ensure the kubectl tool exists and is a viable version, or installs it
23+
verify_kubectl_version()
24+
{
25+
# If kubectl is not available on the path, get it
26+
if ! [ -x "$(command -v kubectl)" ]; then
27+
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
28+
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"
31+
else
32+
echo "Missing required binary in path: kubectl"
33+
return 2
34+
fi
35+
fi
36+
37+
local kubectl_version
38+
IFS=" " read -ra kubectl_version <<< "$(kubectl version --client)"
39+
if [[ "${MINIMUM_KUBECTL_VERSION}" != $(echo -e "${MINIMUM_KUBECTL_VERSION}\n${kubectl_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]]; then
40+
cat << EOF
41+
Detected kubectl version: ${kubectl_version[2]}.
42+
Requires ${MINIMUM_KUBECTL_VERSION} or greater.
43+
Please install ${MINIMUM_KUBECTL_VERSION} or later.
44+
EOF
45+
return 2
46+
fi
47+
}
48+
49+
verify_kubectl_version

0 commit comments

Comments
 (0)