-
Notifications
You must be signed in to change notification settings - Fork 27
add new tag pit.harvester.daily for recurring harvester runs
#463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
40cc425
4a58b3c
3cc7323
3110e68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the k8s version configurable?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could we 'h' as suite variable?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.