Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 🌱 Stop using dev-env in E2E setup #2250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
formatter:
indentless_arrays: true
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ test-clusterclass-e2e: ## Run e2e tests with capi e2e testing framework
GINKGO_NOCOLOR ?= false
ARTIFACTS ?= $(ROOT_DIR)/_artifacts
E2E_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/e2e_conf.yaml
E2E_BMCS_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/bmcs-redfish-virtualmedia.yaml
E2E_OUT_DIR ?= $(ROOT_DIR)/test/e2e/_out
E2E_CONF_FILE_ENVSUBST ?= $(E2E_OUT_DIR)/$(notdir $(E2E_CONF_FILE))
E2E_CONTAINERS ?= quay.io/metal3-io/cluster-api-provider-metal3 quay.io/metal3-io/baremetal-operator quay.io/metal3-io/ip-address-manager
Expand Down Expand Up @@ -221,6 +222,7 @@ e2e-tests: $(GINKGO) e2e-substitutions cluster-templates # This target should be
--focus="$(GINKGO_FOCUS)" $(_SKIP_ARGS) "$(ROOT_DIR)/$(TEST_DIR)/e2e/" -- \
-e2e.artifacts-folder="$(ARTIFACTS)" \
-e2e.config="$(E2E_CONF_FILE_ENVSUBST)" \
-e2e.bmcsConfig="$(E2E_BMCS_CONF_FILE)" \
-e2e.skip-resource-cleanup=$(SKIP_CLEANUP) \
-e2e.trigger-ephemeral-test=$(EPHEMERAL_TEST) \
-e2e.use-existing-cluster=$(SKIP_CREATE_MGMT_CLUSTER)
Expand Down
2 changes: 1 addition & 1 deletion baremetal/metal3cluster_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
func bmcSpec() *infrav1.Metal3ClusterSpec {
return &infrav1.Metal3ClusterSpec{
ControlPlaneEndpoint: infrav1.APIEndpoint{
Host: "192.168.111.249",
Host: "192.168.111.100",
Port: 6443,
},
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func m3mObjectMetaWithOwnerRef() *metav1.ObjectMeta {
func bmcSpec() *infrav1.Metal3ClusterSpec {
return &infrav1.Metal3ClusterSpec{
ControlPlaneEndpoint: infrav1.APIEndpoint{
Host: "192.168.111.249",
Host: "192.168.111.100",
Port: 6443,
},
NoCloudProvider: ptr.To(true),
Expand Down
21 changes: 21 additions & 0 deletions hack/e2e/external.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<network>
<name>external</name>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='m3ex'/>
<domain name='ostest.test.metalkube.org' localOnly='yes'/>
<dns>
<forwarder domain='apps.ostest.test.metalkube.org' addr='127.0.0.1'/>
</dns>
<ip address='192.168.100.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.100.2' end='192.168.100.199'/>
</dhcp>
</ip>
<dnsmasq:options>
<dnsmasq:option value='cache-size=0'/>
</dnsmasq:options>
</network>
34 changes: 34 additions & 0 deletions hack/e2e/fake-ipa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#!/bin/bash
#!/usr/bin/env bash


set -euxo pipefail

launch_fake_ipa()
{
# Create a folder to host fakeIPA config and certs
mkdir -p "${WORKING_DIR}/fake-ipa"
if [[ "${EPHEMERAL_CLUSTER}" = "kind" ]] && [[ "${IRONIC_TLS_SETUP}" = "true" ]]; then
cp "${IRONIC_CACERT_FILE}" "${WORKING_DIR}/fake-ipa/ironic-ca.crt"
elif [[ "${IRONIC_TLS_SETUP}" = "true" ]]; then
# wait for ironic to be running to ensure ironic-cert is created
kubectl -n baremetal-operator-system wait --for=condition=available deployment/baremetal-operator-ironic --timeout=900s
# Extract ironic-cert to be used inside fakeIPA for TLS
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"
fi

# Create fake IPA custom config
cat <<EOF > "${WORKING_DIR}/fake-ipa/config.py"
FAKE_IPA_API_URL = "https://${CLUSTER_BARE_METAL_PROVISIONER_IP}:${IRONIC_API_PORT}"
FAKE_IPA_INSPECTION_CALLBACK_URL = "${IRONIC_URL}/continue_inspection"
FAKE_IPA_ADVERTISE_ADDRESS_IP = "${EXTERNAL_SUBNET_V4_HOST}"
FAKE_IPA_INSECURE = ${FAKE_IPA_INSECURE:-False}
FAKE_IPA_CAFILE = "${FAKE_IPA_CAFILE:-/root/cert/ironic-ca.crt}"
FAKE_IPA_MIN_BOOT_TIME = ${FAKE_IPA_MIN_BOOT_TIME:-20}
FAKE_IPA_MAX_BOOT_TIME = ${FAKE_IPA_MAX_BOOT_TIME:-30}
EOF

# shellcheck disable=SC2086
sudo "${CONTAINER_RUNTIME}" run -d --net host --name fake-ipa ${POD_NAME_INFRA} \
-v "/opt/metal3-dev-env/fake-ipa":/root/cert -v "/root/.ssh":/root/ssh \
-e CONFIG='/root/cert/config.py' \
"${FAKE_IPA_IMAGE}"
}
16 changes: 16 additions & 0 deletions hack/e2e/net.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<network>
<name>baremetal-e2e</name>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='metal3'/>
<ip address='192.168.222.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.222.2' end='192.168.222.199'/>
<host mac='52:54:00:6c:3c:01' name='minikube' ip='192.168.222.199'/>
<bootp file='http://192.168.222.199:6180/boot.ipxe'/>
</dhcp>
</ip>
</network>
11 changes: 11 additions & 0 deletions hack/e2e/provisioning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<network>
<name>provisioning</name>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='provisioning'/>
<ip address='192.168.111.1' netmask='255.255.255.0'>
</ip>
</network>
50 changes: 18 additions & 32 deletions hack/ensure-go.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
#!/usr/bin/env bash

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

set -o errexit
set -o nounset
set -o pipefail
MINIMUM_GO_VERSION=go1.22.4

# Ensure the go tool exists and is a viable version.
# Ensure the go tool exists and is a viable version, or installs it
verify_go_version()
{
if [[ -z "$(command -v go)" ]]; then
cat << EOF
Can't find 'go' in PATH, please fix and retry.
See http://golang.org/doc/install for installation instructions.
EOF
return 2
# If go is not available on the path, get it
if ! [ -x "$(command -v go)" ]; then
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
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
else
echo "Missing required binary in path: go"
return 2
fi
fi

local go_version
IFS=" " read -ra go_version <<< "$(go version)"
local minimum_go_version
minimum_go_version=go1.20
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
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
cat << EOF
Detected go version: ${go_version[*]}.
Kubernetes requires ${minimum_go_version} or greater.
Please install ${minimum_go_version} or later.
Detected go version: ${go_version[2]}.
Requires ${MINIMUM_GO_VERSION} or greater.
Please install ${MINIMUM_GO_VERSION} or later.
EOF
return 2
fi
}

verify_go_version

# Explicitly opt into go modules, even though we're inside a GOPATH directory
export GO111MODULE=on
49 changes: 49 additions & 0 deletions hack/ensure_kubectl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

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

set -eux

USR_LOCAL_BIN="/usr/local/bin"
MINIMUM_KUBECTL_VERSION=v1.32.0

# Ensure the kubectl tool exists and is a viable version, or installs it
verify_kubectl_version()
{
# If kubectl is not available on the path, get it
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"
else
echo "Missing required binary in path: kubectl"
return 2
fi
fi

local kubectl_version
IFS=" " read -ra kubectl_version <<< "$(kubectl version --client)"
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
cat << EOF
Detected kubectl version: ${kubectl_version[2]}.
Requires ${MINIMUM_KUBECTL_VERSION} or greater.
Please install ${MINIMUM_KUBECTL_VERSION} or later.
EOF
return 2
fi
}

verify_kubectl_version
33 changes: 33 additions & 0 deletions hack/ensure_minikube.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -eux

USR_LOCAL_BIN="/usr/local/bin"
OS=$(go env GOOS)
ARCH=$(go env GOARCH)
MINIMUM_MINIKUBE_VERSION=v1.33.0

verify_minikube_version() {
if ! [ -x "$(command -v minikube)" ]; then
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
echo "minikube not found, installing"
curl -LO "https://storage.googleapis.com/minikube/releases/${MINIMUM_MINIKUBE_VERSION}/minikube-${OS}-${ARCH}"
sudo install minikube-linux-amd64 "${USR_LOCAL_BIN}/minikube"
else
echo "Missing required binary in path: minikube"
return 2
fi
fi
local minikube_version
minikube_version="$(minikube version --short)"
if [[ "${MINIMUM_MINIKUBE_VERSION}" != $(echo -e "${MINIMUM_MINIKUBE_VERSION}\n${minikube_version}" | sort -V | head -n1) ]]; then
cat << EOF
Detected minikube version: ${minikube_version}.
Requires ${MINIMUM_MINIKUBE_VERSION} or greater.
Please install ${MINIMUM_MINIKUBE_VERSION} or later.
EOF
return 2
fi
}

verify_minikube_version
24 changes: 24 additions & 0 deletions hack/ensure_yq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -eux

USR_LOCAL_BIN="/usr/local/bin"
YQ_VERSION="v4.40.5"

# Check if yq tool is installed and install it if not
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"
else
echo "Missing required binary in path: yq"
return 2
fi
fi
}

verify_yq
Loading
Loading