Skip to content
Merged
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
6 changes: 5 additions & 1 deletion test/assets/ipv6-network.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<network>
<name>${VM_IPV6_NETWORK}</name>
<forward mode='none'/>
<forward mode="nat">
<nat ipv6='yes'>
<port start='1024' end='65535'/>
</nat>
</forward>
<ip family="ipv6" address="2001:db8:ca7:ff::1" prefix="96">
<dhcp>
<range start="2001:db8:ca7:ff::1000" end="2001:db8:ca7:ff::2000" />
Expand Down
1 change: 1 addition & 0 deletions test/bin/scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ prepare_kickstart() {
-e "s|REPLACE_FIPS_ENABLED|${fips_enabled}|g" \
-e "s|REPLACE_ENABLE_MIRROR|${ENABLE_REGISTRY_MIRROR}|g" \
-e "s|REPLACE_MIRROR_HOSTNAME|${hostname}|g" \
-e "s|REPLACE_VM_BRIDGE_IP|${VM_BRIDGE_IP}|g" \
"${ifile}" > "${output_file}"
done
record_junit "${vmname}" "prepare_kickstart" "OK"
Expand Down
6 changes: 6 additions & 0 deletions test/kickstart-templates/includes/post-containers.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ chmod 600 /etc/crio/openshift-pull-secret

if REPLACE_ENABLE_MIRROR; then
# Setup mirror registries configuration here, as the hostname is dynamic and the file is verbose.
# Use hostnames as IP addresses are not allowed. Since ec2 hostnames do not resolve to IPv6 addresses
# the /etc/hosts file will contain the hostname with the bridge IP from the host.
mkdir -p /etc/containers/registries.conf.d
cat > /etc/containers/registries.conf.d/999-microshift-mirror.conf <<EOF
[[registry]]
Expand Down Expand Up @@ -51,4 +53,8 @@ EOF
}
}
EOF

cat >> /etc/hosts <<EOF
REPLACE_VM_BRIDGE_IP REPLACE_MIRROR_HOSTNAME
EOF
fi
4 changes: 3 additions & 1 deletion test/resources/kubeconfig.resource
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Documentation Keywords for accessing a kubeconfig file for the MicroShift
Library OperatingSystem
Library String
Library DataFormats.py
Library libipv6.py
Resource ../resources/microshift-host.resource
Resource ../resources/common.resource

Expand Down Expand Up @@ -31,9 +32,10 @@ Setup Kubeconfig
# If we have been given an explicit API port to use, make sure that
# port appears in the kubeconfig file.
IF "${API_PORT}"!="${EMPTY}"
${ip}= Add Brackets If Ipv6 ${USHIFT_HOST}
${kubeconfig}= Update Kubeconfig Server Url
... ${kubeconfig}
... https://${USHIFT_HOST}:${API_PORT}
... https://${ip}:${API_PORT}
END
${path}= Create Random Temp File ${kubeconfig}
Set Suite Variable \${KUBECONFIG} ${path}
Expand Down
21 changes: 17 additions & 4 deletions test/resources/microshift-network.resource
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ Access Hello Microshift
... ${ushift_ip}=${USHIFT_HOST}
... ${path}=${EMPTY}
... ${scheme}=http
... ${hostname}=hello-microshift.cluster.local

${ip}= Add Brackets If Ipv6 ${ushift_ip}

${connect_to}= Set Variable "hello-microshift.cluster.local::${ip}:"
${url_path}= Set Variable "${scheme}://hello-microshift.cluster.local:${ushift_port}${path}"
${connect_to}= Set Variable "${hostname}::${ip}:"
${url_path}= Set Variable "${scheme}://${hostname}:${ushift_port}${path}"

${result}= Run Process
... curl -k -i ${url_path} --connect-to ${connect_to}
Expand All @@ -61,26 +62,38 @@ Access Hello Microshift

Access Hello MicroShift Success
[Documentation] Expect 200 OK when accessing "hello microshift" through the router.
[Arguments] ${ushift_port} ${ushift_ip}=${USHIFT_HOST} ${path}=${EMPTY} ${scheme}=http
[Arguments]
... ${ushift_port}
... ${ushift_ip}=${USHIFT_HOST}
... ${path}=${EMPTY}
... ${scheme}=http
... ${hostname}=hello-microshift.cluster.local

${rc} ${stdout} ${stderr}= Access Hello MicroShift
... ushift_port=${ushift_port}
... ushift_ip=${ushift_ip}
... path=${path}
... scheme=${scheme}
... hostname=${hostname}
Should Be Equal As Integers ${rc} 0
Should Match Regexp ${stdout} HTTP.*200
Should Match ${stdout} *Hello MicroShift*

Access Hello MicroShift No Route
[Documentation] Expect 503 Service Unavailable when accessing "hello microshift" through the router.
[Arguments] ${ushift_port} ${ushift_ip}=${USHIFT_HOST} ${path}=${EMPTY} ${scheme}=http
[Arguments]
... ${ushift_port}
... ${ushift_ip}=${USHIFT_HOST}
... ${path}=${EMPTY}
... ${scheme}=http
... ${hostname}=hello-microshift.cluster.local

${rc} ${stdout} ${stderr}= Access Hello MicroShift
... ushift_port=${ushift_port}
... ushift_ip=${ushift_ip}
... path=${path}
... scheme=${scheme}
... hostname=${hostname}
Should Be Equal As Integers ${rc} 0
Should Match Regexp ${stdout} HTTP.*503

Expand Down
28 changes: 28 additions & 0 deletions test/scenarios/el94-src@ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Sourced from scenario.sh and uses functions defined there.

# Redefine network-related settings to use the dedicated 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}"
# shellcheck disable=SC2034 # used elsewhere
BOOTC_REGISTRY_URL="${VM_BRIDGE_IP}:5000"
# Redefine registry mirror. The redhat.registry.io does not resolve to
# ipv6 and the mirror is mandatory.
# shellcheck disable=SC2034 # used elsewhere
ENABLE_REGISTRY_MIRROR=true

scenario_create_vms() {
prepare_kickstart host1 kickstart.ks.template rhel-9.4-microshift-source
launch_vm host1 rhel-9.4 "${VM_IPV6_NETWORK}"
}

scenario_remove_vms() {
remove_vm host1
}

scenario_run_tests() {
run_tests host1 suites/ipv6/singlestack.robot
}
104 changes: 104 additions & 0 deletions test/suites/ipv6/singlestack.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
*** Settings ***
Documentation Tests related to MicroShift running in an IPv6-only host

Resource ../../resources/common.resource
Resource ../../resources/oc.resource
Resource ../../resources/ostree-health.resource
Resource ../../resources/microshift-network.resource
Library ../../resources/libipv6.py

Suite Setup Setup
Suite Teardown Teardown

Test Tags ipv6 network


*** Variables ***
${USHIFT_HOST} ${EMPTY}
${HOSTNAME} hello-microshift.ipv6.cluster.local


*** Test Cases ***
Verify Router Serves IPv6
[Documentation] Verify router is capable of serving ipv6 traffic.
[Setup] Run Keywords
... Create Hello MicroShift Pod
... Expose Hello MicroShift Service Via Route
... Restart Router

Must Be Ipv6 ${USHIFT_HOST}
Wait Until Keyword Succeeds 10x 6s
... Access Hello Microshift Success ushift_port=${HTTP_PORT} hostname=${HOSTNAME}

DNS Entry For Route Should Resolve

[Teardown] Run Keywords
... Delete Hello MicroShift Route
... Delete Hello MicroShift Pod And Service
... Wait For Service Deletion With Timeout

Verify All Services Are Ipv6
[Documentation] Check all services are running IPv6 only

All Services Are Ipv6


*** Keywords ***
Setup
[Documentation] Test suite setup
Login MicroShift Host
Setup Suite With Namespace
Wait Until Greenboot Health Check Exited

Teardown
[Documentation] Test suite teardown
Logout MicroShift Host

Delete Hello MicroShift Route
[Documentation] Delete route for cleanup.
Oc Delete route/hello-microshift -n ${NAMESPACE}

Wait For Service Deletion With Timeout
[Documentation] Polls for service and endpoint by "app=hello-microshift" label. Fails if timeout
... expires. This check is unique to this test suite because each test here reuses the same namespace. Since
... the tests reuse the service name, a small race window exists between the teardown of one test and the setup
... of the next. This produces flakey failures when the service or endpoint names collide.
Wait Until Keyword Succeeds 30s 1s
... Network APIs With Test Label Are Gone

Expose Hello MicroShift Service Via Route
[Documentation] Expose the "hello microshift" application through the Route
Oc Expose pod hello-microshift -n ${NAMESPACE}
Oc Expose svc hello-microshift --hostname ${HOSTNAME} -n ${NAMESPACE}

Network APIs With Test Label Are Gone
[Documentation] Check for service and endpoint by "app=hello-microshift" label. Succeeds if response matches
... "No resources found in <namespace> namespace." Fail if not.
${match_string}= Catenate No resources found in ${NAMESPACE} namespace.
${match_string}= Remove String ${match_string} "
${response}= Run With Kubeconfig oc get svc,ep -l app\=hello-microshift -n ${NAMESPACE}
Should Be Equal As Strings ${match_string} ${response} strip_spaces=True

DNS Entry For Route Should Resolve
[Documentation] Resolve hello-microshift route via mDNS from the hypervisor/RF runner.
... Expects RF runner host has opened port 5353 for libvirt zone.

${result}= Run Process
... avahi-resolve-host-name ${HOSTNAME}
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 see it returned hello-microshift.cluster.local 2001:db8:ca7:ff::1522. Do think it's possible to have a race condition with another test that would also expose hello-microshift.cluster.local?

Should we check if the IP we got is indeed IPv6?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good points, did both.

... shell=True
... timeout=15s
Should Be Equal As Integers 0 ${result.rc}
Log Many ${result.stdout} ${result.stderr}
@{words}= Split String ${result.stdout}
Must Be Ipv6 ${words}[1]

Restart Router
[Documentation] Restart the router and wait for readiness again. The router is sensitive to apiserver
... downtime and might need a restart (after the apiserver is ready) to resync all the routes.
Run With Kubeconfig oc rollout restart deployment router-default -n openshift-ingress
Named Deployment Should Be Available router-default openshift-ingress 5m

All Services Are Ipv6
[Documentation] Retrieve all services and check none of them have an IPv4 family
${response}= Run With Kubeconfig oc get svc -A -o jsonpath='{.items[*].spec.ipFamilies[*]}'
Should Not Contain ${response} IPv4