Skip to content
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
13 changes: 9 additions & 4 deletions test/resources/c2cc.resource
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ${KUBECONFIG_C} ${EMPTY}
&{C2CC_KUBECONFIGS} &{EMPTY}
&{C2CC_SSH_IDS} &{EMPTY}
@{C2CC_REMOTE_ALIASES} @{EMPTY}
${IP_FAMILY} ipv4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to do this explicitly? If the VM does not have IPv4 network, then it should just work, right?



*** Keywords ***
Expand Down Expand Up @@ -135,27 +136,31 @@ Oc Apply On Cluster
Verify Routes In Table 200
[Documentation] Check that routes for the given CIDRs exist in table 200.
[Arguments] ${alias} ${remote_pod_cidr} ${remote_svc_cidr}
${stdout}= Command On Cluster ${alias} ip route show table 200
${ip_cmd}= Set Variable If '${IP_FAMILY}' == 'ipv6' ip -6 ip -4
${stdout}= Command On Cluster ${alias} ${ip_cmd} route show table 200
Should Contain ${stdout} ${remote_pod_cidr}
Should Contain ${stdout} ${remote_svc_cidr}

Verify IP Rules For Table 200
[Documentation] Check that IP rules at priority 100 exist for the given CIDRs.
[Arguments] ${alias} ${remote_pod_cidr} ${remote_svc_cidr}
${stdout}= Command On Cluster ${alias} ip rule show
${ip_cmd}= Set Variable If '${IP_FAMILY}' == 'ipv6' ip -6 ip -4
${stdout}= Command On Cluster ${alias} ${ip_cmd} rule show
Should Contain ${stdout} to ${remote_pod_cidr} lookup 200
Should Contain ${stdout} to ${remote_svc_cidr} lookup 200

Verify Routes In Table 201
[Documentation] Check that service routes exist in table 201 for the local service CIDR.
[Arguments] ${alias} ${local_svc_cidr}
${stdout}= Command On Cluster ${alias} ip route show table 201
${ip_cmd}= Set Variable If '${IP_FAMILY}' == 'ipv6' ip -6 ip -4
${stdout}= Command On Cluster ${alias} ${ip_cmd} route show table 201
Should Contain ${stdout} ${local_svc_cidr}

Verify Service IP Rules
[Documentation] Check that IP rules at priority 99 exist for cross-cluster service routing.
[Arguments] ${alias} ${remote_pod_cidr} ${remote_svc_cidr} ${local_svc_cidr}
${stdout}= Command On Cluster ${alias} ip rule show
${ip_cmd}= Set Variable If '${IP_FAMILY}' == 'ipv6' ip -6 ip -4
${stdout}= Command On Cluster ${alias} ${ip_cmd} rule show
Should Contain ${stdout} from ${remote_pod_cidr} to ${local_svc_cidr} lookup 201
Should Contain ${stdout} from ${remote_svc_cidr} to ${local_svc_cidr} lookup 201

Expand Down
187 changes: 187 additions & 0 deletions test/scenarios-bootc/el10/presubmits/el102-src@c2cc-ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/bin/bash

# Sourced from scenario.sh and uses functions defined there.
export TEST_RANDOMIZATION=none
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
export TEST_RANDOMIZATION=none
export TEST_RANDOMIZATION=suites

to follow the same approach as https://github.com/search?q=repo%3Aopenshift%2Fmicroshift%20TEST_RANDOMIZATION%3Dsuites&type=code


# Redefine network-related settings to use the dedicated IPv6 network bridge
# shellcheck disable=SC2034 # used elsewhere
VM_BRIDGE_IP="$(get_vm_bridge_ip "${VM_IPV6_NETWORK}")"
# shellcheck disable=SC2034 # used elsewhere
WEB_SERVER_URL="http://[${VM_BRIDGE_IP}]:${WEB_SERVER_PORT}"
# Using `hostname` here instead of a raw ip because skopeo only allows either
# ipv4 or fqdn's, but not ipv6. Since the registry is hosted on the ipv6
# network gateway in the host, we need to use a combination of the hostname
# plus /etc/hosts resolution (which is taken care of by kickstart).
# shellcheck disable=SC2034 # used elsewhere
MIRROR_REGISTRY_URL="$(hostname):${MIRROR_REGISTRY_PORT}/microshift"

# Cluster A (host1): non-overlapping CIDRs
CLUSTER_A_POD_CIDR="fd01::/48"
CLUSTER_A_SVC_CIDR="fd02::/112"
CLUSTER_A_DOMAIN="cluster-a.remote"

# Cluster B (host2): non-overlapping CIDRs
CLUSTER_B_POD_CIDR="fd04::/48"
CLUSTER_B_SVC_CIDR="fd05::/112"
CLUSTER_B_DOMAIN="cluster-b.remote"

# Cluster C (host3): non-overlapping CIDRs
CLUSTER_C_POD_CIDR="fd07::/48"
CLUSTER_C_SVC_CIDR="fd08::/112"
CLUSTER_C_DOMAIN="cluster-c.remote"

wait_for_greenboot_on_hosts() {
local junit_label=$1
local host
for host in host1 host2 host3; do
local host_ip full_host
host_ip=$(get_vm_property "${host}" ip)
full_host=$(full_vm_name "${host}")
if ! wait_for_greenboot "${full_host}" "${host_ip}"; then
record_junit "${host}" "${junit_label}" "FAILED"
return 1
fi
record_junit "${host}" "${junit_label}" "OK"
done
}

configure_c2cc_host() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we really need to make common file with reusable functions ASAP. Take a look at USHIFT-7117

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes, please :) but I prefer to do it on the next PR

local host=$1
shift
# Remaining args are sets of 4: remote_ip remote_pod_cidr remote_svc_cidr remote_domain (repeat)

run_command_on_vm "${host}" "sudo mkdir -p /etc/microshift/config.d"

# Build the YAML config with all remote clusters
local yaml_content
yaml_content="clusterToCluster:"$'\n'" remoteClusters:"
local firewall_cidrs=()

while [ $# -gt 0 ]; do
local remote_ip=$1
local remote_pod_cidr=$2
local remote_svc_cidr=$3
local remote_domain=$4
shift 4

yaml_content+=$'\n'" - nextHop: ${remote_ip}"
yaml_content+=$'\n'" clusterNetwork:"
yaml_content+=$'\n'" - ${remote_pod_cidr}"
yaml_content+=$'\n'" serviceNetwork:"
yaml_content+=$'\n'" - ${remote_svc_cidr}"
yaml_content+=$'\n'" domain: ${remote_domain}"

firewall_cidrs+=("${remote_pod_cidr}" "${remote_svc_cidr}")
done

run_command_on_vm "${host}" "sudo tee /etc/microshift/config.d/50-c2cc.yaml > /dev/null <<EOF
${yaml_content}
EOF"

configure_vm_firewall "${host}"
for cidr in "${firewall_cidrs[@]}"; do
run_command_on_vm "${host}" "sudo firewall-cmd --permanent --zone=trusted --add-source=${cidr}"
done
run_command_on_vm "${host}" "sudo firewall-cmd --reload"
run_command_on_vm "${host}" "sudo systemctl restart microshift"
}

configure_c2cc_hosts() {
local -r host1_ip=$(get_vm_property host1 ip)
local -r host2_ip=$(get_vm_property host2 ip)
local -r host3_ip=$(get_vm_property host3 ip)

wait_for_greenboot_on_hosts "c2cc_pre_greenboot"

Comment thread
vanhalenar marked this conversation as resolved.
configure_c2cc_host host1 \
"${host2_ip}" "${CLUSTER_B_POD_CIDR}" "${CLUSTER_B_SVC_CIDR}" "${CLUSTER_B_DOMAIN}" \
"${host3_ip}" "${CLUSTER_C_POD_CIDR}" "${CLUSTER_C_SVC_CIDR}" "${CLUSTER_C_DOMAIN}"

configure_c2cc_host host2 \
"${host1_ip}" "${CLUSTER_A_POD_CIDR}" "${CLUSTER_A_SVC_CIDR}" "${CLUSTER_A_DOMAIN}" \
"${host3_ip}" "${CLUSTER_C_POD_CIDR}" "${CLUSTER_C_SVC_CIDR}" "${CLUSTER_C_DOMAIN}"

configure_c2cc_host host3 \
"${host1_ip}" "${CLUSTER_A_POD_CIDR}" "${CLUSTER_A_SVC_CIDR}" "${CLUSTER_A_DOMAIN}" \
"${host2_ip}" "${CLUSTER_B_POD_CIDR}" "${CLUSTER_B_SVC_CIDR}" "${CLUSTER_B_DOMAIN}"

wait_for_greenboot_on_hosts "c2cc_greenboot"
}

scenario_create_vms() {
prepare_kickstart host1 kickstart-bootc.ks.template rhel102-bootc-source false true
prepare_kickstart host2 kickstart-bootc.ks.template rhel102-bootc-source false true
prepare_kickstart host3 kickstart-bootc.ks.template rhel102-bootc-source false true

# Inject host2's and host3's non-default CIDRs into its kickstart config so MicroShift
# boots with the correct network from the start (no cleanup-data needed).
local -r host2_ks_dir="${SCENARIO_INFO_DIR}/${SCENARIO}/vms/host2"
cat >> "${host2_ks_dir}/post-microshift.cfg" <<EOF
cat - >>/etc/microshift/config.yaml <<IEOF
network:
clusterNetwork:
- ${CLUSTER_B_POD_CIDR}
serviceNetwork:
- ${CLUSTER_B_SVC_CIDR}
IEOF
EOF
local -r host3_ks_dir="${SCENARIO_INFO_DIR}/${SCENARIO}/vms/host3"
cat >> "${host3_ks_dir}/post-microshift.cfg" <<EOF
cat - >>/etc/microshift/config.yaml <<IEOF
network:
clusterNetwork:
- ${CLUSTER_C_POD_CIDR}
serviceNetwork:
- ${CLUSTER_C_SVC_CIDR}
IEOF
EOF

launch_vm rhel102-bootc --vmname host1 --network "${VM_IPV6_NETWORK}"
launch_vm rhel102-bootc --vmname host2 --network "${VM_IPV6_NETWORK}"
launch_vm rhel102-bootc --vmname host3 --network "${VM_IPV6_NETWORK}"
}

scenario_remove_vms() {
remove_vm host1
remove_vm host2
remove_vm host3
}

scenario_run_tests() {
if ! configure_c2cc_hosts; then
return 1
fi

# Retrieve host2's kubeconfig
local -r host2_ip=$(get_vm_property host2 ip)
local -r kubeconfig_b="${SCENARIO_INFO_DIR}/${SCENARIO}/kubeconfig-b"

# Retrieve host3's kubeconfig
local -r host3_ip=$(get_vm_property host3 ip)
local -r kubeconfig_c="${SCENARIO_INFO_DIR}/${SCENARIO}/kubeconfig-c"

# Wait for host2 and host3 to be fully ready (run_tests only waits for host1)
wait_for_microshift_to_be_ready host2
wait_for_microshift_to_be_ready host3

run_command_on_vm host2 "sudo cp /var/lib/microshift/resources/kubeadmin/${host2_ip}/kubeconfig /tmp/kubeconfig-b && sudo chmod 644 /tmp/kubeconfig-b"
run_command_on_vm host3 "sudo cp /var/lib/microshift/resources/kubeadmin/${host3_ip}/kubeconfig /tmp/kubeconfig-c && sudo chmod 644 /tmp/kubeconfig-c"
copy_file_from_vm host2 "/tmp/kubeconfig-b" "${kubeconfig_b}"
copy_file_from_vm host3 "/tmp/kubeconfig-c" "${kubeconfig_c}"

run_tests host1 \
--variable "CLUSTER_A_POD_CIDR:${CLUSTER_A_POD_CIDR}" \
--variable "CLUSTER_A_SVC_CIDR:${CLUSTER_A_SVC_CIDR}" \
--variable "CLUSTER_A_DOMAIN:${CLUSTER_A_DOMAIN}" \
--variable "CLUSTER_B_POD_CIDR:${CLUSTER_B_POD_CIDR}" \
--variable "CLUSTER_B_SVC_CIDR:${CLUSTER_B_SVC_CIDR}" \
--variable "CLUSTER_B_DOMAIN:${CLUSTER_B_DOMAIN}" \
--variable "KUBECONFIG_B:${kubeconfig_b}" \
--variable "CLUSTER_C_POD_CIDR:${CLUSTER_C_POD_CIDR}" \
--variable "CLUSTER_C_SVC_CIDR:${CLUSTER_C_SVC_CIDR}" \
--variable "CLUSTER_C_DOMAIN:${CLUSTER_C_DOMAIN}" \
--variable "KUBECONFIG_C:${kubeconfig_c}" \
--variable "FOREIGN_CIDR:2001:db8::/64" \
--variable "IP_FAMILY:ipv6" \
suites/c2cc/
}
1 change: 1 addition & 0 deletions test/scenarios-bootc/el10/presubmits/el102-src@c2cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,6 @@ scenario_run_tests() {
--variable "CLUSTER_C_SVC_CIDR:${CLUSTER_C_SVC_CIDR}" \
--variable "CLUSTER_C_DOMAIN:${CLUSTER_C_DOMAIN}" \
--variable "KUBECONFIG_C:${kubeconfig_c}" \
--variable "FOREIGN_CIDR:192.0.2.0/24" \
suites/c2cc/
}
Loading