Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
operator/crd: Fix typo in additional columns field
Browse files Browse the repository at this point in the history
An e2e test to validate the deployment fields listed by `kubectl get`.
  • Loading branch information
avalluri committed Nov 11, 2020
1 parent 3c22e42 commit 2003d58
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deploy/crd/pmem-csi.intel.com_deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
- jsonPath: .status.phase
name: Status
type: string
- jsonPath: .metatdata.creationTimestamp
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pmemcsi/v1alpha1/deployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type DeploymentStatus struct {
// +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeSelector`
// +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.spec.image`
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metatdata.creationTimestamp`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
type Deployment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
29 changes: 29 additions & 0 deletions test/e2e/operator/deployment_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

api "github.com/intel/pmem-csi/pkg/apis/pmemcsi/v1alpha1"
"github.com/intel/pmem-csi/pkg/exec"
"github.com/intel/pmem-csi/pkg/k8sutil"
"github.com/intel/pmem-csi/pkg/pmem-csi-operator/controller/deployment/testcases"
"github.com/intel/pmem-csi/pkg/version"
Expand Down Expand Up @@ -160,6 +161,34 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool {
})
}

It("get deployment shall list expected fields", func() {
lblKey := "storage"
lblValue := "unknown-node"
deployment := getDeployment("test-get-deployment-fields")
// Only values that are visible in Deployment CR are shown in `kubectl get`
// but, not the default values chosen by the operator.
// So provide the values that are expected to list.
deployment.Spec.DeviceMode = api.DeviceModeDirect
deployment.Spec.PullPolicy = corev1.PullNever
deployment.Spec.Image = dummyImage
deployment.Spec.NodeSelector = map[string]string{
lblKey: lblValue,
}

deployment = deploy.CreateDeploymentCR(f, deployment)
defer deploy.DeleteDeploymentCR(f, deployment.Name)
validateDriver(deployment, "validate driver")

d := deploy.GetDeploymentCR(f, deployment.Name)

// Run in-cluster kubectl from master node
ssh := os.Getenv("REPO_ROOT") + "/_work/" + os.Getenv("CLUSTER") + "/ssh.0"
out, err := exec.RunCommand(ssh, "kubectl", "get", "deployments.pmem-csi.intel.com", "--no-headers")
Expect(err).ShouldNot(HaveOccurred(), "kubectl get: %v", out)
Expect(out).Should(MatchRegexp(`%s\s+%s\s+.*"?%s"?:"?%s"?.*\s+%s\s+%s\s+[0-9]+(s|m)`,
d.Name, d.Spec.DeviceMode, lblKey, lblValue, d.Spec.Image, d.Status.Phase), "fields mismatch")
})

It("driver image shall default to operator image", func() {
deployment := getDeployment("test-deployment-driver-image")
deployment.Spec.Image = ""
Expand Down

0 comments on commit 2003d58

Please sign in to comment.