Skip to content

WRKLDS-1431: e2e: migrate DCs to Deployments #28957

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

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 14 additions & 119 deletions examples/sample-app/application-template-stibuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,75 +164,24 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "apps.openshift.io/v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "frontend",
"annotations": {
"template.alpha.openshift.io/wait-for-ready": "true"
"template.alpha.openshift.io/wait-for-ready": "true",
"image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"origin-ruby-sample:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]"
}
},
"spec": {
"strategy": {
"type": "Rolling",
"rollingParams": {
"updatePeriodSeconds": 1,
"intervalSeconds": 1,
"timeoutSeconds": 120,
"pre": {
"failurePolicy": "Abort",
"execNewPod": {
"command": [
"/bin/true"
],
"env": [
{
"name": "CUSTOM_VAR1",
"value": "custom_value1"
}
],
"containerName": "ruby-helloworld"
}
},
"post": {
"failurePolicy": "Ignore",
"execNewPod": {
"command": [
"/bin/true"
],
"env": [
{
"name": "CUSTOM_VAR2",
"value": "custom_value2"
}
],
"containerName": "ruby-helloworld"
}
}
},
"resources": {}
"type": "RollingUpdate"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"ruby-helloworld"
],
"from": {
"kind": "ImageStreamTag",
"name": "origin-ruby-sample:latest"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 2,
"selector": {
"name": "frontend"
"matchLabels": {
"name": "frontend"
}
},
"template": {
"metadata": {
Expand Down Expand Up @@ -317,8 +266,8 @@
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "apps.openshift.io/v1",
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "database",
"annotations": {
Expand All @@ -327,67 +276,13 @@
},
"spec": {
"strategy": {
"type": "Recreate",
"recreateParams": {
"pre": {
"failurePolicy": "Abort",
"execNewPod": {
"command": [
"/bin/true"
],
"env": [
{
"name": "CUSTOM_VAR1",
"value": "custom_value1"
}
],
"containerName": "ruby-helloworld-database",
"volumes": ["ruby-helloworld-data"]
}
},
"mid": {
"failurePolicy": "Abort",
"execNewPod": {
"command": [
"/bin/true"
],
"env": [
{
"name": "CUSTOM_VAR2",
"value": "custom_value2"
}
],
"containerName": "ruby-helloworld-database",
"volumes": ["ruby-helloworld-data"]
}
},
"post": {
"failurePolicy": "Ignore",
"execNewPod": {
"command": [
"/bin/true"
],
"env": [
{
"name": "CUSTOM_VAR2",
"value": "custom_value2"
}
],
"containerName": "ruby-helloworld-database",
"volumes": ["ruby-helloworld-data"]
}
}
},
"resources": {}
"type": "Recreate"
},
"triggers": [
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "database"
"matchLabels": {
"name": "database"
}
},
"template": {
"metadata": {
Expand Down
52 changes: 28 additions & 24 deletions test/extended/builds/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,27 @@ package builds

import (
"path/filepath"
"time"

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"

admissionapi "k8s.io/pod-security-admission/api"

deploymentutil "github.com/openshift/origin/test/extended/deployments"
exutil "github.com/openshift/origin/test/extended/util"
)

var _ = g.Describe("[sig-builds][Feature:Builds][volumes] build volumes", func() {
var (
oc = exutil.NewCLIWithPodSecurityLevel("build-volumes", admissionapi.LevelBaseline)
baseDir = exutil.FixturePath("testdata", "builds", "volumes")
secret = filepath.Join(baseDir, "secret.yaml")
configmap = filepath.Join(baseDir, "configmap.yaml")
s2iImageStream = filepath.Join(baseDir, "s2i-imagestream.yaml")
s2iBuildConfig = filepath.Join(baseDir, "s2i-buildconfig.yaml")
s2iDeploymentConfig = filepath.Join(baseDir, "s2i-deploymentconfig.yaml")
dockerImageStream = filepath.Join(baseDir, "docker-imagestream.yaml")
dockerBuildConfig = filepath.Join(baseDir, "docker-buildconfig.yaml")
dockerDeploymentConfig = filepath.Join(baseDir, "docker-deploymentconfig.yaml")
oc = exutil.NewCLIWithPodSecurityLevel("build-volumes", admissionapi.LevelBaseline)
baseDir = exutil.FixturePath("testdata", "builds", "volumes")
secret = filepath.Join(baseDir, "secret.yaml")
configmap = filepath.Join(baseDir, "configmap.yaml")
s2iImageStream = filepath.Join(baseDir, "s2i-imagestream.yaml")
s2iBuildConfig = filepath.Join(baseDir, "s2i-buildconfig.yaml")
s2iDeployment = filepath.Join(baseDir, "s2i-deployment.yaml")
dockerImageStream = filepath.Join(baseDir, "docker-imagestream.yaml")
dockerBuildConfig = filepath.Join(baseDir, "docker-buildconfig.yaml")
dockerDeployment = filepath.Join(baseDir, "docker-deployment.yaml")
)

g.Context("", func() {
Expand All @@ -51,7 +49,7 @@ var _ = g.Describe("[sig-builds][Feature:Builds][volumes] build volumes", func()
}
})

g.It("should mount given secrets and configmaps into the build pod for source strategy builds [apigroup:image.openshift.io][apigroup:build.openshift.io][apigroup:apps.openshift.io]", func() {
g.It("should mount given secrets and configmaps into the build pod for source strategy builds [apigroup:image.openshift.io][apigroup:build.openshift.io]", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't remember if we discussed this before but you may want to rename these tests in the test mapping repo so history carries over and component readiness can compare to past releases. Unless, you feel this is now a new test that should not be compared anymore?

"New" tests may soon be required to have a very high pass rate 99% by component readiness.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did :) I have a PR ready for the mapping: openshift-eng/ci-test-mapping#148. Once this merges I will update the mapping accordingly.

g.By("creating an imagestream")
err := oc.Run("create").Args("-f", s2iImageStream).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
Expand All @@ -70,26 +68,29 @@ var _ = g.Describe("[sig-builds][Feature:Builds][volumes] build volumes", func()
o.Expect(buildPodLogs).To(o.ContainSubstring("my-secret-value"))
o.Expect(buildPodLogs).To(o.ContainSubstring("my-configmap-value"))

g.By("creating a deployment config")
err = oc.Run("create").Args("-f", s2iDeploymentConfig).Execute()
g.By("creating a deployment")
err = oc.Run("create").Args("-f", s2iDeployment).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

projectName, err := oc.Run("project").Args("-q").Output()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("waiting for the deployment to complete")
_, err = deploymentutil.WaitForDeployerToComplete(oc, "mys2itest-1", 5*time.Minute)
err = exutil.WaitForDeploymentReady(oc, "mys2itest", projectName, -1)
o.Expect(err).NotTo(o.HaveOccurred())

g.By("ensuring that the secret does not exist in the build image")
out, err := oc.Run("rsh").Args("dc/mys2itest", "cat", "/var/run/secrets/some-secret/key").Output()
out, err := oc.Run("rsh").Args("deployment/mys2itest", "cat", "/var/run/secrets/some-secret/key").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("cat: /var/run/secrets/some-secret/key: No such file or directory"))

g.By("ensuring that the configmap does not exist in the build image")
out, err = oc.Run("rsh").Args("dc/mys2itest", "cat", "/var/run/configmaps/some-configmap/key").Output()
out, err = oc.Run("rsh").Args("deployment/mys2itest", "cat", "/var/run/configmaps/some-configmap/key").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("cat: /var/run/configmaps/some-configmap/key: No such file or directory"))
})

g.It("should mount given secrets and configmaps into the build pod for docker strategy builds [apigroup:image.openshift.io][apigroup:build.openshift.io][apigroup:apps.openshift.io]", func() {
g.It("should mount given secrets and configmaps into the build pod for docker strategy builds [apigroup:image.openshift.io][apigroup:build.openshift.io]", func() {
g.By("creating an imagestream")
err := oc.Run("create").Args("-f", dockerImageStream).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
Expand All @@ -108,21 +109,24 @@ var _ = g.Describe("[sig-builds][Feature:Builds][volumes] build volumes", func()
o.Expect(buildPodLogs).To(o.ContainSubstring("my-secret-value"))
o.Expect(buildPodLogs).To(o.ContainSubstring("my-configmap-value"))

g.By("creating a deployment config")
err = oc.Run("create").Args("-f", dockerDeploymentConfig).Execute()
g.By("creating a deployment")
err = oc.Run("create").Args("-f", dockerDeployment).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

projectName, err := oc.Run("project").Args("-q").Output()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("waiting for the deployment to complete")
_, err = deploymentutil.WaitForDeployerToComplete(oc, "mydockertest-1", 5*time.Minute)
err = exutil.WaitForDeploymentReady(oc, "mydockertest", projectName, -1)
o.Expect(err).NotTo(o.HaveOccurred())

g.By("ensuring that the secret does not exist in the build image")
out, err := oc.Run("rsh").Args("dc/mydockertest", "cat", "/var/run/secrets/some-secret/key").Output()
out, err := oc.Run("rsh").Args("deployment/mydockertest", "cat", "/var/run/secrets/some-secret/key").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("cat: /var/run/secrets/some-secret/key: No such file or directory"))

g.By("ensuring that the configmap does not exist in the build image")
out, err = oc.Run("rsh").Args("dc/mydockertest", "cat", "/var/run/configmaps/some-configmap/key").Output()
out, err = oc.Run("rsh").Args("deployment/mydockertest", "cat", "/var/run/configmaps/some-configmap/key").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("cat: /var/run/configmaps/some-configmap/key: No such file or directory"))
})
Expand Down
2 changes: 1 addition & 1 deletion test/extended/cli/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ var _ = g.Describe("[sig-cli] oc adm", func() {
o.Expect(out).To(o.ContainSubstring("createuser2"))
})

g.It("build-chain [apigroup:build.openshift.io][apigroup:image.openshift.io][apigroup:project.openshift.io][apigroup:apps.openshift.io]", func() {
g.It("build-chain [apigroup:build.openshift.io][apigroup:image.openshift.io][apigroup:project.openshift.io]", func() {
// Test building a dependency tree
s2iBuildPath := exutil.FixturePath("..", "..", "examples", "sample-app", "application-template-stibuild.json")
out, _, err := ocns.Run("process").Args("-f", s2iBuildPath, "-l", "build=sti").Outputs()
Expand Down
4 changes: 2 additions & 2 deletions test/extended/cli/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ var _ = g.Describe("[sig-cli] oc builds", func() {
o.Expect(err).NotTo(o.HaveOccurred())
})

g.It("webhooks CRUD [apigroup:build.openshift.io][apigroup:apps.openshift.io]", func() {
g.It("webhooks CRUD [apigroup:build.openshift.io]", func() {
g.By("check bc webhooks")
out, err := oc.Run("describe").Args("buildConfigs", "ruby-sample-build").Output()
o.Expect(err).NotTo(o.HaveOccurred())
Expand Down Expand Up @@ -284,7 +284,7 @@ var _ = g.Describe("[sig-cli] oc builds", func() {
))
})

g.It("start-build [apigroup:build.openshift.io][apigroup:apps.openshift.io]", func() {
g.It("start-build [apigroup:build.openshift.io]", func() {
g.By("valid build")
out, err := oc.Run("start-build").Args("--from-webhook", getTriggerURL("secret101", "generic")).Output()
o.Expect(err).NotTo(o.HaveOccurred())
Expand Down
Loading