mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #42545 from shiywang/e2e
Automatic merge from submit-queue (batch tested with PRs 42522, 42545, 42556, 42006, 42631) add e2e test for `apply set/view last-applied` command @pwittrock @kubernetes/sig-cli-pr-reviews
This commit is contained in:
commit
57fbbc6104
@ -96,6 +96,9 @@ const (
|
||||
kubeCtlManifestPath = "test/e2e/testing-manifests/kubectl"
|
||||
redisControllerFilename = "redis-master-controller.json"
|
||||
redisServiceFilename = "redis-master-service.json"
|
||||
nginxDeployment1Filename = "nginx-deployment1.yaml"
|
||||
nginxDeployment2Filename = "nginx-deployment2.yaml"
|
||||
nginxDeployment3Filename = "nginx-deployment3.yaml"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -684,6 +687,49 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
|
||||
framework.Failf("port should keep the same")
|
||||
}
|
||||
})
|
||||
|
||||
It("apply set/view last-applied", func() {
|
||||
deployment1Yaml := readTestFileOrDie(nginxDeployment1Filename)
|
||||
deployment2Yaml := readTestFileOrDie(nginxDeployment2Filename)
|
||||
deployment3Yaml := readTestFileOrDie(nginxDeployment3Filename)
|
||||
nsFlag := fmt.Sprintf("--namespace=%v", ns)
|
||||
|
||||
By("deployment replicas number is 2")
|
||||
framework.RunKubectlOrDieInput(string(deployment1Yaml[:]), "apply", "-f", "-", nsFlag)
|
||||
|
||||
By("check the last-applied matches expectations annotations")
|
||||
output := framework.RunKubectlOrDieInput(string(deployment1Yaml[:]), "apply", "view-last-applied", "-f", "-", nsFlag, "-o", "json")
|
||||
requiredString := "\"replicas\": 2"
|
||||
if !strings.Contains(output, requiredString) {
|
||||
framework.Failf("Missing %s in kubectl view-last-applied", requiredString)
|
||||
}
|
||||
|
||||
By("apply file doesn't have replicas")
|
||||
framework.RunKubectlOrDieInput(string(deployment2Yaml[:]), "apply", "set-last-applied", "-f", "-", nsFlag)
|
||||
|
||||
By("check last-applied has been updated, annotations doesn't replicas")
|
||||
output = framework.RunKubectlOrDieInput(string(deployment1Yaml[:]), "apply", "view-last-applied", "-f", "-", nsFlag, "-o", "json")
|
||||
requiredString = "\"replicas\": 2"
|
||||
if strings.Contains(output, requiredString) {
|
||||
framework.Failf("Missing %s in kubectl view-last-applied", requiredString)
|
||||
}
|
||||
|
||||
By("scale set replicas to 3")
|
||||
nginxDeploy := "nginx-deployment"
|
||||
framework.RunKubectlOrDie("scale", "deployment", nginxDeploy, "--replicas=3", nsFlag)
|
||||
|
||||
By("apply file doesn't have replicas but image changed")
|
||||
framework.RunKubectlOrDieInput(string(deployment3Yaml[:]), "apply", "-f", "-", nsFlag)
|
||||
|
||||
By("verify replicas still is 3 and image has been updated")
|
||||
output = framework.RunKubectlOrDieInput(string(deployment3Yaml[:]), "get", "-f", "-", nsFlag, "-o", "json")
|
||||
requiredItems := []string{"\"replicas\": 3", "nginx-slim:0.7"}
|
||||
for _, item := range requiredItems {
|
||||
if !strings.Contains(output, item) {
|
||||
framework.Failf("Missing %s in kubectl apply", item)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
framework.KubeDescribe("Kubectl cluster-info", func() {
|
||||
|
16
test/e2e/testing-manifests/kubectl/nginx-deployment1.yaml
Normal file
16
test/e2e/testing-manifests/kubectl/nginx-deployment1.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
replicas: 2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: gcr.io/google_containers/nginx-slim:0.8
|
||||
ports:
|
||||
- containerPort: 80
|
15
test/e2e/testing-manifests/kubectl/nginx-deployment2.yaml
Normal file
15
test/e2e/testing-manifests/kubectl/nginx-deployment2.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: gcr.io/google_containers/nginx-slim:0.8
|
||||
ports:
|
||||
- containerPort: 80
|
15
test/e2e/testing-manifests/kubectl/nginx-deployment3.yaml
Normal file
15
test/e2e/testing-manifests/kubectl/nginx-deployment3.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: gcr.io/google_containers/nginx-slim:0.7
|
||||
ports:
|
||||
- containerPort: 80
|
Loading…
Reference in New Issue
Block a user