-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Marketplace OPSRC&CSC with publisher&displayName #23711
Merged
openshift-merge-robot
merged 9 commits into
openshift:master
from
emmajiafan:marketplacestatus
Nov 26, 2019
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ec94e01
Merge pull request #1 from openshift/master
emmajiafan 5d219c5
marketplace labels
d65dbcc
ocp-21728 opsrc&csc with provider
220a84b
modify the bindata
9117906
remove the comment code
6e64b71
modify the ignore
956b19f
modify the way of wait time
5bcc154
change the resourcetime
68ac80d
modify the resourcewaittime
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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,123 @@ | ||
package marketplace | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
g "github.com/onsi/ginkgo" | ||
o "github.com/onsi/gomega" | ||
|
||
exutil "github.com/openshift/origin/test/extended/util" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
e2e "k8s.io/kubernetes/test/e2e/framework" | ||
) | ||
|
||
var _ = g.Describe("[Feature:Marketplace] Marketplace resources with labels provider displayName", func() { | ||
|
||
defer g.GinkgoRecover() | ||
|
||
var ( | ||
oc = exutil.NewCLI("marketplace", exutil.KubeConfigPath()) | ||
allNs = "openshift-operators" | ||
marketplaceNs = "openshift-marketplace" | ||
resourceWait = 60 * time.Second | ||
|
||
opsrcYamltem = exutil.FixturePath("testdata", "marketplace", "opsrc", "02-opsrc.yaml") | ||
cscYamltem = exutil.FixturePath("testdata", "marketplace", "csc", "02-csc.yaml") | ||
) | ||
|
||
g.AfterEach(func() { | ||
//clear the sub,csv resource | ||
allresourcelist := [][]string{ | ||
{"operatorsource", "opsrctestlabel", marketplaceNs}, | ||
{"catalogsourceconfig", "csctestlabel", marketplaceNs}, | ||
} | ||
|
||
for _, source := range allresourcelist { | ||
err := clearResources(oc, source[0], source[1], source[2]) | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
} | ||
}) | ||
|
||
//OCP-21728 check the publisher,display,labels of opsrc&csc | ||
g.It("[ocp-21728]create opsrc with labels", func() { | ||
|
||
//create one opsrc with label | ||
opsrcYaml, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", opsrcYamltem, "-p", "NAME=opsrctestlabel", "NAMESPACE=marketplace_e2e", "LABEL=optestlabel", "DISPLAYNAME=optestlabel", "PUBLISHER=optestlabel", fmt.Sprintf("MARKETPLACE=%s", marketplaceNs)).OutputToFile("config.json") | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
err = createResources(oc, opsrcYaml) | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
//wait for the opsrc is created finished | ||
err = wait.Poll(5*time.Second, resourceWait, func() (bool, error) { | ||
output, err := oc.AsAdmin().Run("get").Args("operatorsource", "opsrctestlabel", "-o=jsonpath={.status.currentPhase.phase.message}", "-n", marketplaceNs).Output() | ||
if err != nil { | ||
e2e.Failf("Failed to create opsrctestlabel, error:%v", err) | ||
return false, err | ||
} | ||
if strings.Contains(output, "has been successfully reconciled") { | ||
return true, nil | ||
} | ||
return false, nil | ||
}) | ||
|
||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
opsrcResourceList := [][]string{ | ||
{"operatorsource", "opsrctestlabel", "-o=jsonpath={.metadata.labels.opsrc-provider}", marketplaceNs}, | ||
{"operatorsource", "opsrctestlabel", "-o=jsonpath={.spec.displayName}", marketplaceNs}, | ||
{"operatorsource", "opsrctestlabel", "-o=jsonpath={.spec.publisher}", marketplaceNs}, | ||
{"catalogsource", "opsrctestlabel", "-o=jsonpath={.metadata.labels.opsrc-provider}", marketplaceNs}, | ||
{"catalogsource", "opsrctestlabel", "-o=jsonpath={.spec.displayName}", marketplaceNs}, | ||
{"catalogsource", "opsrctestlabel", "-o=jsonpath={.spec.publisher}", marketplaceNs}, | ||
} | ||
//check the displayname,provider,labels of opsrc & catalogsource | ||
for _, source := range opsrcResourceList { | ||
msg, _ := getResourceByPath(oc, source[0], source[1], source[2], source[3]) | ||
o.Expect(msg).Should(o.ContainSubstring("optestlabel")) | ||
} | ||
//create one csc with provider&display&labels | ||
cscYaml, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", cscYamltem, "-p", "NAME=csctestlabel", fmt.Sprintf("NAMESPACE=%s", allNs), fmt.Sprintf("MARKETPLACE=%s", marketplaceNs), "PACKAGES=camel-k-marketplace-e2e-tests", "DISPLAYNAME=csctestlabel", "PUBLISHER=csctestlabel").OutputToFile("config.json") | ||
err = createResources(oc, cscYaml) | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
//wait for the csc is created finished | ||
err = wait.Poll(5*time.Second, resourceWait, func() (bool, error) { | ||
output, err := oc.AsAdmin().Run("get").Args("catalogsourceconfig", "csctestlabel", "-o=jsonpath={.status.currentPhase.phase.message}", "-n", marketplaceNs).Output() | ||
if err != nil { | ||
e2e.Failf("Failed to create csctestlabel, error:%v", err) | ||
return false, err | ||
} | ||
if strings.Contains(output, "has been successfully reconciled") { | ||
return true, nil | ||
} | ||
return false, nil | ||
}) | ||
|
||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
|
||
cscResourceList := [][]string{ | ||
{"catalogsourceconfig", "csctestlabel", "-o=jsonpath={.spec.csDisplayName}", marketplaceNs}, | ||
{"catalogsourceconfig", "csctestlabel", "-o=jsonpath={.spec.csPublisher}", marketplaceNs}, | ||
{"catalogsource", "csctestlabel", "-o=jsonpath={.spec.displayName}", allNs}, | ||
{"catalogsource", "csctestlabel", "-o=jsonpath={.spec.publisher}", allNs}, | ||
} | ||
//check the displayname,provider oc csc & catalogsource | ||
for _, source := range cscResourceList { | ||
msg, _ := getResourceByPath(oc, source[0], source[1], source[2], source[3]) | ||
o.Expect(msg).Should(o.ContainSubstring("csctestlabel")) | ||
} | ||
|
||
//get the packagelist of opsrctestlabel | ||
packageListOpsrc1, _ := getResourceByPath(oc, "operatorsource", "opsrctestlabel", "-o=jsonpath={.status.packages}", marketplaceNs) | ||
packageList := strings.Split(packageListOpsrc1, ",") | ||
|
||
//get the packagelist with label of opsrctestlabel | ||
packageListOpsrc2, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifests", "-lopsrc-provider=optestlabel", "-o=name", "-n", marketplaceNs).Output() | ||
for _, packages := range packageList { | ||
o.Expect(packageListOpsrc2).Should(o.ContainSubstring(packages)) | ||
} | ||
}) | ||
}) |
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 marketplace | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
o "github.com/onsi/gomega" | ||
exutil "github.com/openshift/origin/test/extended/util" | ||
|
||
e2e "k8s.io/kubernetes/test/e2e/framework" | ||
) | ||
|
||
//create objects by yaml in the cluster | ||
func createResources(oc *exutil.CLI, yamlfile string) error { | ||
yaml := fmt.Sprint(yamlfile) | ||
e2e.Logf("Start to create Resource: %s", yaml) | ||
err := oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", yaml).Execute() | ||
o.Expect(err).NotTo(o.HaveOccurred()) | ||
if err != nil { | ||
e2e.Failf("Unable to create file:%s", yaml) | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// delete objects in the cluster | ||
func clearResources(oc *exutil.CLI, resourcetype string, name string, ns string) error { | ||
msg, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-n", ns, resourcetype, name).Output() | ||
if err != nil { | ||
errstring := fmt.Sprintf("%v", msg) | ||
if strings.Contains(errstring, "NotFound") { | ||
return nil | ||
} | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
//check the resource exist or not | ||
func existResources(oc *exutil.CLI, resourcetype string, name string, ns string) (b bool, e error) { | ||
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", ns, resourcetype, name).Output() | ||
if err != nil { | ||
errstring := fmt.Sprintf("%v", msg) | ||
if strings.Contains(errstring, "NotFound") { | ||
return false, nil | ||
} | ||
|
||
e2e.Failf("Can't get resource:%s", name) | ||
return false, err | ||
} | ||
return true, nil | ||
} | ||
|
||
func getResourceByPath(oc *exutil.CLI, resourcetype string, name string, path string, ns string) (msg string, e error) { | ||
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", ns, resourcetype, name, path).Output() | ||
if err != nil { | ||
errstring := fmt.Sprintf("%v", msg) | ||
if strings.Contains(errstring, "NotFound") { | ||
return msg, nil | ||
} | ||
e2e.Failf("Can't get resource:%s", name) | ||
return msg, err | ||
} | ||
return msg, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
apiVersion: v1 | ||
kind: Template | ||
metadata: | ||
name: csc-template | ||
objects: | ||
- apiVersion: operators.coreos.com/v1 | ||
kind: CatalogSourceConfig | ||
metadata: | ||
name: "${NAME}" | ||
namespace: "${MARKETPLACE}" | ||
spec: | ||
targetNamespace: "${NAMESPACE}" | ||
source: "" | ||
packages: "${PACKAGES}" | ||
csDisplayName: "${DISPLAYNAME}" | ||
csPublisher: "${PUBLISHER}" | ||
|
||
parameters: | ||
- name: NAME | ||
- name: NAMESPACE | ||
- name: MARKETPLACE | ||
- name: PACKAGES | ||
- name: DISPLAYNAME | ||
- name: PUBLISHER |
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 @@ | ||
apiVersion: v1 | ||
kind: Template | ||
metadata: | ||
name: opsrc-template | ||
objects: | ||
- apiVersion: operators.coreos.com/v1 | ||
kind: OperatorSource | ||
metadata: | ||
name: "${NAME}" | ||
namespace: "${MARKETPLACE}" | ||
labels: | ||
opsrc-provider: "${LABEL}" | ||
spec: | ||
type: appregistry | ||
endpoint: "https://quay.io/cnr" | ||
registryNamespace: "${NAMESPACE}" | ||
displayName: "${DISPLAYNAME}" | ||
publisher: "${PUBLISHER}" | ||
|
||
parameters: | ||
- name: NAME | ||
- name: NAMESPACE | ||
- name: MARKETPLACE | ||
- name: LABEL | ||
- name: DISPLAYNAME | ||
- name: PUBLISHER |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this last part. I thought the purpose of this test was to check label propogation on marketplace child resources? Why are we checking the packagemanifest here? Or am I misunderstanding the purpose of this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will check label propogation on marketplace child resources and the packagemanifests from the child "catalogsource" ,The packcagemanifests will alsoo attache the label and they can be filtered by the label.