-
Notifications
You must be signed in to change notification settings - Fork 230
USHIFT-6849: Add C2CC IPv6 tests scenarios #6750
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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() { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||||||
|
|
||||||
|
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/ | ||||||
| } | ||||||
There was a problem hiding this comment.
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?