Skip to content

Commit

Permalink
Merge pull request rancher#46586 from lscalabrini01/qa-issue-1443-tes…
Browse files Browse the repository at this point in the history
…t_wl_daemonset-main

<main> Convert test_wl_deamonset test to go
  • Loading branch information
lscalabrini01 authored Aug 14, 2024
2 parents b6023c4 + fe3ac95 commit a9946d2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tests/v2/actions/workloads/deamonset/deamonset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package deamonset

import (
"github.com/rancher/rancher/tests/v2/actions/workloads/deployment"
"github.com/rancher/shepherd/clients/rancher"
"github.com/rancher/shepherd/extensions/charts"
"github.com/rancher/shepherd/extensions/workloads"
appv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// CreateDeamonset is a helper to create a deamonset
func CreateDeamonset(client *rancher.Client, clusterID, namespaceName string, replicaCount int, secretName, configMapName string, useEnvVars, useVolumes bool) (*appv1.DaemonSet, error) {
deploymentTemplate, err := deployment.CreateDeployment(client, clusterID, namespaceName, replicaCount, secretName, configMapName, useEnvVars, useVolumes)
if err != nil {
return nil, err
}

createdDaemonset := workloads.NewDaemonSetTemplate(deploymentTemplate.Name, namespaceName, deploymentTemplate.Spec.Template, true, nil)

err = charts.WatchAndWaitDaemonSets(client, clusterID, namespaceName, metav1.ListOptions{
FieldSelector: "metadata.name=" + createdDaemonset.Name,
})

return createdDaemonset, err
}
12 changes: 12 additions & 0 deletions tests/v2/validation/workloads/workload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

projectsapi "github.com/rancher/rancher/tests/v2/actions/projects"
"github.com/rancher/rancher/tests/v2/actions/workloads/deamonset"
deployment "github.com/rancher/rancher/tests/v2/actions/workloads/deployment"
"github.com/rancher/rancher/tests/v2/actions/workloads/pods"
"github.com/rancher/shepherd/clients/rancher"
Expand Down Expand Up @@ -94,6 +95,17 @@ func (w *WorkloadTestSuite) TestWorkloadSideKick() {
require.Equal(w.T(), 2, countRunning)
}

func (w *WorkloadTestSuite) TestWorkloadDaemonSet() {
subSession := w.session.NewSession()
defer subSession.Cleanup()

_, namespace, err := projectsapi.CreateProjectAndNamespace(w.client, w.cluster.ID)
require.NoError(w.T(), err)

_, err = deamonset.CreateDeamonset(w.client, w.cluster.ID, namespace.Name, 1, "", "", false, false)
require.NoError(w.T(), err)
}

func TestWorkloadTestSuite(t *testing.T) {
suite.Run(t, new(WorkloadTestSuite))
}
2 changes: 1 addition & 1 deletion tests/validation/tests/v3_api/test_workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_wl_statefulset():
)
validate_workload(p_client, workload, "statefulSet", ns.name)


#Converted to go test in TestWorkloadDaemonSet
def test_wl_daemonset():
p_client = namespace["p_client"]
ns = namespace["ns"]
Expand Down

0 comments on commit a9946d2

Please sign in to comment.