Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to pr…
…oper e2e Add annotation, label, and other basic tests Added secret and status resources Add project Add service and statefulset resources Formatting Combine annotations.sh and image changes into PR Migrate YAML list and probe tests All new cli/compat tests passing Add oauthaccesstoken validation Last of basicresources.sh migrated, cleanup Use e2e image for timeout test Move larger tests to additional PRs Remove AsAdmin for label and annotation tests Remove newCreateOptions Remove AsAdmin where not needed status and explain Added secret and status resources Add service and statefulset resources Formatting Combine annotations.sh and image changes into PR Migrate YAML list and probe tests All new cli/compat tests passing Add oauthaccesstoken validation Last of basicresources.sh migrated, cleanup Use e2e image for timeout test Move larger tests to additional PRs Cleanup after rebase
- Loading branch information
Showing
18 changed files
with
503 additions
and
1,071 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
g "github.com/onsi/ginkgo" | ||
o "github.com/onsi/gomega" | ||
|
||
exutil "github.com/openshift/origin/test/extended/util" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
var _ = g.Describe("[sig-cli] oc annotate", func() { | ||
defer g.GinkgoRecover() | ||
|
||
const ( | ||
podAnnotationTemplate = `{{index .metadata.annotations "new-anno"}}` | ||
) | ||
|
||
var ( | ||
ctx = context.Background() | ||
oc = exutil.NewCLI("oc-annotation") | ||
) | ||
|
||
g.It("pod", func() { | ||
g.By("creating hello-openshift pod") | ||
_, err := oc.KubeClient().CoreV1().Pods(oc.Namespace()).Create( | ||
ctx, | ||
newHelloPod(), | ||
metav1.CreateOptions{}, | ||
) | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
g.By("setting a new annotation") | ||
out, err := oc.Run("annotate").Args("pod", "hello-openshift", "new-anno=hello").Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("pod/hello-openshift annotated")) | ||
|
||
g.By("validating new annotation") | ||
out, err = oc.Run("get").Args("pod", "hello-openshift", "--template", podAnnotationTemplate).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.Equal("hello")) | ||
|
||
g.By("removing the annotation") | ||
out, err = oc.Run("annotate").Args("pod", "hello-openshift", "new-anno-").Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("pod/hello-openshift annotated")) | ||
|
||
g.By("validating missing annotation") | ||
out, err = oc.Run("get").Args("pod", "hello-openshift", "--template", podAnnotationTemplate).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.Equal("<no value>")) | ||
|
||
g.By("setting empty annotation") | ||
out, err = oc.Run("annotate").Args("pod", "hello-openshift", `new-anno=`).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("pod/hello-openshift annotated")) | ||
|
||
g.By("validating empty annotation") | ||
out, err = oc.Run("get").Args("pod", "hello-openshift", "--template", podAnnotationTemplate).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.BeEmpty()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
g "github.com/onsi/ginkgo" | ||
o "github.com/onsi/gomega" | ||
|
||
exutil "github.com/openshift/origin/test/extended/util" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
podLabelTemplate = `{{index .metadata.labels "new-label"}}` | ||
) | ||
|
||
var _ = g.Describe("[sig-cli] oc label", func() { | ||
defer g.GinkgoRecover() | ||
|
||
var ( | ||
ctx = context.Background() | ||
oc = exutil.NewCLI("oc-label") | ||
) | ||
|
||
g.It("pod", func() { | ||
g.By("creating hello-openshift pod") | ||
_, err := oc.KubeClient().CoreV1().Pods(oc.Namespace()).Create( | ||
ctx, | ||
newHelloPod(), | ||
metav1.CreateOptions{}, | ||
) | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
g.By("setting a new label") | ||
out, err := oc.Run("label").Args("pod", "hello-openshift", "new-label=hello").Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("pod/hello-openshift labeled")) | ||
|
||
g.By("validating new label") | ||
out, err = oc.Run("get").Args("pod", "hello-openshift", "--template", podLabelTemplate).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.Equal("hello")) | ||
|
||
g.By("removing the label") | ||
out, err = oc.Run("label").Args("pod", "hello-openshift", "new-label-").Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("pod/hello-openshift labeled")) | ||
|
||
g.By("validating missing label") | ||
out, err = oc.Run("get").Args("pod", "hello-openshift", "--template", podLabelTemplate).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.Equal("<no value>")) | ||
|
||
g.By("setting empty label") | ||
out, err = oc.Run("label").Args("pod", "hello-openshift", `new-label=`).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("pod/hello-openshift labeled")) | ||
|
||
g.By("validating empty label") | ||
out, err = oc.Run("get").Args("pod", "hello-openshift", "--template", podLabelTemplate).Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.BeEmpty()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cli | ||
|
||
import ( | ||
g "github.com/onsi/ginkgo" | ||
o "github.com/onsi/gomega" | ||
|
||
exutil "github.com/openshift/origin/test/extended/util" | ||
) | ||
|
||
var _ = g.Describe("[sig-cli] oc project", func() { | ||
defer g.GinkgoRecover() | ||
|
||
var ( | ||
oc = exutil.NewCLI("oc-project").AsAdmin() | ||
) | ||
|
||
g.It("--show-labels works for projects", func() { | ||
out, err := oc.Run("label").Args("namespace", oc.Namespace(), "foo=bar").Output() | ||
o.Expect(out).To(o.ContainSubstring("labeled")) | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
out, err = oc.Run("get").Args("project", oc.Namespace(), "--show-labels").Output() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
o.Expect(out).To(o.ContainSubstring("foo=bar")) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/openshift/origin/test/extended/util/image" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
k8simage "k8s.io/kubernetes/test/utils/image" | ||
) | ||
|
||
func newHelloPod() *corev1.Pod { | ||
return &corev1.Pod{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: "v1", | ||
Kind: "Pod", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "hello-openshift", | ||
Labels: map[string]string{ | ||
"name": "hello-openshift", | ||
}, | ||
}, | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: "hello-openshift", | ||
Image: k8simage.GetE2EImage(k8simage.Agnhost), | ||
Args: []string{"netexec"}, | ||
Ports: []corev1.ContainerPort{ | ||
{ | ||
ContainerPort: 8080, | ||
Protocol: corev1.ProtocolTCP, | ||
}, | ||
}, | ||
VolumeMounts: []corev1.VolumeMount{ | ||
{ | ||
Name: "tmp", | ||
MountPath: "/tmp", | ||
}, | ||
}, | ||
TerminationMessagePath: "/dev/termination-log", | ||
ImagePullPolicy: corev1.PullIfNotPresent, | ||
}, | ||
}, | ||
Volumes: []corev1.Volume{ | ||
{ | ||
Name: "tmp", | ||
VolumeSource: corev1.VolumeSource{ | ||
EmptyDir: &corev1.EmptyDirVolumeSource{}, | ||
}, | ||
}, | ||
}, | ||
RestartPolicy: corev1.RestartPolicyAlways, | ||
DNSPolicy: corev1.DNSClusterFirst, | ||
}, | ||
} | ||
} | ||
|
||
func newShellPod(shell string) *corev1.Pod { | ||
return &corev1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "cli-test", | ||
}, | ||
Spec: corev1.PodSpec{ | ||
ServiceAccountName: "builder", | ||
RestartPolicy: corev1.RestartPolicyNever, | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: "test", | ||
Image: image.ShellImage(), | ||
Command: []string{"/bin/bash", "-c", shell}, | ||
Env: []corev1.EnvVar{ | ||
{ | ||
Name: "HOME", | ||
Value: "/tmp", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func newFrontendService() *corev1.Service { | ||
return &corev1.Service{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "frontend", | ||
Labels: map[string]string{ | ||
"name": "frontend", | ||
}, | ||
}, | ||
Spec: corev1.ServiceSpec{ | ||
Ports: []corev1.ServicePort{ | ||
{ | ||
Protocol: corev1.ProtocolTCP, | ||
Port: 9998, | ||
TargetPort: intstr.FromInt(9998), | ||
}, | ||
}, | ||
Selector: map[string]string{ | ||
"name": "frontend", | ||
}, | ||
Type: "ClusterIP", | ||
SessionAffinity: corev1.ServiceAffinityNone, | ||
}, | ||
} | ||
} | ||
|
||
func newBusyBoxStatefulSet() *appsv1.StatefulSet { | ||
var replicas = int32(1) | ||
|
||
return &appsv1.StatefulSet{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "testapp", | ||
}, | ||
Spec: appsv1.StatefulSetSpec{ | ||
Replicas: &replicas, | ||
Selector: &metav1.LabelSelector{ | ||
MatchLabels: map[string]string{ | ||
"app": "testapp", | ||
}, | ||
}, | ||
ServiceName: "frontend", | ||
Template: corev1.PodTemplateSpec{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: map[string]string{ | ||
"app": "testapp", | ||
}, | ||
}, | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: "testapp", | ||
Image: k8simage.GetE2EImage(k8simage.BusyBox), | ||
Command: []string{"/bin/sleep"}, | ||
Args: []string{"300"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
Oops, something went wrong.