Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
r2k1 committed Oct 22, 2024
1 parent 47cbaa9 commit 5c894c2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 21 deletions.
9 changes: 6 additions & 3 deletions e2e/config/vhd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"
"testing"

"github.com/Azure/agentbaker/pkg/agent/datamodel"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
Expand All @@ -29,9 +30,10 @@ var (
Arch: "arm64",
}
VHDUbuntu2204Gen2Containerd = &Image{
Name: "2204gen2containerd",
OS: "ubuntu",
Arch: "amd64",
Name: "2204gen2containerd",
OS: "ubuntu",
Arch: "amd64",
Distro: datamodel.AKSUbuntuContainerd2404Gen2,
}
VHDAzureLinuxV2Gen2Arm64 = &Image{
Name: "AzureLinuxV2gen2arm64",
Expand Down Expand Up @@ -78,6 +80,7 @@ type Image struct {
Name string
OS string
Version string
Distro datamodel.Distro

vhd VHDResourceID
vhdOnce sync.Once
Expand Down
16 changes: 2 additions & 14 deletions e2e/node_bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/exec"
"testing"

"github.com/Azure/agentbaker/pkg/agent"
"github.com/Azure/agentbaker/pkg/agent/datamodel"
"github.com/Azure/agentbakere2e/config"
"github.com/barkimedes/go-deepcopy"
Expand Down Expand Up @@ -52,14 +53,6 @@ func Test_ubuntu2204NodeBootstrapper(t *testing.T) {
},
CSEOverride: CSENodeBootstrapper(ctx, t, cluster),
DisableCustomData: true,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"
// Check that we don't leak these secrets if they're
// set (which they mostly aren't in these scenarios).
nbc.ContainerService.Properties.CertificateProfile.ClientPrivateKey = "client cert private key"
nbc.ContainerService.Properties.ServicePrincipalProfile.Secret = "SP secret"
},
},
Tags: Tags{Scriptless: true},
})
Expand All @@ -69,12 +62,7 @@ func CSENodeBootstrapper(ctx context.Context, t *testing.T, cluster *Cluster) st
nbcAny, err := deepcopy.Anything(cluster.NodeBootstrappingConfiguration)
require.NoError(t, err)
nbc := nbcAny.(*datamodel.NodeBootstrappingConfiguration)
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"
// Check that we don't leak these secrets if they're
// set (which they mostly aren't in these scenarios).
nbc.ContainerService.Properties.CertificateProfile.ClientPrivateKey = "client cert private key"
nbc.ContainerService.Properties.ServicePrincipalProfile.Secret = "SP secret"
agent.ValidateAndSetLinuxNodeBootstrappingConfiguration(nbc)

configContent := nbcToNbcContractV1(nbc)

Expand Down
2 changes: 1 addition & 1 deletion e2e/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func Test_ubuntu2204ScriptlessInstaller(t *testing.T) {
LiveVMValidators: []*LiveVMValidator{
FileHasContentsValidator("/var/log/azure/node-bootstrapper.log", "node-bootstrapper finished successfully"),
},
// TODO: add support for nbccontract instead
// TODO: replace it with nbccontract
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"
Expand Down
3 changes: 2 additions & 1 deletion e2e/vmss.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func createVMSS(ctx context.Context, t *testing.T, vmssName string, opts *scenar
ab, err := agent.NewAgentBaker()
require.NoError(t, err)
if opts.scenario.Tags.Scriptless {
nodeBootstrapping, err = ab.GetNodeBootstrappingForScriptless(ctx, nbcToNbcContractV1(opts.nbc), opts.scenario.Config.Distro, datamodel.AzurePublicCloud)
agent.ValidateAndSetLinuxNodeBootstrappingConfiguration(opts.nbc)
nodeBootstrapping, err = ab.GetNodeBootstrappingForScriptless(ctx, nbcToNbcContractV1(opts.nbc), opts.scenario.VHD.Distro, datamodel.AzurePublicCloud)
require.NoError(t, err)
} else {
nodeBootstrapping, err = ab.GetNodeBootstrapping(ctx, opts.nbc)
Expand Down
3 changes: 2 additions & 1 deletion pkg/agent/baker.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ func normalizeResourceGroupNameForLabel(resourceGroupName string) string {
return truncated
}

func validateAndSetLinuxNodeBootstrappingConfiguration(config *datamodel.NodeBootstrappingConfiguration) {
// ValidateAndSetLinuxNodeBootstrappingConfiguration is exported only for temporary usage in e2e testing of new config.
func ValidateAndSetLinuxNodeBootstrappingConfiguration(config *datamodel.NodeBootstrappingConfiguration) {
if config.KubeletConfig == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/bakerapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (agentBaker *agentBakerImpl) GetNodeBootstrapping(ctx context.Context, conf
if config.AgentPoolProfile.IsWindows() {
validateAndSetWindowsNodeBootstrappingConfiguration(config)
} else {
validateAndSetLinuxNodeBootstrappingConfiguration(config)
ValidateAndSetLinuxNodeBootstrappingConfiguration(config)
}

templateGenerator := InitializeTemplateGenerator()
Expand Down

0 comments on commit 5c894c2

Please sign in to comment.