-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dualstack integration tests (#532)
- Loading branch information
1 parent
52f7707
commit 4e96859
Showing
11 changed files
with
192 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
description: "LXD profile for Canonical Kubernetes with dualstack networking" | ||
devices: | ||
eth0: | ||
name: eth0 | ||
nictype: bridged | ||
parent: LXD_DUALSTACK_NETWORK | ||
type: nic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cluster-config: | ||
network: | ||
enabled: true | ||
dns: | ||
enabled: true | ||
cluster-domain: cluster.local | ||
local-storage: | ||
enabled: true | ||
local-path: /storage/path | ||
default: false | ||
gateway: | ||
enabled: true | ||
metrics-server: | ||
enabled: true | ||
pod-cidr: 10.100.0.0/16,fd01::/108 | ||
service-cidr: 10.200.0.0/16,fd98::/108 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# Copyright 2024 Canonical, Ltd. | ||
# | ||
import logging | ||
from ipaddress import IPv4Address, IPv6Address, ip_address | ||
from pathlib import Path | ||
|
||
import pytest | ||
from test_util import config, harness, util | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.mark.node_count(1) | ||
def test_dualstack(h: harness.Harness, tmp_path: Path): | ||
snap_path = (tmp_path / "k8s.snap").as_posix() | ||
main = h.new_instance(dualstack=True) | ||
util.setup_k8s_snap(main, snap_path) | ||
|
||
bootstrap_config = (config.MANIFESTS_DIR / "bootstrap-dualstack.yaml").read_text() | ||
|
||
main.exec( | ||
["k8s", "bootstrap", "--file", "-"], | ||
input=str.encode(bootstrap_config), | ||
) | ||
util.wait_until_k8s_ready(main, [main]) | ||
|
||
dualstack_config = (config.MANIFESTS_DIR / "nginx-dualstack.yaml").read_text() | ||
|
||
# Deploy nginx with dualstack service | ||
main.exec( | ||
["k8s", "kubectl", "apply", "-f", "-"], input=str.encode(dualstack_config) | ||
) | ||
addresses = ( | ||
util.stubbornly(retries=5, delay_s=3) | ||
.on(main) | ||
.exec( | ||
[ | ||
"k8s", | ||
"kubectl", | ||
"get", | ||
"svc", | ||
"nginx-dualstack", | ||
"-o", | ||
"jsonpath='{.spec.clusterIPs[*]}'", | ||
], | ||
text=True, | ||
capture_output=True, | ||
) | ||
.stdout | ||
) | ||
|
||
for ip in addresses.split(): | ||
addr = ip_address(ip.strip("'")) | ||
if isinstance(addr, IPv6Address): | ||
address = f"http://[{str(addr)}]" | ||
elif isinstance(addr, IPv4Address): | ||
address = f"http://{str(addr)}" | ||
else: | ||
pytest.fail(f"Unknown IP address type: {addr}") | ||
|
||
# need to shell out otherwise this runs into permission errors | ||
util.stubbornly(retries=3, delay_s=1).on(main).exec( | ||
["curl", address], shell=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters