Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions TAG_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ The pit tags organizes Go tests using **build tags**. These tags define when and
##### pit.daily
- Tests that should run **every day**

##### pit.harvester.daily
- Tests that should run **every day** on a harvester setup

##### pit.weekly
- Tests that should run **once per week**

Expand Down
2 changes: 1 addition & 1 deletion validation/fleet/public_gitrepo_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build validation || sanity || pit.daily
//go:build validation || sanity || pit.daily || pit.harvester.daily

package fleet

Expand Down
100 changes: 100 additions & 0 deletions validation/harvester/provisioning/cloud_provider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//go:build validation || recurring || pit.harvester.daily

package harvester

import (
"os"
"testing"

"github.com/rancher/shepherd/clients/rancher"
"github.com/rancher/shepherd/extensions/cloudcredentials"
"github.com/rancher/shepherd/extensions/defaults/providers"
"github.com/rancher/shepherd/pkg/config"
"github.com/rancher/shepherd/pkg/config/operations"
"github.com/rancher/shepherd/pkg/session"
"github.com/rancher/tests/actions/clusters"
"github.com/rancher/tests/actions/config/defaults"
"github.com/rancher/tests/actions/provisioning"
"github.com/rancher/tests/actions/provisioninginput"
"github.com/rancher/tests/actions/qase"
"github.com/rancher/tests/actions/workloads/deployment"
"github.com/rancher/tests/actions/workloads/pods"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

type HarvesterProvisioningTestSuite struct {
suite.Suite
client *rancher.Client
session *session.Session
cattleConfig map[string]any
}

func (p *HarvesterProvisioningTestSuite) TearDownSuite() {
p.session.Cleanup()
}

func (p *HarvesterProvisioningTestSuite) SetupSuite() {
testSession := session.NewSession()
p.session = testSession

client, err := rancher.NewClient("", testSession)
require.NoError(p.T(), err)

p.client = client

p.cattleConfig = config.LoadConfigFromFile(os.Getenv(config.ConfigEnvironmentKey))

p.cattleConfig, err = defaults.SetK8sDefault(client, defaults.RKE2, p.cattleConfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the k8s version configurable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, its still pulled from the config file. But if it shows up as empty, SetK8sDefault will use the latest (which is what I want in this case, but the config value is still used as 1st priority if it is there)

require.NoError(p.T(), err)
}

func (p *HarvesterProvisioningTestSuite) TestCloudProvider() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we 'h' as suite variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted p for provisioning 😄


nodeRolesDedicated := []provisioninginput.MachinePools{provisioninginput.EtcdMachinePool, provisioninginput.ControlPlaneMachinePool, provisioninginput.WorkerMachinePool}
nodeRolesDedicated[0].MachinePoolConfig.Quantity = 1
nodeRolesDedicated[1].MachinePoolConfig.Quantity = 2
nodeRolesDedicated[2].MachinePoolConfig.Quantity = 2
Comment on lines +55 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this means 1 etcd, 2 control plane and 2 worker? why not the more standard 1 etcd, 1 control plane and 2 worker?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for cloud provider, the cpi controller runs on the control plane. having 2 cp nodes is the 'production minimum' recommendation (we usually do 3etcd, 2cp, 3 workers but I'm resource limited in harvester lab)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential future enhancement to allow this to be set via config as well, but I'm fine with the hardcoded values right now due to our lab limitations.

clusterConfig := new(clusters.ClusterConfig)
operations.LoadObjectFromMap(defaults.ClusterConfigKey, p.cattleConfig, clusterConfig)
var err error

clusterConfig.Provider = providers.Harvester
clusterConfig.MachinePools = nodeRolesDedicated

provider := provisioning.CreateProvider(clusterConfig.Provider)
credentialSpec := cloudcredentials.LoadCloudCredential(string(provider.Name))
machineConfigSpec := provider.LoadMachineConfigFunc(p.cattleConfig)

logrus.Infof("Provisioning cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you use the suite approche for the logs on the tests?

suggestion: p.T().Logf("Provisioning cluster")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually use logrus for logs

cluster, err := provisioning.CreateProvisioningCluster(p.client, provider, credentialSpec, clusterConfig, machineConfigSpec, nil)
require.NoError(p.T(), err)

logrus.Infof("Verifying the cluster is ready (%s)", cluster.Name)
provisioning.VerifyClusterReady(p.T(), p.client, cluster)

logrus.Infof("Verifying cluster deployments (%s)", cluster.Name)
err = deployment.VerifyClusterDeployments(p.client, cluster)
require.NoError(p.T(), err)

logrus.Infof("Verifying cluster pods (%s)", cluster.Name)
err = pods.VerifyClusterPods(p.client, cluster)
require.NoError(p.T(), err)

logrus.Infof("Verifying cloud provider (%s)", cluster.Name)
provider.VerifyCloudProviderFunc(p.T(), p.client, cluster)

params := provisioning.GetProvisioningSchemaParams(p.client, p.cattleConfig)
err = qase.UpdateSchemaParameters("Harvester_oot", params)
if err != nil {
logrus.Warningf("Failed to upload schema parameters %s", err)
}

}

// 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 TestHarvesterProvisioningTestSuite(t *testing.T) {
suite.Run(t, new(HarvesterProvisioningTestSuite))
}
4 changes: 2 additions & 2 deletions validation/harvester/schemas/harvester_schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
custom_field:
"15": "TestRKE2ProvisioningTestSuite TestK3SProvisioningTestSuite TestRKE1ProvisioningTestSuite"
- title: "Node Driver Cloud Provider RKE2 - Loadbalancing and Storage"
description: "TestRKE2ProvisioningTestSuite TestK3SProvisioningTestSuite TestRKE1ProvisioningTestSuite"
description: "HarvesterProvisioningTestSuite"
automation: 2
steps:
- action: "Prerequisites"
Expand All @@ -50,7 +50,7 @@
expectedresult: "writing and reading file(s) in the mountpoint are successful"
position: 3
custom_field:
"15": "TestRKE2ProvisioningTestSuite TestK3SProvisioningTestSuite TestRKE1ProvisioningTestSuite"
"15": "HarvesterProvisioningTestSuite"
- title: "Custom Cluster Provisioning"
description: "TestCustomClusterRKE2ProvisioningTestSuite TestCustomClusterK3SProvisioningTestSuite TestCustomClusterRKE1ProvisioningTestSuite"
automation: 2
Expand Down
2 changes: 1 addition & 1 deletion validation/longhorn/chartinstall/installation_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build validation || pit.daily
//go:build validation || pit.daily || pit.harvester.daily

package longhorn

Expand Down
2 changes: 1 addition & 1 deletion validation/networking/connectivity/network_policy_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (validation || infra.rke2k3s || cluster.any || sanity || pit.daily) && !stress && !extended
//go:build (validation || infra.rke2k3s || cluster.any || sanity || pit.daily || pit.harvester.daily) && !stress && !extended

package connectivity

Expand Down
2 changes: 1 addition & 1 deletion validation/workloads/workload_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build (validation || infra.any || cluster.any || sanity || pit.daily) && !stress && !extended
//go:build (validation || infra.any || cluster.any || sanity || pit.daily || pit.harvester.daily) && !stress && !extended

package workloads

Expand Down