Skip to content

Commit 38aec12

Browse files
committed
rke2 package updates
update update Add more tests Update custom and parallelism update custom cluster agent/ace tests
1 parent 42c7bc5 commit 38aec12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1173
-689
lines changed

actions/nodes/ec2/ec2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
)
2727

2828
// CreateNodes creates `quantityPerPool[n]` number of ec2 instances
29-
func CreateNodes(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32) (ec2Nodes []*nodes.Node, err error) {
29+
func CreateNodes(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32, ec2Configs *rancherEc2.AWSEC2Configs) (ec2Nodes []*nodes.Node, err error) {
3030
ec2Client, err := client.GetEC2Client()
3131
if err != nil {
3232
return nil, err
@@ -36,7 +36,7 @@ func CreateNodes(client *rancher.Client, rolesPerPool []string, quantityPerPool
3636
reservationConfigs := []*rancherEc2.AWSEC2Config{}
3737
// provisioning instances in reverse order to allow windows instances time to become ready
3838
for i := len(quantityPerPool) - 1; i >= 0; i-- {
39-
config := MatchRoleToConfig(rolesPerPool[i], ec2Client.ClientConfig.AWSEC2Config)
39+
config := MatchRoleToConfig(rolesPerPool[i], ec2Configs.AWSEC2Config)
4040
if config == nil {
4141
return nil, errors.New("No matching nodesAndRole for AWSEC2Config with role:" + rolesPerPool[i])
4242
}

actions/provisioning/creates.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/sirupsen/logrus"
1212

1313
"github.com/rancher/shepherd/clients/corral"
14+
"github.com/rancher/shepherd/clients/ec2"
1415
"github.com/rancher/shepherd/clients/rancher"
1516

1617
apiv1 "github.com/rancher/rancher/pkg/apis/provisioning.cattle.io/v1"
@@ -184,7 +185,7 @@ func CreateProvisioningCluster(client *rancher.Client, provider Provider, creden
184185
}
185186

186187
// CreateProvisioningCustomCluster provisions a non-rke1 cluster using a 3rd party client for its nodes, then runs verify checks
187-
func CreateProvisioningCustomCluster(client *rancher.Client, externalNodeProvider *ExternalNodeProvider, clustersConfig *clusters.ClusterConfig) (*v1.SteveAPIObject, error) {
188+
func CreateProvisioningCustomCluster(client *rancher.Client, externalNodeProvider *ExternalNodeProvider, clustersConfig *clusters.ClusterConfig, ec2Configs *ec2.AWSEC2Configs) (*v1.SteveAPIObject, error) {
188189
setLogrusFormatter()
189190
rolesPerNode := []string{}
190191
quantityPerPool := []int32{}
@@ -221,7 +222,7 @@ func CreateProvisioningCustomCluster(client *rancher.Client, externalNodeProvide
221222
}
222223
}
223224

224-
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool)
225+
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool, ec2Configs)
225226
if err != nil {
226227
return nil, err
227228
}
@@ -429,7 +430,7 @@ func CreateProvisioningRKE1CustomCluster(client *rancher.Client, externalNodePro
429430
}
430431
}
431432

432-
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool)
433+
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool, nil)
433434
if err != nil {
434435
return nil, nil, err
435436
}

actions/provisioning/nodeproviders.go

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ const (
1717
fromConfig = "config"
1818
)
1919

20-
type NodeCreationFunc func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32) (nodes []*nodes.Node, err error)
20+
type NodeCreationFunc func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32, ec2Configs *rancherEc2.AWSEC2Configs) (nodes []*nodes.Node, err error)
2121
type NodeDeletionFunc func(client *rancher.Client, nodes []*nodes.Node) error
2222
type CustomOSNamesFunc func(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs) ([]string, error)
23+
type GetCustomWindowsPools func(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs) []rancherEc2.AWSEC2Config
2324

2425
type ExternalNodeProvider struct {
25-
Name string
26-
NodeCreationFunc NodeCreationFunc
27-
NodeDeletionFunc NodeDeletionFunc
28-
GetOSNamesFunc CustomOSNamesFunc
26+
Name string
27+
NodeCreationFunc NodeCreationFunc
28+
NodeDeletionFunc NodeDeletionFunc
29+
GetOSNamesFunc CustomOSNamesFunc
30+
GetWindowsPoolsFunc GetCustomWindowsPools
2931
}
3032

3133
// ExternalNodeProviderSetup is a helper function that setups an ExternalNodeProvider object is a wrapper
@@ -34,15 +36,16 @@ func ExternalNodeProviderSetup(providerType string) ExternalNodeProvider {
3436
switch providerType {
3537
case ec2NodeProviderName:
3638
return ExternalNodeProvider{
37-
Name: providerType,
38-
NodeCreationFunc: ec2.CreateNodes,
39-
NodeDeletionFunc: ec2.DeleteNodes,
40-
GetOSNamesFunc: GetAWSOSNames,
39+
Name: providerType,
40+
NodeCreationFunc: ec2.CreateNodes,
41+
NodeDeletionFunc: ec2.DeleteNodes,
42+
GetOSNamesFunc: GetAWSOSNames,
43+
GetWindowsPoolsFunc: GetWindowsPools,
4144
}
4245
case fromConfig:
4346
return ExternalNodeProvider{
4447
Name: providerType,
45-
NodeCreationFunc: func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32) (nodesList []*nodes.Node, err error) {
48+
NodeCreationFunc: func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32, ec2Configs *rancherEc2.AWSEC2Configs) (nodesList []*nodes.Node, err error) {
4649
var nodeConfig nodes.ExternalNodeConfig
4750
config.LoadConfig(nodes.ExternalNodeConfigConfigurationFileKey, &nodeConfig)
4851

@@ -91,3 +94,14 @@ func GetAWSOSNames(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs
9194

9295
return osNames, nil
9396
}
97+
98+
func GetWindowsPools(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs) []rancherEc2.AWSEC2Config {
99+
var windowsConfigs []rancherEc2.AWSEC2Config
100+
for _, machineConfig := range customConfig.AWSEC2Config {
101+
if slices.Contains(machineConfig.Roles, "windows") {
102+
windowsConfigs = append(windowsConfigs, machineConfig)
103+
}
104+
}
105+
106+
return windowsConfigs
107+
}

actions/provisioning/permutations/permutations.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"strings"
55

66
"github.com/rancher/shepherd/clients/corral"
7+
"github.com/rancher/shepherd/clients/ec2"
78
"github.com/rancher/shepherd/clients/rancher"
89
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
910
steveV1 "github.com/rancher/shepherd/clients/rancher/v1"
1011
"github.com/rancher/shepherd/extensions/cloudcredentials"
12+
"github.com/rancher/shepherd/pkg/config"
1113
"github.com/rancher/shepherd/pkg/session"
1214
"github.com/rancher/tests/actions/cloudprovider"
1315
"github.com/rancher/tests/actions/clusters"
@@ -103,7 +105,10 @@ func RunTestPermutations(s *suite.Suite, testNamePrefix string, client *rancher.
103105
case RKE2CustomCluster, K3SCustomCluster:
104106
testClusterConfig.KubernetesVersion = kubeVersion
105107

106-
clusterObject, err = provisioning.CreateProvisioningCustomCluster(client, customProvider, testClusterConfig)
108+
awsEC2Configs := new(ec2.AWSEC2Configs)
109+
config.LoadConfig(ec2.ConfigurationFileKey, awsEC2Configs)
110+
111+
clusterObject, err = provisioning.CreateProvisioningCustomCluster(client, customProvider, testClusterConfig, awsEC2Configs)
107112
reports.TimeoutClusterReport(clusterObject, err)
108113
require.NoError(s.T(), err)
109114

results.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites tests="1" failures="1" errors="0" time="24.779711">
3+
<testsuite tests="1" failures="1" time="13.490000" name="github.com/rancher/tests/validation/certificates/rke2k3s" timestamp="2025-07-29T15:38:22-05:00">
4+
<properties>
5+
<property name="go.version" value="go1.24.2 darwin/arm64"></property>
6+
</properties>
7+
<testcase classname="github.com/rancher/tests/validation/certificates/rke2k3s" name="TestCertRotationTestSuite" time="12.360000">
8+
<failure message="Failed" type="">=== RUN TestCertRotationTestSuite&#xA;time=&#34;2025-07-29T15:38:46-05:00&#34; level=info msg=&#34;default rke2 kubernetes version is: v1.32.6+rke2r1&#34;&#xA;time=&#34;2025-07-29T15:38:46-05:00&#34; level=info msg=&#34;no version found in kubernetesVersions; default rke2 kubernetes version v1.32.6+rke2r1 will be used: [v1.32.6+rke2r1]&#34;&#xA; providers.go:102: test panicked: Provider: not found&#xA; goroutine 24 [running]:&#xA; runtime/debug.Stack()&#xA; &#x9;/Users/sgartner/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:26 +0x64&#xA; github.com/stretchr/testify/suite.failOnPanic(0x1400060a540, {0x107726d80, 0x140008014a0})&#xA; &#x9;/Users/sgartner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:89 +0x38&#xA; github.com/stretchr/testify/suite.recoverAndFailOnPanic(0x1400060a540)&#xA; &#x9;/Users/sgartner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:83 +0x40&#xA; panic({0x107726d80?, 0x140008014a0?})&#xA; &#x9;/Users/sgartner/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:792 +0x124&#xA; github.com/rancher/tests/actions/provisioning.CreateProvider({0x0, 0x0})&#xA; &#x9;/Users/sgartner/go/src/github.com/susesgartner/tests/actions/provisioning/providers.go:102 +0x580&#xA; github.com/rancher/tests/validation/provisioning/resources/provisioncluster.ProvisionRKE2K3SCluster(0x1400060a540, 0x14000b933e0, {0x106e3dc1e?, 0x1076842e0?}, 0x140011e9760, 0x140009f5180, 0x0?, 0x0?)&#xA; &#x9;/Users/sgartner/go/src/github.com/susesgartner/tests/validation/provisioning/resources/provisioncluster/provision_cluster.go:51 +0x338&#xA; github.com/rancher/tests/validation/certificates/rke2k3s.(*CertRotationTestSuite).SetupSuite(0x1400024c400)&#xA; &#x9;/Users/sgartner/go/src/github.com/susesgartner/tests/validation/certificates/rke2k3s/cert_rotation_test.go:75 +0x39c&#xA; github.com/stretchr/testify/suite.Run(0x1400060a540, {0x107fa1cd0, 0x1400024c400})&#xA; &#x9;/Users/sgartner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:157 +0x5a4&#xA; github.com/rancher/tests/validation/certificates/rke2k3s.TestCertRotationTestSuite(0x1400060a540)&#xA; &#x9;/Users/sgartner/go/src/github.com/susesgartner/tests/validation/certificates/rke2k3s/cert_rotation_test.go:103 +0x3c&#xA; testing.tRunner(0x1400060a540, 0x107f73520)&#xA; &#x9;/Users/sgartner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1792 +0xe4&#xA; created by testing.(*T).Run in goroutine 1&#xA; &#x9;/Users/sgartner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1851 +0x374&#xA;--- FAIL: TestCertRotationTestSuite (12.36s)&#xA;</failure>
9+
</testcase>
10+
</testsuite>
11+
</testsuites>

validation/certificates/rke2k3s/cert_rotation_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/extensions/defaults/stevetypes"
@@ -55,6 +56,9 @@ func (c *CertRotationTestSuite) SetupSuite() {
5556
k3sClusterConfig := new(clusters.ClusterConfig)
5657
operations.LoadObjectFromMap(defaults.ClusterConfigKey, c.cattleConfig, k3sClusterConfig)
5758

59+
awsEC2Configs := new(ec2.AWSEC2Configs)
60+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, c.cattleConfig, awsEC2Configs)
61+
5862
nodeRolesStandard := []provisioninginput.MachinePools{
5963
provisioninginput.EtcdMachinePool,
6064
provisioninginput.ControlPlaneMachinePool,
@@ -68,10 +72,10 @@ func (c *CertRotationTestSuite) SetupSuite() {
6872
rke2ClusterConfig.MachinePools = nodeRolesStandard
6973
k3sClusterConfig.MachinePools = nodeRolesStandard
7074

71-
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, true, false)
75+
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, awsEC2Configs, true, false)
7276
require.NoError(c.T(), err)
7377

74-
c.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, true, false)
78+
c.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, awsEC2Configs, true, false)
7579
require.NoError(c.T(), err)
7680

7781
}

validation/certificates/rke2k3s/cert_rotation_wins_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/extensions/defaults/stevetypes"
@@ -51,6 +52,9 @@ func (c *CertRotationWindowsTestSuite) SetupSuite() {
5152
clusterConfig := new(clusters.ClusterConfig)
5253
operations.LoadObjectFromMap(defaults.ClusterConfigKey, c.cattleConfig, clusterConfig)
5354

55+
awsEC2Configs := new(ec2.AWSEC2Configs)
56+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, c.cattleConfig, awsEC2Configs)
57+
5458
if clusterConfig.Provider != "vsphere" {
5559
c.T().Skip("Test requires vSphere provider")
5660
}
@@ -69,7 +73,7 @@ func (c *CertRotationWindowsTestSuite) SetupSuite() {
6973

7074
clusterConfig.MachinePools = nodeRolesStandard
7175

72-
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), clusterConfig, true, false)
76+
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), clusterConfig, awsEC2Configs, true, false)
7377
require.NoError(c.T(), err)
7478
}
7579

validation/charts/backup_restore/backup_restore.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/rancher/tests/actions/provisioning"
2121
"github.com/rancher/tests/actions/provisioninginput"
2222

23+
"github.com/rancher/shepherd/clients/ec2"
2324
"github.com/rancher/shepherd/clients/rancher"
2425
shepCharts "github.com/rancher/shepherd/extensions/charts"
2526
"github.com/rancher/shepherd/extensions/users"
@@ -297,7 +298,10 @@ func createRKE2dsCluster(t *testing.T, client *rancher.Client) (*v1.SteveAPIObje
297298
}
298299
testClusterConfig.MachinePools = nodeAndRoles
299300
testClusterConfig.KubernetesVersion = provisioningConfig.RKE2KubernetesVersions[0]
300-
steveObject, err := provisioning.CreateProvisioningCustomCluster(client, &externalNodeProvider, testClusterConfig)
301+
302+
awsEC2Configs := new(ec2.AWSEC2Configs)
303+
config.LoadConfig(ec2.ConfigurationFileKey, awsEC2Configs)
304+
steveObject, err := provisioning.CreateProvisioningCustomCluster(client, &externalNodeProvider, testClusterConfig, awsEC2Configs)
301305

302306
if err != nil {
303307
return nil, nil, err

validation/deleting/rke2k3s/delete_cluster_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/pkg/config"
@@ -54,6 +55,9 @@ func (d *DeleteClusterTestSuite) SetupSuite() {
5455
k3sClusterConfig := new(clusters.ClusterConfig)
5556
operations.LoadObjectFromMap(defaults.ClusterConfigKey, d.cattleConfig, k3sClusterConfig)
5657

58+
awsEC2Configs := new(ec2.AWSEC2Configs)
59+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, d.cattleConfig, awsEC2Configs)
60+
5761
nodeRolesStandard := []provisioninginput.MachinePools{
5862
provisioninginput.EtcdMachinePool,
5963
provisioninginput.ControlPlaneMachinePool,
@@ -67,10 +71,10 @@ func (d *DeleteClusterTestSuite) SetupSuite() {
6771
rke2ClusterConfig.MachinePools = nodeRolesStandard
6872
k3sClusterConfig.MachinePools = nodeRolesStandard
6973

70-
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, true, false)
74+
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, awsEC2Configs, true, false)
7175
require.NoError(d.T(), err)
7276

73-
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, true, false)
77+
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, awsEC2Configs, true, false)
7478
require.NoError(d.T(), err)
7579
}
7680

validation/deleting/rke2k3s/delete_init_machine_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/pkg/config"
@@ -53,6 +54,9 @@ func (d *DeleteInitMachineTestSuite) SetupSuite() {
5354
k3sClusterConfig := new(clusters.ClusterConfig)
5455
operations.LoadObjectFromMap(defaults.ClusterConfigKey, d.cattleConfig, k3sClusterConfig)
5556

57+
awsEC2Configs := new(ec2.AWSEC2Configs)
58+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, d.cattleConfig, awsEC2Configs)
59+
5660
nodeRolesStandard := []provisioninginput.MachinePools{
5761
provisioninginput.EtcdMachinePool,
5862
provisioninginput.ControlPlaneMachinePool,
@@ -66,10 +70,10 @@ func (d *DeleteInitMachineTestSuite) SetupSuite() {
6670
rke2ClusterConfig.MachinePools = nodeRolesStandard
6771
k3sClusterConfig.MachinePools = nodeRolesStandard
6872

69-
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, true, false)
73+
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, awsEC2Configs, true, false)
7074
require.NoError(d.T(), err)
7175

72-
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, true, false)
76+
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, awsEC2Configs, true, false)
7377
require.NoError(d.T(), err)
7478
}
7579

0 commit comments

Comments
 (0)