Skip to content

Commit

Permalink
Merge pull request rancher#45121 from slickwarren/cwarren/v2.8/vspher…
Browse files Browse the repository at this point in the history
…e-cpi-csi

[2.8] add vsphere chart validation to automation framework
  • Loading branch information
slickwarren authored Apr 15, 2024
2 parents 84afb4e + ffa6adb commit a52d992
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 61 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ require (
github.com/containers/image/v5 v5.25.0
github.com/google/gnostic-models v0.6.8
github.com/rancher/rancher/pkg/apis v0.0.0-20240213233515-935d309ebad4
github.com/rancher/shepherd v0.0.0-20240408151625-d0c3b8dbe5dd
github.com/rancher/shepherd v0.0.0-20240412143253-50c4247b5902
go.qase.io/client v0.0.0-20231114201952-65195ec001fa
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1641,8 +1641,8 @@ github.com/rancher/remotedialer v0.3.0 h1:y1EO8JCsgZo0RcqTUp6U8FXcBAv27R+TLnWRcp
github.com/rancher/remotedialer v0.3.0/go.mod h1:BwwztuvViX2JrLLUwDlsYt5DiyUwHLlzynRwkZLAY0Q=
github.com/rancher/rke v1.5.9-rc1 h1:xlXoYDK9fWynUtKNP4WOiFI6ufKIBxjK7FVqk96U76A=
github.com/rancher/rke v1.5.9-rc1/go.mod h1:vojhOf8U8VCmw7y17OENWXSIfEFPEbXCMQcmI7xN7i8=
github.com/rancher/shepherd v0.0.0-20240408151625-d0c3b8dbe5dd h1:Nog4ViMD04zg6GP+5IvsthOIWqps7m6mdMnhIwWkPxA=
github.com/rancher/shepherd v0.0.0-20240408151625-d0c3b8dbe5dd/go.mod h1:LNI7nH1BptYMvJmuqsLgmkMytGBBTpW4jk4vAHCxfF4=
github.com/rancher/shepherd v0.0.0-20240412143253-50c4247b5902 h1:Bs+tXgtduRRtr50SFJ1lBgLATmj4xjc6RjuS2m47Iyg=
github.com/rancher/shepherd v0.0.0-20240412143253-50c4247b5902/go.mod h1:LNI7nH1BptYMvJmuqsLgmkMytGBBTpW4jk4vAHCxfF4=
github.com/rancher/steve v0.0.0-20240305150728-3943409601f1 h1:6wNYy3q9jget45syTN6K2uOLSYaptLYCHscY2WRmhDI=
github.com/rancher/steve v0.0.0-20240305150728-3943409601f1/go.mod h1:o4vLBzMTKbHHhIiAcbgOiaN3aK1vIjL6ZTgaGxQYpsY=
github.com/rancher/system-upgrade-controller/pkg/apis v0.0.0-20210727200656-10b094e30007 h1:ru+mqGnxMmKeU0Q3XIDxkARvInDIqT1hH2amTcsjxI4=
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/integration/catalogv2/rancher_managed_charts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,11 @@ func (w *RancherManagedChartsTest) TestServeIcons() {
w.Assert().Equal("bundled", systemCatalogUpdated.Value)

// Fetch one icon with https:// scheme, it should return an empty object (i.e length of image equals 0) with nil error
imgLength, err := w.catalogClient.FetchChartIcon(smallForkClusterRepoName, "fleet", "102.0.0+up0.6.0")
imgLength, err := w.catalogClient.FetchChartIcon(smallForkClusterRepoName, "fleet")
w.Require().NoError(err)
w.Assert().Equal(0, imgLength)

imgLength, err = w.catalogClient.FetchChartIcon(smallForkClusterRepoName, "rancher-cis-benchmark", "4.0.0")
imgLength, err = w.catalogClient.FetchChartIcon(smallForkClusterRepoName, "rancher-cis-benchmark")
w.Require().NoError(err)
w.Assert().Greater(imgLength, 0)

Expand Down
3 changes: 2 additions & 1 deletion tests/v2/validation/provisioning/k3s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ harvesterMachineConfig":
vmwarevsphereMachineConfigs:
datacenter: "/<datacenter>" #required
hostSystem: "/<datacenter>/path-to-host" #required
datastore: "/<datacenter>/path-to-datastore" #required
datastoreURL: "/datastore.URL" #required
datastore: ""/<datacenter>/path-to-datastore" #required
folder: "/<datacenter>/path-to-vm-folder" #required
pool: "/<datacenter>/path-to-resource-pool" #required
vmwarevsphereMachineConfig:
Expand Down
280 changes: 228 additions & 52 deletions tests/v2/validation/provisioning/permutations/permutations.go

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tests/v2/validation/provisioning/rke1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ provisioningInput:
snapshot: false
```


## Cloud Provider
Cloud Provider enables additional options through the cloud provider, like cloud persistent storage or cloud provisioned load balancers.

Names of cloud provider options are typically controlled by rancher product. Hence the discrepancy in rke2 vs. rke1 AWS in-tree and out-of-tree options.
To use automation with a cloud provider, simply enter one of the following options in the `cloudProvider` field in the config.

### RKE1 Cloud Provider Options
* external-aws
* aws
* rancher-vsphere


## NodeTemplateConfigs
RKE1 specifically needs a node template config to run properly. These are the inputs needed for the different node providers.
Top level node template config entries can be set. The top level nodeTemplate is optional, and is not need for the different node
Expand Down Expand Up @@ -209,6 +222,7 @@ vmwarevsphereNodeConfig:
creationType: ""
datacenter: ""
datastore: ""
datastoreURL: ""
datastoreCluster: ""
diskSize: "20000"
folder: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package rke1

import (
"slices"
"testing"

"github.com/rancher/rancher/tests/v2/validation/provisioning/permutations"
Expand Down Expand Up @@ -84,6 +85,11 @@ func (r *RKE1CloudProviderTestSuite) TestAWSCloudProviderRKE1Cluster() {
}{
{"OutOfTree" + provisioninginput.StandardClientName.String(), nodeRolesDedicated, r.standardUserClient, r.client.Flags.GetValue(environmentflag.Long)},
}

if !slices.Contains(r.provisioningConfig.Providers, "aws") {
r.T().Skip("AWS Cloud Provider test requires access to aws.")
}

for _, tt := range tests {
if !tt.runFlag {
r.T().Logf("SKIPPED")
Expand All @@ -96,6 +102,37 @@ func (r *RKE1CloudProviderTestSuite) TestAWSCloudProviderRKE1Cluster() {
}
}

func (r *RKE1CloudProviderTestSuite) TestVsphereCloudProviderRKE1Cluster() {
nodeRolesDedicated := []provisioninginput.NodePools{provisioninginput.EtcdNodePool, provisioninginput.ControlPlaneNodePool, provisioninginput.WorkerNodePool}
nodeRolesDedicated[0].NodeRoles.Quantity = 3
nodeRolesDedicated[1].NodeRoles.Quantity = 2
nodeRolesDedicated[2].NodeRoles.Quantity = 2

tests := []struct {
name string
nodePools []provisioninginput.NodePools
client *rancher.Client
runFlag bool
}{
{"OutOfTree" + provisioninginput.StandardClientName.String(), nodeRolesDedicated, r.standardUserClient, r.client.Flags.GetValue(environmentflag.Long)},
}

if !slices.Contains(r.provisioningConfig.Providers, "vsphere") {
r.T().Skip("Vsphere Cloud Provider test requires access to Vsphere.")
}

for _, tt := range tests {
if !tt.runFlag {
r.T().Logf("SKIPPED")
continue
}
provisioningConfig := *r.provisioningConfig
provisioningConfig.CloudProvider = "rancher-vsphere"
provisioningConfig.NodePools = tt.nodePools
permutations.RunTestPermutations(&r.Suite, tt.name, tt.client, &provisioningConfig, permutations.RKE1ProvisionCluster, nil, nil)
}
}

// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestRKE1CloudProviderTestSuite(t *testing.T) {
Expand Down
11 changes: 8 additions & 3 deletions tests/v2/validation/provisioning/rke2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ vmwarevsphereCredentials:
```
## Cloud Provider
Cloud Provider enables additional options such as load-balancers and storage devices to be provisioned through your cluster
available options:
### AWS
Cloud Provider enables additional options through the cloud provider, like cloud persistent storage or cloud provisioned load balancers.
Names of cloud provider options are typically controlled by rancher product. Hence the discrepancy in rke2 vs. rke1 AWS in-tree and out-of-tree options.
To use automation with a cloud provider, simply enter one of the following options in the `cloudProvider` field in the config.

### RKE2 Cloud Provider Options
* `aws-in-tree` uses the in-tree provider for aws -- **Deprecated on kubernetes 1.26 and below**
* `aws` uses the out-of-tree provider for aws. Built in logic to the automation will be applied to the cluster that applies the correct configuration for the out-of-tree charts to be installed. Supported on kubernetes 1.22+
* rancher-vsphere

## Machine RKE2 Config
Machine RKE2 config is the final piece needed for the config to run RKE2 provisioning tests.
Expand Down Expand Up @@ -233,6 +237,7 @@ vmwarevsphereMachineConfigs:
datacenter: "/<datacenter>" #required
hostSystem: "/<datacenter>/path-to-host" #required
datastore: "/<datacenter>/path-to-datastore" #required
datastoreURL: "ds:///<url>"
folder: "/<datacenter>/path-to-vm-folder" #required
pool: "/<datacenter>/path-to-resource-pool" #required
vmwarevsphereMachineConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package rke2

import (
"slices"
"testing"

"github.com/rancher/rancher/tests/v2/validation/provisioning/permutations"
Expand Down Expand Up @@ -83,18 +84,55 @@ func (r *RKE2CloudProviderTestSuite) TestAWSCloudProviderCluster() {
{"OutOfTree" + provisioninginput.StandardClientName.String(), nodeRolesDedicated, r.standardUserClient, r.client.Flags.GetValue(environmentflag.Long)},
}

if !slices.Contains(r.provisioningConfig.Providers, "aws") {
r.T().Skip("AWS Cloud Provider test requires access to aws.")
}

for _, tt := range tests {
if !tt.runFlag {
r.T().Logf("SKIPPED")
continue
}

provisioningConfig := *r.provisioningConfig
provisioningConfig.CloudProvider = "aws"
provisioningConfig.MachinePools = tt.machinePools
permutations.RunTestPermutations(&r.Suite, tt.name, tt.client, &provisioningConfig, permutations.RKE2ProvisionCluster, nil, nil)
}
}

func (r *RKE2CloudProviderTestSuite) TestVsphereCloudProviderCluster() {
nodeRolesDedicated := []provisioninginput.MachinePools{provisioninginput.EtcdMachinePool, provisioninginput.ControlPlaneMachinePool, provisioninginput.WorkerMachinePool}
nodeRolesDedicated[0].MachinePoolConfig.Quantity = 3
nodeRolesDedicated[1].MachinePoolConfig.Quantity = 2
nodeRolesDedicated[2].MachinePoolConfig.Quantity = 2

tests := []struct {
name string
machinePools []provisioninginput.MachinePools
client *rancher.Client
runFlag bool
}{
{"OutOfTree" + provisioninginput.StandardClientName.String(), nodeRolesDedicated, r.standardUserClient, r.client.Flags.GetValue(environmentflag.Long)},
}

if !slices.Contains(r.provisioningConfig.Providers, "vsphere") {
r.T().Skip("Vsphere Cloud Provider test requires access to vsphere.")
}

for _, tt := range tests {
if !tt.runFlag {
r.T().Logf("SKIPPED")
continue
}

provisioningConfig := *r.provisioningConfig
provisioningConfig.CloudProvider = "rancher-vsphere"
provisioningConfig.MachinePools = tt.machinePools
permutations.RunTestPermutations(&r.Suite, tt.name, tt.client, &provisioningConfig, permutations.RKE2ProvisionCluster, nil, nil)
}
}

// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestRKE2CloudProviderTestSuite(t *testing.T) {
Expand Down

0 comments on commit a52d992

Please sign in to comment.