-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathscenario_localdns_hosts_test.go
More file actions
85 lines (79 loc) · 3.17 KB
/
scenario_localdns_hosts_test.go
File metadata and controls
85 lines (79 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package e2e
import (
"testing"
aksnodeconfigv1 "github.com/Azure/agentbaker/aks-node-controller/pkg/gen/aksnodeconfig/v1"
"github.com/Azure/agentbaker/e2e/config"
"github.com/Azure/agentbaker/pkg/agent/datamodel"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Test_LocalDNSHostsPlugin tests the localdns hosts plugin across all supported distros
// on the legacy (bash CSE) bootstrap path.
// Hosts plugin validators (IP match, Corefile, hosts file) run automatically
// via ValidateCommonLinux when EnableHostsPlugin is set; this test does not assert
// on DNS flags such as AA/RA.
//
// Run a single distro with: go test -run "Test_LocalDNSHostsPlugin/AzureLinuxV3" -v
func Test_LocalDNSHostsPlugin(t *testing.T) {
tests := []struct {
name string
vhd *config.Image
vmConfigMutator func(*armcompute.VirtualMachineScaleSet)
}{
{name: "Ubuntu2204", vhd: config.VHDUbuntu2204Gen2Containerd},
{name: "Ubuntu2404", vhd: config.VHDUbuntu2404Gen2Containerd},
{name: "AzureLinuxV3", vhd: config.VHDAzureLinuxV3Gen2},
{name: "ACL", vhd: config.VHDACLGen2TL, vmConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
vmss.Properties = addTrustedLaunchToVMSS(vmss.Properties)
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Tests that localdns hosts plugin works correctly on " + tt.name,
Config: Config{
Cluster: ClusterKubenet,
VHD: tt.vhd,
BootstrapConfigMutator: func(_ *Cluster, nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.AgentPoolProfile.LocalDNSProfile.EnableHostsPlugin = true
},
VMConfigMutator: tt.vmConfigMutator,
},
})
})
}
}
// Test_LocalDNSHostsPlugin_Scriptless tests the localdns hosts plugin across all supported distros
// on the scriptless (aks-node-controller) bootstrap path.
// The base AKSNodeConfig from nbcToAKSNodeConfigV1 already includes a full LocalDnsProfile with
// DNS overrides, so the mutator only needs to enable the hosts plugin.
//
// Run a single distro with: go test -run "Test_LocalDNSHostsPlugin_Scriptless/Ubuntu2204" -v
func Test_LocalDNSHostsPlugin_Scriptless(t *testing.T) {
tests := []struct {
name string
vhd *config.Image
vmConfigMutator func(*armcompute.VirtualMachineScaleSet)
}{
{name: "Ubuntu2204", vhd: config.VHDUbuntu2204Gen2Containerd},
{name: "Ubuntu2404", vhd: config.VHDUbuntu2404Gen2Containerd},
{name: "AzureLinuxV3", vhd: config.VHDAzureLinuxV3Gen2},
{name: "ACL", vhd: config.VHDACLGen2TL, vmConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
vmss.Properties = addTrustedLaunchToVMSS(vmss.Properties)
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Tests that localdns hosts plugin works correctly on " + tt.name + " (scriptless)",
Config: Config{
Cluster: ClusterKubenet,
VHD: tt.vhd,
VMConfigMutator: tt.vmConfigMutator,
AKSNodeConfigMutator: func(_ *Cluster, config *aksnodeconfigv1.Configuration) {
config.LocalDnsProfile.EnableHostsPlugin = true
},
},
})
})
}
}