element_type
stringclasses 4
values | project_name
stringclasses 1
value | uuid
stringlengths 36
36
| name
stringlengths 0
346
| imports
stringlengths 0
2.67k
| structs
stringclasses 761
values | interfaces
stringclasses 22
values | file_location
stringclasses 545
values | code
stringlengths 26
8.07M
| global_vars
stringclasses 7
values | package
stringclasses 124
values | tags
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
function
|
openshift/openshift-tests-private
|
724dbedd-d725-4122-8b19-8db846cd5d66
|
GetDeprecatedChannelNameByPakcage
|
['DeprecatedEntriesInfo', 'DeprecationData']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/catalog.go
|
func GetDeprecatedChannelNameByPakcage(deprecationDataOut []DeprecationData, packageName string) []string {
var channelsName []string
var singleDeprecationData DeprecationData
var deprecatedEntriesInfo DeprecatedEntriesInfo
for _, singleDeprecationData = range deprecationDataOut {
if singleDeprecationData.Package == packageName {
for _, deprecatedEntriesInfo = range singleDeprecationData.Entries {
if deprecatedEntriesInfo.Reference.Schema == "olm.channel" {
channelsName = append(channelsName, deprecatedEntriesInfo.Reference.Name)
}
}
}
}
return channelsName
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
08f091bf-7214-402f-bed4-a1058f17bfaa
|
GetDeprecatedBundlesNameByPakcage
|
['DeprecatedEntriesInfo', 'DeprecationData']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/catalog.go
|
func GetDeprecatedBundlesNameByPakcage(deprecationDataOut []DeprecationData, packageName string) []string {
var bundlesName []string
var singleDeprecationData DeprecationData
var deprecatedEntriesInfo DeprecatedEntriesInfo
for _, singleDeprecationData = range deprecationDataOut {
if singleDeprecationData.Package == packageName {
for _, deprecatedEntriesInfo = range singleDeprecationData.Entries {
if deprecatedEntriesInfo.Reference.Schema == "olm.bundle" {
bundlesName = append(bundlesName, deprecatedEntriesInfo.Reference.Name)
}
}
}
}
return bundlesName
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
e48fcefa-c3c5-454a-8e71-c092a3126e5a
|
UnmarshalContent
|
['"encoding/json"', '"fmt"', '"strings"']
|
['ClusterCatalogDescription', 'BundleData', 'ChannelData', 'PackageData', 'DeprecationData', 'ContentData']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/catalog.go
|
func (clustercatalog *ClusterCatalogDescription) UnmarshalContent(oc *exutil.CLI, schema string) (ContentData, error) {
var (
singlePackageData PackageData
singleChannelData ChannelData
singleBundleData BundleData
singleDeprecationData DeprecationData
ContentData ContentData
targetData interface{}
err error
)
switch schema {
case "all":
return clustercatalog.UnmarshalAllContent(oc)
case "bundle":
targetData = &singleBundleData
case "channel":
targetData = &singleChannelData
case "package":
targetData = &singlePackageData
case "deprecations":
targetData = &singleDeprecationData
default:
return ContentData, fmt.Errorf("unsupported schema: %s", schema)
}
contents := clustercatalog.GetContent(oc)
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
if strings.Contains(line, "\"schema\":\"olm."+schema+"\"") {
if err = json.Unmarshal([]byte(line), targetData); err != nil {
return ContentData, err
}
switch schema {
case "bundle":
ContentData.Bundles = append(ContentData.Bundles, singleBundleData)
case "channel":
ContentData.Channels = append(ContentData.Channels, singleChannelData)
case "package":
ContentData.Packages = append(ContentData.Packages, singlePackageData)
case "deprecations":
ContentData.Deprecations = append(ContentData.Deprecations, singleDeprecationData)
}
}
}
err = nil
switch schema {
case "bundle":
if len(ContentData.Bundles) == 0 {
err = fmt.Errorf("can not get Bundles")
}
case "channel":
if len(ContentData.Channels) == 0 {
err = fmt.Errorf("can not get Channels")
}
case "package":
if len(ContentData.Packages) == 0 {
err = fmt.Errorf("can not get Packages")
}
case "deprecations":
if len(ContentData.Deprecations) == 0 {
err = fmt.Errorf("can not get Deprecations")
}
}
return ContentData, err
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
6752443d-afbd-45f2-bdfe-c948d6b4a2b8
|
UnmarshalAllContent
|
['"encoding/json"', '"fmt"', '"strings"']
|
['ClusterCatalogDescription', 'BundleData', 'ChannelData', 'PackageData', 'DeprecationData', 'ContentData']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/catalog.go
|
func (clustercatalog *ClusterCatalogDescription) UnmarshalAllContent(oc *exutil.CLI) (ContentData, error) {
var ContentData ContentData
contents := clustercatalog.GetContent(oc)
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
if strings.Contains(line, "\"schema\":\"olm.bundle\"") || strings.Contains(line, "\"schema\":\"olm.channel\"") || strings.Contains(line, "\"schema\":\"olm.package\"") || strings.Contains(line, "\"schema\":\"olm.deprecations\"") {
var targetData interface{}
switch {
case strings.Contains(line, "\"schema\":\"olm.bundle\""):
targetData = new(BundleData)
case strings.Contains(line, "\"schema\":\"olm.channel\""):
targetData = new(ChannelData)
case strings.Contains(line, "\"schema\":\"olm.package\""):
targetData = new(PackageData)
case strings.Contains(line, "\"schema\":\"olm.deprecations\""):
targetData = new(DeprecationData)
}
if err := json.Unmarshal([]byte(line), targetData); err != nil {
return ContentData, err
}
switch data := targetData.(type) {
case *BundleData:
ContentData.Bundles = append(ContentData.Bundles, *data)
case *ChannelData:
ContentData.Channels = append(ContentData.Channels, *data)
case *PackageData:
ContentData.Packages = append(ContentData.Packages, *data)
case *DeprecationData:
ContentData.Deprecations = append(ContentData.Deprecations, *data)
}
}
}
if len(ContentData.Bundles) == 0 && len(ContentData.Channels) == 0 && len(ContentData.Packages) == 0 && len(ContentData.Deprecations) == 0 {
return ContentData, fmt.Errorf("no any bundle, channel or package are got")
}
return ContentData, nil
}
|
olmv1util
| |||
file
|
openshift/openshift-tests-private
|
04704556-9c22-46f5-95f8-6e6ed7d2f427
|
cip
|
import (
"time"
o "github.com/onsi/gomega"
e2e "k8s.io/kubernetes/test/e2e/framework"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
)
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/cip.go
|
package olmv1util
import (
"time"
o "github.com/onsi/gomega"
e2e "k8s.io/kubernetes/test/e2e/framework"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
)
type CipDescription struct {
Name string
Repo1 string
Repo2 string
Repo3 string
Repo4 string
Policy string
Template string
}
func (cip *CipDescription) Create(oc *exutil.CLI) {
e2e.Logf("=========Create cip %v=========", cip.Name)
err := cip.CreateWithoutCheck(oc)
o.Expect(err).NotTo(o.HaveOccurred())
// start to update it
AssertMCPCondition(oc, "master", "Updating", "status", "True", 3, 120, 5)
AssertMCPCondition(oc, "worker", "Updating", "status", "True", 3, 120, 5)
// AssertMCPCondition(oc, "master", "Updated", "status", "False", 3, 90)
// AssertMCPCondition(oc, "worker", "Updated", "status", "False", 3, 90)
// finish to update it
AssertMCPCondition(oc, "master", "Updating", "status", "False", 30, 900, 10)
AssertMCPCondition(oc, "worker", "Updating", "status", "False", 30, 900, 10)
o.Expect(HealthyMCP4OLM(oc)).To(o.BeTrue())
// AssertMCPCondition(oc, "master", "Updated", "status", "True", 5, 30)
// AssertMCPCondition(oc, "worker", "Updated", "status", "True", 5, 30)
}
func (cip *CipDescription) CreateWithoutCheck(oc *exutil.CLI) error {
e2e.Logf("=========CreateWithoutCheck cip %v=========", cip.Name)
paremeters := []string{"-n", "default", "--ignore-unknown-parameters=true", "-f", cip.Template, "-p"}
if len(cip.Name) > 0 {
paremeters = append(paremeters, "NAME="+cip.Name)
}
if len(cip.Repo1) > 0 {
paremeters = append(paremeters, "REPO1="+cip.Repo1)
}
if len(cip.Repo2) > 0 {
paremeters = append(paremeters, "REPO2="+cip.Repo2)
}
if len(cip.Repo3) > 0 {
paremeters = append(paremeters, "REPO3="+cip.Repo3)
}
if len(cip.Repo4) > 0 {
paremeters = append(paremeters, "REPO4="+cip.Repo4)
}
if len(cip.Policy) > 0 {
paremeters = append(paremeters, "POLICY="+cip.Policy)
}
err := exutil.ApplyClusterResourceFromTemplateWithError(oc, paremeters...)
return err
}
func (cip *CipDescription) DeleteWithoutCheck(oc *exutil.CLI) {
e2e.Logf("=========DeleteWithoutCheck cip %v=========", cip.Name)
exutil.CleanupResource(oc, 4*time.Second, 160*time.Second, exutil.AsAdmin,
exutil.WithoutNamespace, "ClusterImagePolicy", cip.Name)
}
func (cip *CipDescription) Delete(oc *exutil.CLI) {
e2e.Logf("=========Delete cip %v=========", cip.Name)
cip.DeleteWithoutCheck(oc)
// start to update it
// AssertMCPCondition(oc, "master", "Updating", "status", "True", 3, 90, 5)
// AssertMCPCondition(oc, "worker", "Updating", "status", "True", 3, 90, 5)
// AssertMCPCondition(oc, "master", "Updated", "status", "False", 3, 90, 5)
// AssertMCPCondition(oc, "worker", "Updated", "status", "False", 3, 90, 5)
// finish to update it
AssertMCPCondition(oc, "master", "Updating", "status", "False", 90, 900, 30)
AssertMCPCondition(oc, "worker", "Updating", "status", "False", 30, 900, 10)
// AssertMCPCondition(oc, "master", "Updated", "status", "True", 5, 30, 5)
// AssertMCPCondition(oc, "worker", "Updated", "status", "True", 5, 30, 5)
o.Eventually(func() bool {
return HealthyMCP4OLM(oc)
}, 600*time.Second, 30*time.Second).Should(o.BeTrue(), "mcp is not recovered after delete cip")
}
|
package olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
32878154-3421-4efe-83c2-bb0289a6ccd0
|
Create
|
['CipDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/cip.go
|
func (cip *CipDescription) Create(oc *exutil.CLI) {
e2e.Logf("=========Create cip %v=========", cip.Name)
err := cip.CreateWithoutCheck(oc)
o.Expect(err).NotTo(o.HaveOccurred())
// start to update it
AssertMCPCondition(oc, "master", "Updating", "status", "True", 3, 120, 5)
AssertMCPCondition(oc, "worker", "Updating", "status", "True", 3, 120, 5)
// AssertMCPCondition(oc, "master", "Updated", "status", "False", 3, 90)
// AssertMCPCondition(oc, "worker", "Updated", "status", "False", 3, 90)
// finish to update it
AssertMCPCondition(oc, "master", "Updating", "status", "False", 30, 900, 10)
AssertMCPCondition(oc, "worker", "Updating", "status", "False", 30, 900, 10)
o.Expect(HealthyMCP4OLM(oc)).To(o.BeTrue())
// AssertMCPCondition(oc, "master", "Updated", "status", "True", 5, 30)
// AssertMCPCondition(oc, "worker", "Updated", "status", "True", 5, 30)
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
a112f7d4-57f7-4b27-af9c-5a03546a59ff
|
CreateWithoutCheck
|
['CipDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/cip.go
|
func (cip *CipDescription) CreateWithoutCheck(oc *exutil.CLI) error {
e2e.Logf("=========CreateWithoutCheck cip %v=========", cip.Name)
paremeters := []string{"-n", "default", "--ignore-unknown-parameters=true", "-f", cip.Template, "-p"}
if len(cip.Name) > 0 {
paremeters = append(paremeters, "NAME="+cip.Name)
}
if len(cip.Repo1) > 0 {
paremeters = append(paremeters, "REPO1="+cip.Repo1)
}
if len(cip.Repo2) > 0 {
paremeters = append(paremeters, "REPO2="+cip.Repo2)
}
if len(cip.Repo3) > 0 {
paremeters = append(paremeters, "REPO3="+cip.Repo3)
}
if len(cip.Repo4) > 0 {
paremeters = append(paremeters, "REPO4="+cip.Repo4)
}
if len(cip.Policy) > 0 {
paremeters = append(paremeters, "POLICY="+cip.Policy)
}
err := exutil.ApplyClusterResourceFromTemplateWithError(oc, paremeters...)
return err
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
d2fc58d5-9e56-4830-9186-bbd1ab02de47
|
DeleteWithoutCheck
|
['"time"']
|
['CipDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/cip.go
|
func (cip *CipDescription) DeleteWithoutCheck(oc *exutil.CLI) {
e2e.Logf("=========DeleteWithoutCheck cip %v=========", cip.Name)
exutil.CleanupResource(oc, 4*time.Second, 160*time.Second, exutil.AsAdmin,
exutil.WithoutNamespace, "ClusterImagePolicy", cip.Name)
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
65f6f6a1-e732-41e2-997c-43b34c482fd0
|
Delete
|
['"time"']
|
['CipDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/cip.go
|
func (cip *CipDescription) Delete(oc *exutil.CLI) {
e2e.Logf("=========Delete cip %v=========", cip.Name)
cip.DeleteWithoutCheck(oc)
// start to update it
// AssertMCPCondition(oc, "master", "Updating", "status", "True", 3, 90, 5)
// AssertMCPCondition(oc, "worker", "Updating", "status", "True", 3, 90, 5)
// AssertMCPCondition(oc, "master", "Updated", "status", "False", 3, 90, 5)
// AssertMCPCondition(oc, "worker", "Updated", "status", "False", 3, 90, 5)
// finish to update it
AssertMCPCondition(oc, "master", "Updating", "status", "False", 90, 900, 30)
AssertMCPCondition(oc, "worker", "Updating", "status", "False", 30, 900, 10)
// AssertMCPCondition(oc, "master", "Updated", "status", "True", 5, 30, 5)
// AssertMCPCondition(oc, "worker", "Updated", "status", "True", 5, 30, 5)
o.Eventually(func() bool {
return HealthyMCP4OLM(oc)
}, 600*time.Second, 30*time.Second).Should(o.BeTrue(), "mcp is not recovered after delete cip")
}
|
olmv1util
| |||
file
|
openshift/openshift-tests-private
|
8c762522-ea96-45ac-b463-444ae8cf3391
|
clusterextension
|
import (
"context"
"fmt"
"time"
o "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
"strings"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
)
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
package olmv1util
import (
"context"
"fmt"
"time"
o "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
"strings"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
)
type ClusterExtensionDescription struct {
Name string
PackageName string
Channel string
Version string
InstallNamespace string
SaName string
UpgradeConstraintPolicy string
LabelKey string // default is olmv1-test
LabelValue string // suggest to use case id
ExpressionsKey string
ExpressionsOperator string
ExpressionsValue1 string
ExpressionsValue2 string
ExpressionsValue3 string
SourceType string
Template string
InstalledBundle string
}
func (clusterextension *ClusterExtensionDescription) Create(oc *exutil.CLI) {
e2e.Logf("=========Create clusterextension %v=========", clusterextension.Name)
err := clusterextension.CreateWithoutCheck(oc)
o.Expect(err).NotTo(o.HaveOccurred())
clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0)
clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0)
clusterextension.GetBundleResource(oc)
}
func (clusterextension *ClusterExtensionDescription) CreateWithoutCheck(oc *exutil.CLI) error {
e2e.Logf("=========CreateWithoutCheck clusterextension %v=========", clusterextension.Name)
paremeters := []string{"-n", "default", "--ignore-unknown-parameters=true", "-f", clusterextension.Template, "-p"}
if len(clusterextension.Name) > 0 {
paremeters = append(paremeters, "NAME="+clusterextension.Name)
}
if len(clusterextension.PackageName) > 0 {
paremeters = append(paremeters, "PACKAGE="+clusterextension.PackageName)
}
if len(clusterextension.Channel) > 0 {
paremeters = append(paremeters, "CHANNEL="+clusterextension.Channel)
}
if len(clusterextension.Version) > 0 {
paremeters = append(paremeters, "VERSION="+clusterextension.Version)
}
if len(clusterextension.InstallNamespace) > 0 {
paremeters = append(paremeters, "INSTALLNAMESPACE="+clusterextension.InstallNamespace)
}
if len(clusterextension.SaName) > 0 {
paremeters = append(paremeters, "SANAME="+clusterextension.SaName)
}
if len(clusterextension.UpgradeConstraintPolicy) > 0 {
paremeters = append(paremeters, "POLICY="+clusterextension.UpgradeConstraintPolicy)
}
if len(clusterextension.LabelKey) > 0 {
paremeters = append(paremeters, "LABELKEY="+clusterextension.LabelKey)
}
if len(clusterextension.LabelValue) > 0 {
paremeters = append(paremeters, "LABELVALUE="+clusterextension.LabelValue)
}
if len(clusterextension.ExpressionsKey) > 0 {
paremeters = append(paremeters, "EXPRESSIONSKEY="+clusterextension.ExpressionsKey)
}
if len(clusterextension.ExpressionsOperator) > 0 {
paremeters = append(paremeters, "EXPRESSIONSOPERATOR="+clusterextension.ExpressionsOperator)
}
if len(clusterextension.ExpressionsValue1) > 0 {
paremeters = append(paremeters, "EXPRESSIONSVALUE1="+clusterextension.ExpressionsValue1)
}
if len(clusterextension.ExpressionsValue2) > 0 {
paremeters = append(paremeters, "EXPRESSIONSVALUE2="+clusterextension.ExpressionsValue2)
}
if len(clusterextension.ExpressionsValue3) > 0 {
paremeters = append(paremeters, "EXPRESSIONSVALUE3="+clusterextension.ExpressionsValue3)
}
if len(clusterextension.SourceType) > 0 {
paremeters = append(paremeters, "SOURCETYPE="+clusterextension.SourceType)
}
err := exutil.ApplyClusterResourceFromTemplateWithError(oc, paremeters...)
return err
}
func (clusterextension *ClusterExtensionDescription) WaitClusterExtensionCondition(oc *exutil.CLI, conditionType string, status string, consistentTime int) {
e2e.Logf("========= wait clusterextension %v %s status is %s =========", clusterextension.Name, conditionType, status)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].status}`, conditionType)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", output, err)
return false, nil
}
if !strings.Contains(strings.ToLower(output), strings.ToLower(status)) {
e2e.Logf("status is %v, not %v, and try next", output, status)
return false, nil
}
return true, nil
})
if errWait != nil {
GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension %s status is not %s", conditionType, status))
}
if consistentTime != 0 {
e2e.Logf("make sure clusterextension %s status is %s consistently for %ds", conditionType, status, consistentTime)
o.Consistently(func() string {
output, _ := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
return strings.ToLower(output)
}, time.Duration(consistentTime)*time.Second, 5*time.Second).Should(o.ContainSubstring(strings.ToLower(status)),
"clusterextension %s status is not %s", conditionType, status)
}
}
func (clusterextension *ClusterExtensionDescription) CheckClusterExtensionCondition(oc *exutil.CLI, conditionType, field, expect string, checkInterval, checkTimeout, consistentTime int) {
e2e.Logf("========= check clusterextension %v %s %s expect is %s =========", clusterextension.Name, conditionType, field, expect)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].%s}`, conditionType, field)
errWait := wait.PollUntilContextTimeout(context.TODO(), time.Duration(checkInterval)*time.Second, time.Duration(checkTimeout)*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", output, err)
return false, nil
}
if !strings.Contains(strings.ToLower(output), strings.ToLower(expect)) {
e2e.Logf("got is %v, not %v, and try next", output, expect)
return false, nil
}
return true, nil
})
if errWait != nil {
GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension %s expected is not %s in %v seconds", conditionType, expect, checkTimeout))
}
if consistentTime != 0 {
e2e.Logf("make sure clusterextension %s expect is %s consistently for %ds", conditionType, expect, consistentTime)
o.Consistently(func() string {
output, _ := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
return strings.ToLower(output)
}, time.Duration(consistentTime)*time.Second, 5*time.Second).Should(o.ContainSubstring(strings.ToLower(expect)),
"clusterextension %s expected is not %s", conditionType, expect)
}
}
func (clusterextension *ClusterExtensionDescription) GetClusterExtensionMessage(oc *exutil.CLI, conditionType string) string {
var message string
e2e.Logf("========= return clusterextension %v %s message =========", clusterextension.Name, conditionType)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].message}`, conditionType)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
var err error
message, err = Get(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("message is %v, error is %v, and try next", message, err)
return false, nil
}
return true, nil
})
if errWait != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("can't get clusterextension %s message", conditionType))
}
return message
}
func (clusterextension *ClusterExtensionDescription) WaitProgressingMessage(oc *exutil.CLI, expect string) {
e2e.Logf("========= wait clusterextension %v Progressing message includes %s =========", clusterextension.Name, expect)
jsonpath := `jsonpath={.status.conditions[?(@.type=="Progressing")].message}`
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", output, err)
return false, nil
}
if !strings.Contains(output, expect) {
e2e.Logf("message is %v, not include %v, and try next", output, expect)
return false, nil
}
return true, nil
})
if errWait != nil {
GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension progressing message does not include %s", expect))
}
}
func (clusterextension *ClusterExtensionDescription) GetClusterExtensionField(oc *exutil.CLI, conditionType, field string) string {
var content string
e2e.Logf("========= return clusterextension %v %s %s =========", clusterextension.Name, conditionType, field)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].%s}`, conditionType, field)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
var err error
content, err = Get(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("content is %v, error is %v, and try next", content, err)
return false, nil
}
return true, nil
})
if errWait != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("can't get clusterextension %s %s", conditionType, field))
}
return content
}
func (clusterextension *ClusterExtensionDescription) GetBundleResource(oc *exutil.CLI) {
e2e.Logf("=========Get clusterextension %v BundleResource =========", clusterextension.Name)
installedBundle, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.install.bundle.name}")
if err != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
}
o.Expect(err).NotTo(o.HaveOccurred())
clusterextension.InstalledBundle = installedBundle
}
func (clusterextension *ClusterExtensionDescription) Patch(oc *exutil.CLI, patch string) {
_, err := oc.AsAdmin().WithoutNamespace().Run("patch").Args("clusterextension", clusterextension.Name, "--type", "merge", "-p", patch).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}
func (clusterextension *ClusterExtensionDescription) DeleteWithoutCheck(oc *exutil.CLI) {
e2e.Logf("=========DeleteWithoutCheck clusterextension %v=========", clusterextension.Name)
exutil.CleanupResource(oc, 4*time.Second, 160*time.Second, exutil.AsAdmin, exutil.WithoutNamespace, "clusterextension", clusterextension.Name)
}
func (clusterextension *ClusterExtensionDescription) Delete(oc *exutil.CLI) {
e2e.Logf("=========Delete clusterextension %v=========", clusterextension.Name)
clusterextension.DeleteWithoutCheck(oc)
//add check later
}
func (clusterextension *ClusterExtensionDescription) WaitClusterExtensionVersion(oc *exutil.CLI, version string) {
e2e.Logf("========= wait clusterextension %v version is %s =========", clusterextension.Name, version)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
installedBundle, _ := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.install.bundle.name}")
if strings.Contains(installedBundle, version) {
e2e.Logf("version is %v", installedBundle)
return true, nil
}
e2e.Logf("version is %v, not %s, and try next", installedBundle, version)
return false, nil
})
if errWait != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension version is not %s", version))
}
}
|
package olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
66dca6c5-9b45-486c-893d-e31d0b593f67
|
Create
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) Create(oc *exutil.CLI) {
e2e.Logf("=========Create clusterextension %v=========", clusterextension.Name)
err := clusterextension.CreateWithoutCheck(oc)
o.Expect(err).NotTo(o.HaveOccurred())
clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0)
clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0)
clusterextension.GetBundleResource(oc)
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
7461c70f-34dd-4463-be77-7363315f4eb0
|
CreateWithoutCheck
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) CreateWithoutCheck(oc *exutil.CLI) error {
e2e.Logf("=========CreateWithoutCheck clusterextension %v=========", clusterextension.Name)
paremeters := []string{"-n", "default", "--ignore-unknown-parameters=true", "-f", clusterextension.Template, "-p"}
if len(clusterextension.Name) > 0 {
paremeters = append(paremeters, "NAME="+clusterextension.Name)
}
if len(clusterextension.PackageName) > 0 {
paremeters = append(paremeters, "PACKAGE="+clusterextension.PackageName)
}
if len(clusterextension.Channel) > 0 {
paremeters = append(paremeters, "CHANNEL="+clusterextension.Channel)
}
if len(clusterextension.Version) > 0 {
paremeters = append(paremeters, "VERSION="+clusterextension.Version)
}
if len(clusterextension.InstallNamespace) > 0 {
paremeters = append(paremeters, "INSTALLNAMESPACE="+clusterextension.InstallNamespace)
}
if len(clusterextension.SaName) > 0 {
paremeters = append(paremeters, "SANAME="+clusterextension.SaName)
}
if len(clusterextension.UpgradeConstraintPolicy) > 0 {
paremeters = append(paremeters, "POLICY="+clusterextension.UpgradeConstraintPolicy)
}
if len(clusterextension.LabelKey) > 0 {
paremeters = append(paremeters, "LABELKEY="+clusterextension.LabelKey)
}
if len(clusterextension.LabelValue) > 0 {
paremeters = append(paremeters, "LABELVALUE="+clusterextension.LabelValue)
}
if len(clusterextension.ExpressionsKey) > 0 {
paremeters = append(paremeters, "EXPRESSIONSKEY="+clusterextension.ExpressionsKey)
}
if len(clusterextension.ExpressionsOperator) > 0 {
paremeters = append(paremeters, "EXPRESSIONSOPERATOR="+clusterextension.ExpressionsOperator)
}
if len(clusterextension.ExpressionsValue1) > 0 {
paremeters = append(paremeters, "EXPRESSIONSVALUE1="+clusterextension.ExpressionsValue1)
}
if len(clusterextension.ExpressionsValue2) > 0 {
paremeters = append(paremeters, "EXPRESSIONSVALUE2="+clusterextension.ExpressionsValue2)
}
if len(clusterextension.ExpressionsValue3) > 0 {
paremeters = append(paremeters, "EXPRESSIONSVALUE3="+clusterextension.ExpressionsValue3)
}
if len(clusterextension.SourceType) > 0 {
paremeters = append(paremeters, "SOURCETYPE="+clusterextension.SourceType)
}
err := exutil.ApplyClusterResourceFromTemplateWithError(oc, paremeters...)
return err
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
2b366ed1-4f51-4454-9a66-46793e344e20
|
WaitClusterExtensionCondition
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"strings"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) WaitClusterExtensionCondition(oc *exutil.CLI, conditionType string, status string, consistentTime int) {
e2e.Logf("========= wait clusterextension %v %s status is %s =========", clusterextension.Name, conditionType, status)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].status}`, conditionType)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", output, err)
return false, nil
}
if !strings.Contains(strings.ToLower(output), strings.ToLower(status)) {
e2e.Logf("status is %v, not %v, and try next", output, status)
return false, nil
}
return true, nil
})
if errWait != nil {
GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension %s status is not %s", conditionType, status))
}
if consistentTime != 0 {
e2e.Logf("make sure clusterextension %s status is %s consistently for %ds", conditionType, status, consistentTime)
o.Consistently(func() string {
output, _ := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
return strings.ToLower(output)
}, time.Duration(consistentTime)*time.Second, 5*time.Second).Should(o.ContainSubstring(strings.ToLower(status)),
"clusterextension %s status is not %s", conditionType, status)
}
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
28595c91-a392-4c42-a464-b60a55a42338
|
CheckClusterExtensionCondition
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"strings"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) CheckClusterExtensionCondition(oc *exutil.CLI, conditionType, field, expect string, checkInterval, checkTimeout, consistentTime int) {
e2e.Logf("========= check clusterextension %v %s %s expect is %s =========", clusterextension.Name, conditionType, field, expect)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].%s}`, conditionType, field)
errWait := wait.PollUntilContextTimeout(context.TODO(), time.Duration(checkInterval)*time.Second, time.Duration(checkTimeout)*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", output, err)
return false, nil
}
if !strings.Contains(strings.ToLower(output), strings.ToLower(expect)) {
e2e.Logf("got is %v, not %v, and try next", output, expect)
return false, nil
}
return true, nil
})
if errWait != nil {
GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension %s expected is not %s in %v seconds", conditionType, expect, checkTimeout))
}
if consistentTime != 0 {
e2e.Logf("make sure clusterextension %s expect is %s consistently for %ds", conditionType, expect, consistentTime)
o.Consistently(func() string {
output, _ := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
return strings.ToLower(output)
}, time.Duration(consistentTime)*time.Second, 5*time.Second).Should(o.ContainSubstring(strings.ToLower(expect)),
"clusterextension %s expected is not %s", conditionType, expect)
}
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
ea3ee3bb-dc97-4e34-9ddc-d09774e1cf5b
|
GetClusterExtensionMessage
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) GetClusterExtensionMessage(oc *exutil.CLI, conditionType string) string {
var message string
e2e.Logf("========= return clusterextension %v %s message =========", clusterextension.Name, conditionType)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].message}`, conditionType)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
var err error
message, err = Get(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("message is %v, error is %v, and try next", message, err)
return false, nil
}
return true, nil
})
if errWait != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("can't get clusterextension %s message", conditionType))
}
return message
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
8073493e-7386-4ee4-943d-86ccc763d817
|
WaitProgressingMessage
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"strings"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) WaitProgressingMessage(oc *exutil.CLI, expect string) {
e2e.Logf("========= wait clusterextension %v Progressing message includes %s =========", clusterextension.Name, expect)
jsonpath := `jsonpath={.status.conditions[?(@.type=="Progressing")].message}`
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", output, err)
return false, nil
}
if !strings.Contains(output, expect) {
e2e.Logf("message is %v, not include %v, and try next", output, expect)
return false, nil
}
return true, nil
})
if errWait != nil {
GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension progressing message does not include %s", expect))
}
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
30c7220b-a94f-4c72-a9e5-b58c513070df
|
GetClusterExtensionField
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) GetClusterExtensionField(oc *exutil.CLI, conditionType, field string) string {
var content string
e2e.Logf("========= return clusterextension %v %s %s =========", clusterextension.Name, conditionType, field)
jsonpath := fmt.Sprintf(`jsonpath={.status.conditions[?(@.type=="%s")].%s}`, conditionType, field)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
var err error
content, err = Get(oc, "clusterextension", clusterextension.Name, "-o", jsonpath)
if err != nil {
e2e.Logf("content is %v, error is %v, and try next", content, err)
return false, nil
}
return true, nil
})
if errWait != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("can't get clusterextension %s %s", conditionType, field))
}
return content
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
7e396726-f09e-4b94-b109-ecc3e80251e2
|
GetBundleResource
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) GetBundleResource(oc *exutil.CLI) {
e2e.Logf("=========Get clusterextension %v BundleResource =========", clusterextension.Name)
installedBundle, err := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.install.bundle.name}")
if err != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
}
o.Expect(err).NotTo(o.HaveOccurred())
clusterextension.InstalledBundle = installedBundle
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
55295eab-762c-4147-803a-36e6d9d52324
|
Patch
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) Patch(oc *exutil.CLI, patch string) {
_, err := oc.AsAdmin().WithoutNamespace().Run("patch").Args("clusterextension", clusterextension.Name, "--type", "merge", "-p", patch).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
a215fcd1-bf80-4827-a92c-fd7f4a759d85
|
DeleteWithoutCheck
|
['"time"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) DeleteWithoutCheck(oc *exutil.CLI) {
e2e.Logf("=========DeleteWithoutCheck clusterextension %v=========", clusterextension.Name)
exutil.CleanupResource(oc, 4*time.Second, 160*time.Second, exutil.AsAdmin, exutil.WithoutNamespace, "clusterextension", clusterextension.Name)
}
|
olmv1util
| |||
function
|
openshift/openshift-tests-private
|
1407d2a7-196d-4382-8101-95c304962f58
|
Delete
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) Delete(oc *exutil.CLI) {
e2e.Logf("=========Delete clusterextension %v=========", clusterextension.Name)
clusterextension.DeleteWithoutCheck(oc)
//add check later
}
|
olmv1util
| ||||
function
|
openshift/openshift-tests-private
|
47a88f22-ecc3-425f-89b6-c87886f521c1
|
WaitClusterExtensionVersion
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', '"strings"']
|
['ClusterExtensionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operators/olmv1util/clusterextension.go
|
func (clusterextension *ClusterExtensionDescription) WaitClusterExtensionVersion(oc *exutil.CLI, version string) {
e2e.Logf("========= wait clusterextension %v version is %s =========", clusterextension.Name, version)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
installedBundle, _ := GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.install.bundle.name}")
if strings.Contains(installedBundle, version) {
e2e.Logf("version is %v", installedBundle)
return true, nil
}
e2e.Logf("version is %v, not %s, and try next", installedBundle, version)
return false, nil
})
if errWait != nil {
Get(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("clusterextension version is not %s", version))
}
}
|
olmv1util
| |||
file
|
openshift/openshift-tests-private
|
61d4fd4b-03c2-40bd-9e74-6110a1e477c7
|
client
|
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"runtime/debug"
"strings"
"time"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
package operatorsdk
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"runtime/debug"
"strings"
"time"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
// CLI provides function to call the Operator-sdk CLI
type CLI struct {
execPath string
verb string
username string
globalArgs []string
commandArgs []string
finalArgs []string
stdin *bytes.Buffer
stdout io.Writer
stderr io.Writer
verbose bool
showInfo bool
skipTLS bool
ExecCommandPath string
env []string
}
// NewOperatorSDKCLI initialize the SDK framework
func NewOperatorSDKCLI() *CLI {
client := &CLI{}
client.username = "admin"
client.execPath = "operator-sdk"
client.showInfo = true
return client
}
// NewMakeCLI initialize the make framework
func NewMakeCLI() *CLI {
client := &CLI{}
client.username = "admin"
client.execPath = "make"
client.showInfo = true
return client
}
// NewMVNCLI initialize the make framework
func NewMVNCLI() *CLI {
client := &CLI{}
client.username = "admin"
client.execPath = "mvn"
client.showInfo = true
return client
}
// Run executes given OperatorSDK command verb
func (c *CLI) Run(commands ...string) *CLI {
in, out, errout := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
operatorsdk := &CLI{
execPath: c.execPath,
verb: commands[0],
username: c.username,
showInfo: c.showInfo,
ExecCommandPath: c.ExecCommandPath,
env: c.env,
}
if c.skipTLS {
operatorsdk.globalArgs = append([]string{"--skip-tls=true"}, commands...)
} else {
operatorsdk.globalArgs = commands
}
operatorsdk.stdin, operatorsdk.stdout, operatorsdk.stderr = in, out, errout
return operatorsdk.setOutput(c.stdout)
}
// setOutput allows to override the default command output
func (c *CLI) setOutput(out io.Writer) *CLI {
c.stdout = out
return c
}
// Args sets the additional arguments for the OpenShift CLI command
func (c *CLI) Args(args ...string) *CLI {
c.commandArgs = args
c.finalArgs = append(c.globalArgs, c.commandArgs...)
return c
}
func (c *CLI) printCmd() string {
return strings.Join(c.finalArgs, " ")
}
// ExitError returns the error info
type ExitError struct {
Cmd string
StdErr string
*exec.ExitError
}
// FatalErr exits the test in case a fatal error has occurred.
func FatalErr(msg interface{}) {
// the path that leads to this being called isn't always clear...
fmt.Fprintln(g.GinkgoWriter, string(debug.Stack()))
e2e.Failf("%v", msg)
}
// Output executes the command and returns stdout/stderr combined into one string
func (c *CLI) Output() (string, error) {
if c.verbose {
e2e.Logf("DEBUG: opm %s\n", c.printCmd())
}
cmd := exec.Command(c.execPath, c.finalArgs...)
cmd.Env = os.Environ()
if c.env != nil {
cmd.Env = append(cmd.Env, c.env...)
}
if c.ExecCommandPath != "" {
e2e.Logf("set exec command path is %s\n", c.ExecCommandPath)
cmd.Dir = c.ExecCommandPath
}
cmd.Stdin = c.stdin
if c.showInfo {
e2e.Logf("Running '%s %s'", c.execPath, strings.Join(c.finalArgs, " "))
}
out, err := cmd.CombinedOutput()
trimmed := strings.TrimSpace(string(out))
switch err := err.(type) {
case nil:
c.stdout = bytes.NewBuffer(out)
return trimmed, nil
case *exec.ExitError:
e2e.Logf("Error running %v:\n%s", cmd, trimmed)
return trimmed, &ExitError{ExitError: err, Cmd: c.execPath + " " + strings.Join(c.finalArgs, " "), StdErr: trimmed}
default:
FatalErr(fmt.Errorf("unable to execute %q: %v", c.execPath, err))
// unreachable code
return "", nil
}
}
// The method is to get random string with length 8.
func getRandomString() string {
chars := "abcdefghijklmnopqrstuvwxyz0123456789"
seed := rand.New(rand.NewSource(time.Now().UnixNano()))
buffer := make([]byte, 8)
for index := range buffer {
buffer[index] = chars[seed.Intn(len(chars))]
}
return string(buffer)
}
func replaceContent(filePath, src, target string) {
input, err := ioutil.ReadFile(filePath)
if err != nil {
FatalErr(fmt.Errorf("read file %s failed: %v", filePath, err))
}
output := bytes.Replace(input, []byte(src), []byte(target), -1)
if err = ioutil.WriteFile(filePath, output, 0o755); err != nil {
FatalErr(fmt.Errorf("write file %s failed: %v", filePath, err))
}
}
func getContent(filePath string) string {
content, err := ioutil.ReadFile(filePath)
o.Expect(err).NotTo(o.HaveOccurred())
return string(content)
}
func insertContent(filePath, src, insertStr string) {
input, err := ioutil.ReadFile(filePath)
if err != nil {
FatalErr(fmt.Errorf("read file %s failed: %v", filePath, err))
}
contents := string(input)
lines := strings.Split(contents, "\n")
var newLines []string
for _, line := range lines {
newLines = append(newLines, line)
if strings.Contains(line, src) {
newLines = append(newLines, insertStr)
}
}
output := []byte(strings.Join(newLines, "\n"))
if err = ioutil.WriteFile(filePath, output, 0o755); err != nil {
FatalErr(fmt.Errorf("write file %s failed: %v", filePath, err))
}
}
func copy(src, target string) error {
bytesRead, err := ioutil.ReadFile(src)
if err != nil {
return err
}
err = ioutil.WriteFile(target, bytesRead, 0o755)
if err != nil {
return err
}
return nil
}
func notInList(target string, strArray []string) bool {
for _, element := range strArray {
if target == element {
return false
}
}
return true
}
func logDebugInfo(oc *exutil.CLI, ns string, resource ...string) {
for _, resourceIndex := range resource {
e2e.Logf("oc get %s:", resourceIndex)
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args(resourceIndex, "-n", ns).Output()
if strings.Contains(resourceIndex, "event") {
var warningEventList []string
lines := strings.Split(output, "\n")
for _, line := range lines {
if strings.Contains(line, "Warning") {
warningStr := strings.Split(line, "Warning")[1]
if notInList(warningStr, warningEventList) {
warningEventList = append(warningEventList, "Warning"+warningStr)
}
}
}
e2e.Logf(strings.Join(warningEventList, "\n"))
} else {
e2e.Logf(output)
}
}
}
// The method is to create one resource with template
func applyResourceFromTemplate(oc *exutil.CLI, parameters ...string) error {
var configFile string
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 15*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := oc.AsAdmin().Run("process").Args(parameters...).OutputToFile(getRandomString() + "olm-config.json")
if err != nil {
e2e.Logf("the err:%v, and try next round", err)
return false, nil
}
configFile = output
return true, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not process %v", parameters))
e2e.Logf("the file of resource is %s", configFile)
return oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", configFile).Execute()
}
type clusterrolebindingDescription struct {
name string
namespace string
saname string
template string
}
// The method is to create role with template
func (clusterrolebinding *clusterrolebindingDescription) create(oc *exutil.CLI) {
err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", clusterrolebinding.template,
"-p", "NAME="+clusterrolebinding.name, "NAMESPACE="+clusterrolebinding.namespace, "SA_NAME="+clusterrolebinding.saname)
o.Expect(err).NotTo(o.HaveOccurred())
}
|
package operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
cbe39dda-5d3f-4da5-ab2c-438c87b42c13
|
NewOperatorSDKCLI
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func NewOperatorSDKCLI() *CLI {
client := &CLI{}
client.username = "admin"
client.execPath = "operator-sdk"
client.showInfo = true
return client
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
c3fb4bd0-7d81-4b95-9c4f-144782d3ea32
|
NewMakeCLI
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func NewMakeCLI() *CLI {
client := &CLI{}
client.username = "admin"
client.execPath = "make"
client.showInfo = true
return client
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
9e5f1ed2-00e3-4d7d-ab5d-845c27b052d9
|
NewMVNCLI
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func NewMVNCLI() *CLI {
client := &CLI{}
client.username = "admin"
client.execPath = "mvn"
client.showInfo = true
return client
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
32b7154d-5eff-4662-9b77-ddd93e81ccfd
|
Run
|
['"bytes"']
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func (c *CLI) Run(commands ...string) *CLI {
in, out, errout := &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}
operatorsdk := &CLI{
execPath: c.execPath,
verb: commands[0],
username: c.username,
showInfo: c.showInfo,
ExecCommandPath: c.ExecCommandPath,
env: c.env,
}
if c.skipTLS {
operatorsdk.globalArgs = append([]string{"--skip-tls=true"}, commands...)
} else {
operatorsdk.globalArgs = commands
}
operatorsdk.stdin, operatorsdk.stdout, operatorsdk.stderr = in, out, errout
return operatorsdk.setOutput(c.stdout)
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
9f94bdf7-ee16-4ad0-b3ae-9614f43ca849
|
setOutput
|
['"io"']
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func (c *CLI) setOutput(out io.Writer) *CLI {
c.stdout = out
return c
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
2445ac54-cf25-4763-969c-e013b1681840
|
Args
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func (c *CLI) Args(args ...string) *CLI {
c.commandArgs = args
c.finalArgs = append(c.globalArgs, c.commandArgs...)
return c
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
ea2ac728-11e3-40de-badb-a28c2a68c4ca
|
printCmd
|
['"strings"']
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func (c *CLI) printCmd() string {
return strings.Join(c.finalArgs, " ")
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
c703c4ba-9dc2-40da-aa1a-a6bec4b432d5
|
FatalErr
|
['"fmt"', '"runtime/debug"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func FatalErr(msg interface{}) {
// the path that leads to this being called isn't always clear...
fmt.Fprintln(g.GinkgoWriter, string(debug.Stack()))
e2e.Failf("%v", msg)
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
9821ba69-9e8b-48bd-98dd-ee26d169b25d
|
Output
|
['"bytes"', '"fmt"', '"os"', '"os/exec"', '"strings"']
|
['CLI', 'ExitError']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func (c *CLI) Output() (string, error) {
if c.verbose {
e2e.Logf("DEBUG: opm %s\n", c.printCmd())
}
cmd := exec.Command(c.execPath, c.finalArgs...)
cmd.Env = os.Environ()
if c.env != nil {
cmd.Env = append(cmd.Env, c.env...)
}
if c.ExecCommandPath != "" {
e2e.Logf("set exec command path is %s\n", c.ExecCommandPath)
cmd.Dir = c.ExecCommandPath
}
cmd.Stdin = c.stdin
if c.showInfo {
e2e.Logf("Running '%s %s'", c.execPath, strings.Join(c.finalArgs, " "))
}
out, err := cmd.CombinedOutput()
trimmed := strings.TrimSpace(string(out))
switch err := err.(type) {
case nil:
c.stdout = bytes.NewBuffer(out)
return trimmed, nil
case *exec.ExitError:
e2e.Logf("Error running %v:\n%s", cmd, trimmed)
return trimmed, &ExitError{ExitError: err, Cmd: c.execPath + " " + strings.Join(c.finalArgs, " "), StdErr: trimmed}
default:
FatalErr(fmt.Errorf("unable to execute %q: %v", c.execPath, err))
// unreachable code
return "", nil
}
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
01165d9d-3a5c-45e1-8c6e-72485ee95743
|
getRandomString
|
['"math/rand"', '"time"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func getRandomString() string {
chars := "abcdefghijklmnopqrstuvwxyz0123456789"
seed := rand.New(rand.NewSource(time.Now().UnixNano()))
buffer := make([]byte, 8)
for index := range buffer {
buffer[index] = chars[seed.Intn(len(chars))]
}
return string(buffer)
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
4b6a2283-3d69-40de-beda-e074ead19afd
|
replaceContent
|
['"bytes"', '"fmt"', '"io/ioutil"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func replaceContent(filePath, src, target string) {
input, err := ioutil.ReadFile(filePath)
if err != nil {
FatalErr(fmt.Errorf("read file %s failed: %v", filePath, err))
}
output := bytes.Replace(input, []byte(src), []byte(target), -1)
if err = ioutil.WriteFile(filePath, output, 0o755); err != nil {
FatalErr(fmt.Errorf("write file %s failed: %v", filePath, err))
}
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
0fc046ad-6137-4a83-941e-a1938785fd7f
|
getContent
|
['"io/ioutil"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func getContent(filePath string) string {
content, err := ioutil.ReadFile(filePath)
o.Expect(err).NotTo(o.HaveOccurred())
return string(content)
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
02ec71b9-7cc6-46f1-9ba3-c7c0397b82ca
|
insertContent
|
['"fmt"', '"io/ioutil"', '"strings"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func insertContent(filePath, src, insertStr string) {
input, err := ioutil.ReadFile(filePath)
if err != nil {
FatalErr(fmt.Errorf("read file %s failed: %v", filePath, err))
}
contents := string(input)
lines := strings.Split(contents, "\n")
var newLines []string
for _, line := range lines {
newLines = append(newLines, line)
if strings.Contains(line, src) {
newLines = append(newLines, insertStr)
}
}
output := []byte(strings.Join(newLines, "\n"))
if err = ioutil.WriteFile(filePath, output, 0o755); err != nil {
FatalErr(fmt.Errorf("write file %s failed: %v", filePath, err))
}
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
8223e492-caed-4921-b624-23392a88bce5
|
copy
|
['"io/ioutil"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func copy(src, target string) error {
bytesRead, err := ioutil.ReadFile(src)
if err != nil {
return err
}
err = ioutil.WriteFile(target, bytesRead, 0o755)
if err != nil {
return err
}
return nil
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
dc0ad6ec-da7f-4b2c-b7df-9b220a754fb1
|
notInList
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func notInList(target string, strArray []string) bool {
for _, element := range strArray {
if target == element {
return false
}
}
return true
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
532de0ca-a490-4add-a0a7-e64f4f6a4e82
|
logDebugInfo
|
['"strings"']
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func logDebugInfo(oc *exutil.CLI, ns string, resource ...string) {
for _, resourceIndex := range resource {
e2e.Logf("oc get %s:", resourceIndex)
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args(resourceIndex, "-n", ns).Output()
if strings.Contains(resourceIndex, "event") {
var warningEventList []string
lines := strings.Split(output, "\n")
for _, line := range lines {
if strings.Contains(line, "Warning") {
warningStr := strings.Split(line, "Warning")[1]
if notInList(warningStr, warningEventList) {
warningEventList = append(warningEventList, "Warning"+warningStr)
}
}
}
e2e.Logf(strings.Join(warningEventList, "\n"))
} else {
e2e.Logf(output)
}
}
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
2d03840e-facd-4b2d-846a-2ccdef40fc4d
|
applyResourceFromTemplate
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
['CLI']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func applyResourceFromTemplate(oc *exutil.CLI, parameters ...string) error {
var configFile string
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 15*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := oc.AsAdmin().Run("process").Args(parameters...).OutputToFile(getRandomString() + "olm-config.json")
if err != nil {
e2e.Logf("the err:%v, and try next round", err)
return false, nil
}
configFile = output
return true, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not process %v", parameters))
e2e.Logf("the file of resource is %s", configFile)
return oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", configFile).Execute()
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
7e4d145b-5e8d-476e-a9c6-2cb847bc4a9b
|
create
|
['CLI', 'clusterrolebindingDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/client.go
|
func (clusterrolebinding *clusterrolebindingDescription) create(oc *exutil.CLI) {
err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", clusterrolebinding.template,
"-p", "NAME="+clusterrolebinding.name, "NAMESPACE="+clusterrolebinding.namespace, "SA_NAME="+clusterrolebinding.saname)
o.Expect(err).NotTo(o.HaveOccurred())
}
|
operatorsdk
| ||||
test
|
openshift/openshift-tests-private
|
42a187e8-b1cc-49e5-820c-c7d09470f616
|
util
|
import (
"context"
"fmt"
"strings"
"time"
o "github.com/onsi/gomega"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
"github.com/openshift/openshift-tests-private/test/extended/util/architecture"
container "github.com/openshift/openshift-tests-private/test/extended/util/container"
"github.com/tidwall/gjson"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
package operatorsdk
import (
"context"
"fmt"
"strings"
"time"
o "github.com/onsi/gomega"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
"github.com/openshift/openshift-tests-private/test/extended/util/architecture"
container "github.com/openshift/openshift-tests-private/test/extended/util/container"
"github.com/tidwall/gjson"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
const (
asAdmin = true
asUser = false
withoutNamespace = true
withNamespace = false
compare = true
contain = false
requireNS = true
notRequireNS = false
present = true
notPresent = false
ok = true
nok = false
)
func buildPushOperatorImage(architecture architecture.Architecture, tmpPath, imageTag, tokenDir string) {
exutil.By("Build and Push the operator image with architecture")
podmanCLI := container.NewPodmanCLI()
podmanCLI.ExecCommandPath = tmpPath
output, err := podmanCLI.Run("build").Args(tmpPath, "--arch", architecture.String(), "--tag", imageTag,
"--authfile", fmt.Sprintf("%s/.dockerconfigjson", tokenDir)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
imagePushOutput, _ := podmanCLI.Run("push").Args(imageTag).Output()
if strings.Contains(imagePushOutput, "Writing manifest to image destination") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.")
}
type subscriptionDescription struct {
subName string `json:"name"`
namespace string `json:"namespace"`
channel string `json:"channel"`
ipApproval string `json:"installPlanApproval"`
operatorPackage string `json:"spec.name"`
catalogSourceName string `json:"source"`
catalogSourceNamespace string `json:"sourceNamespace"`
startingCSV string `json:"startingCSV,omitempty"`
installedCSV string
template string
}
// the method is to just create sub, and save it to dr, do not check its state.
func (sub *subscriptionDescription) createWithoutCheck(oc *exutil.CLI, itName string, dr describerResrouce) {
// for most operator subscription failure, the reason is that there is a left cluster-scoped CSV.
// I'd like to print all CSV before create it.
// It prints many lines which descrease the exact match for RP, and increase log size.
// So, change it to one line with necessary information csv name and namespace.
allCSVs, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "--all-namespaces", "-o=jsonpath={range .items[*]}{@.metadata.name}{\",\"}{@.metadata.namespace}{\":\"}{end}").Output()
if err != nil {
e2e.Failf("!!! Couldn't get all CSVs:%v\n", err)
}
csvMap := make(map[string][]string)
csvList := strings.Split(allCSVs, ":")
for _, csv := range csvList {
if strings.Compare(csv, "") == 0 {
continue
}
name := strings.Split(csv, ",")[0]
ns := strings.Split(csv, ",")[1]
val, ok := csvMap[name]
if ok {
if strings.HasPrefix(ns, "openshift-") {
alreadyOpenshiftDefaultNS := false
for _, v := range val {
if strings.Contains(v, "openshift-") {
alreadyOpenshiftDefaultNS = true // normally one default operator exists in all openshift- ns, like elasticsearch-operator
// only add one openshift- ns to indicate. to save log size and line size. Or else one line
// will be greater than 3k
break
}
}
if !alreadyOpenshiftDefaultNS {
val = append(val, ns)
csvMap[name] = val
}
} else {
val = append(val, ns)
csvMap[name] = val
}
} else {
nsSlice := make([]string, 20)
nsSlice[1] = ns
csvMap[name] = nsSlice
}
}
for name, ns := range csvMap {
e2e.Logf("getting csv is %v, the related NS is %v", name, ns)
}
e2e.Logf("create sub %s", sub.subName)
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", sub.template, "-p", "SUBNAME="+sub.subName, "SUBNAMESPACE="+sub.namespace, "CHANNEL="+sub.channel,
"APPROVAL="+sub.ipApproval, "OPERATORNAME="+sub.operatorPackage, "SOURCENAME="+sub.catalogSourceName, "SOURCENAMESPACE="+sub.catalogSourceNamespace, "STARTINGCSV="+sub.startingCSV)
o.Expect(err).NotTo(o.HaveOccurred())
dr.getIr(itName).add(newResource(oc, "sub", sub.subName, requireNS, sub.namespace))
}
// the method is to check if the sub's state is AtLatestKnown.
// if it is AtLatestKnown, get installed csv from sub and save it to dr.
// if it is not AtLatestKnown, raise error.
func (sub *subscriptionDescription) findInstalledCSV(oc *exutil.CLI, itName string, dr describerResrouce) {
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
state := getResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.state}")
if strings.Compare(state, "AtLatestKnown") == 0 {
return true, nil
}
e2e.Logf("sub %s state is %s, not AtLatestKnown", sub.subName, state)
return false, nil
})
if err != nil {
getResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "-o=jsonpath-as-json={.status}")
getResource(oc, asAdmin, withoutNamespace, "pod", "-n", sub.catalogSourceNamespace)
}
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("sub %s stat is not AtLatestKnown", sub.subName))
installedCSV := getResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.installedCSV}")
o.Expect(installedCSV).NotTo(o.BeEmpty())
if strings.Compare(sub.installedCSV, installedCSV) != 0 {
sub.installedCSV = installedCSV
dr.getIr(itName).add(newResource(oc, "csv", sub.installedCSV, requireNS, sub.namespace))
}
e2e.Logf("the installed CSV name is %s", sub.installedCSV)
}
// the method is to create sub, and save the sub resrouce into dr. and more create csv possible depending on sub.ipApproval
// if sub.ipApproval is Automatic, it will wait the sub's state become AtLatestKnown and get installed csv as sub.installedCSV, and save csv into dr
// if sub.ipApproval is not Automatic, it will just wait sub's state become UpgradePending
func (sub *subscriptionDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) {
// for most operator subscription failure, the reason is that there is a left cluster-scoped CSV.
// I'd like to print all CSV before create it.
// allCSVs, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "--all-namespaces").Output()
// if err != nil {
// e2e.Failf("!!! Couldn't get all CSVs:%v\n", err)
// }
// e2e.Logf("!!! Get all CSVs in this cluster:\n%s\n", allCSVs)
sub.createWithoutCheck(oc, itName, dr)
if strings.Compare(sub.ipApproval, "Automatic") == 0 {
sub.findInstalledCSV(oc, itName, dr)
} else {
newCheck("expect", asAdmin, withoutNamespace, compare, "UpgradePending", ok, []string{"sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.state}"}).check(oc)
}
}
type catalogSourceDescription struct {
name string
namespace string
displayName string
publisher string
sourceType string
address string
template string
secret string
interval string
imageTemplate string
}
// the method is to create catalogsource with template, and save it to dr.
func (catsrc *catalogSourceDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) {
if strings.Compare(catsrc.interval, "") == 0 {
catsrc.interval = "10m0s"
e2e.Logf("set interval to be 10m0s")
}
err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", catsrc.template,
"-p", "NAME="+catsrc.name, "NAMESPACE="+catsrc.namespace, "ADDRESS="+catsrc.address, "SECRET="+catsrc.secret,
"DISPLAYNAME="+"\""+catsrc.displayName+"\"", "PUBLISHER="+"\""+catsrc.publisher+"\"", "SOURCETYPE="+catsrc.sourceType,
"INTERVAL="+catsrc.interval, "IMAGETEMPLATE="+catsrc.imageTemplate)
o.Expect(err).NotTo(o.HaveOccurred())
catsrc.setSCCRestricted(oc)
dr.getIr(itName).add(newResource(oc, "catsrc", catsrc.name, requireNS, catsrc.namespace))
e2e.Logf("create catsrc %s SUCCESS", catsrc.name)
}
func (catsrc *catalogSourceDescription) setSCCRestricted(oc *exutil.CLI) {
output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("configmaps", "-n", "openshift-kube-apiserver", "config", `-o=jsonpath={.data.config\.yaml}`).Output()
o.Expect(err).NotTo(o.HaveOccurred())
psa := gjson.Get(output, "admission.pluginConfig.PodSecurity.configuration.defaults.enforce").String()
e2e.Logf("pod-security.kubernetes.io/enforce is %s", string(psa))
if strings.Contains(string(psa), "restricted") {
originSCC := catsrc.getSCC(oc)
e2e.Logf("spec.grpcPodConfig.securityContextConfig is %s", originSCC)
if strings.Compare(originSCC, "") == 0 {
e2e.Logf("set spec.grpcPodConfig.securityContextConfig to be restricted")
err := oc.AsAdmin().WithoutNamespace().Run("patch").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "--type=merge", "-p", `{"spec":{"grpcPodConfig":{"securityContextConfig":"restricted"}}}`).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
} else {
e2e.Logf("spec.grpcPodConfig.securityContextConfig is not empty, skip setting")
}
}
}
func (catsrc *catalogSourceDescription) getSCC(oc *exutil.CLI) string {
output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.spec.grpcPodConfig.securityContextConfig}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
return output
}
func (catsrc *catalogSourceDescription) createWithCheck(oc *exutil.CLI, itName string, dr describerResrouce) {
catsrc.create(oc, itName, dr)
err := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
status, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.status..lastObservedState}").Output()
if strings.Compare(status, "READY") != 0 {
e2e.Logf("catsrc %s lastObservedState is %s, not READY", catsrc.name, status)
return false, nil
}
return true, nil
})
if err != nil {
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.status}").Output()
e2e.Logf(output)
logDebugInfo(oc, catsrc.namespace, "pod", "events")
}
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("catsrc %s lastObservedState is not READY", catsrc.name))
e2e.Logf("catsrc %s lastObservedState is READY", catsrc.name)
}
type operatorGroupDescription struct {
name string
namespace string
multinslabel string
template string
serviceAccountName string
upgradeStrategy string
}
// the method is to check if og exist. if not existing, create it with template and save it to dr.
// if existing, nothing happen.
func (og *operatorGroupDescription) createwithCheck(oc *exutil.CLI, itName string, dr describerResrouce) {
output, err := doAction(oc, "get", asAdmin, false, "operatorgroup")
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(output, "No resources found") {
e2e.Logf(fmt.Sprintf("No operatorgroup in project: %s, create one: %s", og.namespace, og.name))
og.create(oc, itName, dr)
} else {
e2e.Logf(fmt.Sprintf("Already exist operatorgroup in project: %s", og.namespace))
}
}
// the method is to create og and save it to dr
// if og.multinslabel is not set, it will create og with ownnamespace or allnamespace depending on template
// if og.multinslabel is set, it will create og with multinamespace.
func (og *operatorGroupDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) {
var err error
if strings.Compare(og.multinslabel, "") != 0 && strings.Compare(og.serviceAccountName, "") != 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "MULTINSLABEL="+og.multinslabel, "SERVICE_ACCOUNT_NAME="+og.serviceAccountName)
} else if strings.Compare(og.multinslabel, "") == 0 && strings.Compare(og.serviceAccountName, "") == 0 && strings.Compare(og.upgradeStrategy, "") == 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace)
} else if strings.Compare(og.multinslabel, "") != 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "MULTINSLABEL="+og.multinslabel)
} else if strings.Compare(og.upgradeStrategy, "") != 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "UPGRADESTRATEGY="+og.upgradeStrategy)
} else {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "SERVICE_ACCOUNT_NAME="+og.serviceAccountName)
}
o.Expect(err).NotTo(o.HaveOccurred())
dr.getIr(itName).add(newResource(oc, "og", og.name, requireNS, og.namespace))
e2e.Logf("create og %s success", og.name)
}
type resourceDescription struct {
oc *exutil.CLI
asAdmin bool
withoutNamespace bool
kind string
name string
requireNS bool
namespace string
}
// the method is to construc one resource so that it can be deleted with itResource and describerResrouce
// oc is the oc client
// asAdmin means when deleting resource, we take admin role
// withoutNamespace means when deleting resource, we take WithoutNamespace
// kind is the kind of resource
// name is the name of resource
// namespace is the namesapce of resoruce. it is "" for cluster level resource
// if requireNS is requireNS, need to add "-n" parameter. used for project level resource
// if requireNS is notRequireNS, no need to add "-n". used for cluster level resource
func newResource(oc *exutil.CLI, kind string, name string, nsflag bool, namespace string) resourceDescription {
return resourceDescription{
oc: oc,
asAdmin: asAdmin,
withoutNamespace: withoutNamespace,
kind: kind,
name: name,
requireNS: nsflag,
namespace: namespace,
}
}
// the method is to delete resource.
func (r resourceDescription) delete() {
if r.withoutNamespace && r.requireNS {
removeResource(r.oc, r.asAdmin, r.withoutNamespace, r.kind, r.name, "-n", r.namespace)
} else {
removeResource(r.oc, r.asAdmin, r.withoutNamespace, r.kind, r.name)
}
}
// the struct to save the resource created in g.It, and it take name+kind+namespace as key to save resoruce of g.It.
type itResource map[string]resourceDescription
func (ir itResource) add(r resourceDescription) {
ir[r.name+r.kind+r.namespace] = r
}
func (ir itResource) remove(name string, kind string, namespace string) {
rKey := name + kind + namespace
if r, ok := ir[rKey]; ok {
r.delete()
delete(ir, rKey)
}
}
func (ir itResource) cleanup() {
for _, r := range ir {
e2e.Logf("cleanup resource %s, %s", r.kind, r.name)
ir.remove(r.name, r.kind, r.namespace)
}
}
// the struct is to save g.It in g.Describe, and map the g.It name to itResource so that it can get all resource of g.Describe per g.It.
type describerResrouce map[string]itResource
func (dr describerResrouce) addIr(itName string) {
dr[itName] = itResource{}
}
func (dr describerResrouce) getIr(itName string) itResource {
ir, ok := dr[itName]
if !ok {
e2e.Logf("!!! couldn't find the itName:%s, print the describerResrouce:%v", itName, dr)
}
o.Expect(ok).To(o.BeTrue())
return ir
}
func (dr describerResrouce) rmIr(itName string) {
delete(dr, itName)
}
// the method is to get something from resource. it is "oc get xxx" actaully
// asAdmin means if taking admin to get it
// withoutNamespace means if take WithoutNamespace() to get it.
func getResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) string {
var result string
var err error
err = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
result, err = doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", result, err)
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not get %v", parameters))
e2e.Logf("$oc get %v, the returned resource:%v", parameters, result)
return result
}
// the method is to remove resource
// asAdmin means if taking admin to remove it
// withoutNamespace means if take WithoutNamespace() to remove it.
func removeResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) {
output, err := doAction(oc, "delete", asAdmin, withoutNamespace, parameters...)
if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) {
e2e.Logf("the resource is deleted already")
return
}
o.Expect(err).NotTo(o.HaveOccurred())
err = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) {
e2e.Logf("the resource is delete successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not remove %v", parameters))
}
// the method is to do something with oc.
// asAdmin means if taking admin to do it
// withoutNamespace means if take WithoutNamespace() to do it.
func doAction(oc *exutil.CLI, action string, asAdmin bool, withoutNamespace bool, parameters ...string) (string, error) {
if asAdmin && withoutNamespace {
return oc.AsAdmin().WithoutNamespace().Run(action).Args(parameters...).Output()
}
if asAdmin && !withoutNamespace {
return oc.AsAdmin().Run(action).Args(parameters...).Output()
}
if !asAdmin && withoutNamespace {
return oc.WithoutNamespace().Run(action).Args(parameters...).Output()
}
if !asAdmin && !withoutNamespace {
return oc.Run(action).Args(parameters...).Output()
}
return "", nil
}
type checkDescription struct {
method string
executor bool
inlineNamespace bool
expectAction bool
expectContent string
expect bool
resource []string
}
// the method is to make newCheck object.
// the method parameter is expect, it will check something is expceted or not
// the method parameter is present, it will check something exists or not
// the executor is asAdmin, it will exectue oc with Admin
// the executor is asUser, it will exectue oc with User
// the inlineNamespace is withoutNamespace, it will execute oc with WithoutNamespace()
// the inlineNamespace is withNamespace, it will execute oc with WithNamespace()
// the expectAction take effective when method is expect, if it is contain, it will check if the strings contain substring with expectContent parameter
//
// if it is compare, it will check the strings is samme with expectContent parameter
//
// the expectContent is the content we expected
// the expect is ok, contain or compare result is OK for method == expect, no error raise. if not OK, error raise
// the expect is nok, contain or compare result is NOK for method == expect, no error raise. if OK, error raise
// the expect is ok, resource existing is OK for method == present, no error raise. if resource not existing, error raise
// the expect is nok, resource not existing is OK for method == present, no error raise. if resource existing, error raise
func newCheck(method string, executor bool, inlineNamespace bool, expectAction bool,
expectContent string, expect bool, resource []string) checkDescription {
return checkDescription{
method: method,
executor: executor,
inlineNamespace: inlineNamespace,
expectAction: expectAction,
expectContent: expectContent,
expect: expect,
resource: resource,
}
}
// the method is to check the resource per definition of the above described newCheck.
func (ck checkDescription) check(oc *exutil.CLI) {
switch ck.method {
case "present":
ok := isPresentResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.resource...)
o.Expect(ok).To(o.BeTrue())
case "expect":
err := expectedResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.expectContent, ck.expect, ck.resource...)
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("expected content %s not found by %v", ck.expectContent, ck.resource))
default:
err := fmt.Errorf("unknown method")
o.Expect(err).NotTo(o.HaveOccurred())
}
}
// the method is to check the presence of the resource
// asAdmin means if taking admin to check it
// withoutNamespace means if take WithoutNamespace() to check it.
// present means if you expect the resource presence or not. if it is ok, expect presence. if it is nok, expect not present.
func isPresentResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, present bool, parameters ...string) bool {
parameters = append(parameters, "--ignore-not-found")
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 70*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil {
e2e.Logf("the get error is %v, and try next", err)
return false, nil
}
if !present && strings.Compare(output, "") == 0 {
return true, nil
}
if present && strings.Compare(output, "") != 0 {
return true, nil
}
return false, nil
})
if err != nil {
return false
}
return true
}
// the method is to check one resource's attribution is expected or not.
// asAdmin means if taking admin to check it
// withoutNamespace means if take WithoutNamespace() to check it.
// isCompare means if containing or exactly comparing. if it is contain, it check result contain content. if it is compare, it compare the result with content exactly.
// content is the substing to be expected
// the expect is ok, contain or compare result is OK for method == expect, no error raise. if not OK, error raise
// the expect is nok, contain or compare result is NOK for method == expect, no error raise. if OK, error raise
func expectedResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, isCompare bool, content string, expect bool, parameters ...string) error {
expectMap := map[bool]string{
true: "do",
false: "do not",
}
cc := func(a, b string, ic bool) bool {
bs := strings.Split(b, "+2+")
ret := false
for _, s := range bs {
if (ic && strings.Compare(a, s) == 0) || (!ic && strings.Contains(a, s)) {
ret = true
}
}
return ret
}
e2e.Logf("Running: oc get asAdmin(%t) withoutNamespace(%t) %s", asAdmin, withoutNamespace, strings.Join(parameters, " "))
return wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil {
e2e.Logf("the get error is %v, and try next", err)
return false, nil
}
e2e.Logf("---> we %v expect value: %s, in returned value: %s", expectMap[expect], content, output)
if isCompare && expect && cc(output, content, isCompare) {
e2e.Logf("the output %s matches one of the content %s, expected", output, content)
return true, nil
}
if isCompare && !expect && !cc(output, content, isCompare) {
e2e.Logf("the output %s does not matche the content %s, expected", output, content)
return true, nil
}
if !isCompare && expect && cc(output, content, isCompare) {
e2e.Logf("the output %s contains one of the content %s, expected", output, content)
return true, nil
}
if !isCompare && !expect && !cc(output, content, isCompare) {
e2e.Logf("the output %s does not contain the content %s, expected", output, content)
return true, nil
}
e2e.Logf("---> Not as expected! Return false")
return false, nil
})
}
|
package operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
c8ca9d27-c2eb-456b-98e2-fe678516a7e1
|
buildPushOperatorImage
|
['"context"', '"fmt"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func buildPushOperatorImage(architecture architecture.Architecture, tmpPath, imageTag, tokenDir string) {
exutil.By("Build and Push the operator image with architecture")
podmanCLI := container.NewPodmanCLI()
podmanCLI.ExecCommandPath = tmpPath
output, err := podmanCLI.Run("build").Args(tmpPath, "--arch", architecture.String(), "--tag", imageTag,
"--authfile", fmt.Sprintf("%s/.dockerconfigjson", tokenDir)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
imagePushOutput, _ := podmanCLI.Run("push").Args(imageTag).Output()
if strings.Contains(imagePushOutput, "Writing manifest to image destination") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.")
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
457171cf-f7fc-47eb-a728-7055a381354d
|
createWithoutCheck
|
['"strings"']
|
['subscriptionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (sub *subscriptionDescription) createWithoutCheck(oc *exutil.CLI, itName string, dr describerResrouce) {
// for most operator subscription failure, the reason is that there is a left cluster-scoped CSV.
// I'd like to print all CSV before create it.
// It prints many lines which descrease the exact match for RP, and increase log size.
// So, change it to one line with necessary information csv name and namespace.
allCSVs, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "--all-namespaces", "-o=jsonpath={range .items[*]}{@.metadata.name}{\",\"}{@.metadata.namespace}{\":\"}{end}").Output()
if err != nil {
e2e.Failf("!!! Couldn't get all CSVs:%v\n", err)
}
csvMap := make(map[string][]string)
csvList := strings.Split(allCSVs, ":")
for _, csv := range csvList {
if strings.Compare(csv, "") == 0 {
continue
}
name := strings.Split(csv, ",")[0]
ns := strings.Split(csv, ",")[1]
val, ok := csvMap[name]
if ok {
if strings.HasPrefix(ns, "openshift-") {
alreadyOpenshiftDefaultNS := false
for _, v := range val {
if strings.Contains(v, "openshift-") {
alreadyOpenshiftDefaultNS = true // normally one default operator exists in all openshift- ns, like elasticsearch-operator
// only add one openshift- ns to indicate. to save log size and line size. Or else one line
// will be greater than 3k
break
}
}
if !alreadyOpenshiftDefaultNS {
val = append(val, ns)
csvMap[name] = val
}
} else {
val = append(val, ns)
csvMap[name] = val
}
} else {
nsSlice := make([]string, 20)
nsSlice[1] = ns
csvMap[name] = nsSlice
}
}
for name, ns := range csvMap {
e2e.Logf("getting csv is %v, the related NS is %v", name, ns)
}
e2e.Logf("create sub %s", sub.subName)
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", sub.template, "-p", "SUBNAME="+sub.subName, "SUBNAMESPACE="+sub.namespace, "CHANNEL="+sub.channel,
"APPROVAL="+sub.ipApproval, "OPERATORNAME="+sub.operatorPackage, "SOURCENAME="+sub.catalogSourceName, "SOURCENAMESPACE="+sub.catalogSourceNamespace, "STARTINGCSV="+sub.startingCSV)
o.Expect(err).NotTo(o.HaveOccurred())
dr.getIr(itName).add(newResource(oc, "sub", sub.subName, requireNS, sub.namespace))
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
e1694382-0845-46c5-bb4c-1eb32236bb05
|
findInstalledCSV
|
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
['subscriptionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (sub *subscriptionDescription) findInstalledCSV(oc *exutil.CLI, itName string, dr describerResrouce) {
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
state := getResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.state}")
if strings.Compare(state, "AtLatestKnown") == 0 {
return true, nil
}
e2e.Logf("sub %s state is %s, not AtLatestKnown", sub.subName, state)
return false, nil
})
if err != nil {
getResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "-o=jsonpath-as-json={.status}")
getResource(oc, asAdmin, withoutNamespace, "pod", "-n", sub.catalogSourceNamespace)
}
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("sub %s stat is not AtLatestKnown", sub.subName))
installedCSV := getResource(oc, asAdmin, withoutNamespace, "sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.installedCSV}")
o.Expect(installedCSV).NotTo(o.BeEmpty())
if strings.Compare(sub.installedCSV, installedCSV) != 0 {
sub.installedCSV = installedCSV
dr.getIr(itName).add(newResource(oc, "csv", sub.installedCSV, requireNS, sub.namespace))
}
e2e.Logf("the installed CSV name is %s", sub.installedCSV)
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
561f9b89-4773-48c3-8e58-58af65c762d7
|
create
|
['"strings"']
|
['subscriptionDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (sub *subscriptionDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) {
// for most operator subscription failure, the reason is that there is a left cluster-scoped CSV.
// I'd like to print all CSV before create it.
// allCSVs, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "--all-namespaces").Output()
// if err != nil {
// e2e.Failf("!!! Couldn't get all CSVs:%v\n", err)
// }
// e2e.Logf("!!! Get all CSVs in this cluster:\n%s\n", allCSVs)
sub.createWithoutCheck(oc, itName, dr)
if strings.Compare(sub.ipApproval, "Automatic") == 0 {
sub.findInstalledCSV(oc, itName, dr)
} else {
newCheck("expect", asAdmin, withoutNamespace, compare, "UpgradePending", ok, []string{"sub", sub.subName, "-n", sub.namespace, "-o=jsonpath={.status.state}"}).check(oc)
}
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
a0b9d166-fe2e-4e88-ac6e-9b6172b7cadb
|
create
|
['"strings"']
|
['catalogSourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (catsrc *catalogSourceDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) {
if strings.Compare(catsrc.interval, "") == 0 {
catsrc.interval = "10m0s"
e2e.Logf("set interval to be 10m0s")
}
err := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", catsrc.template,
"-p", "NAME="+catsrc.name, "NAMESPACE="+catsrc.namespace, "ADDRESS="+catsrc.address, "SECRET="+catsrc.secret,
"DISPLAYNAME="+"\""+catsrc.displayName+"\"", "PUBLISHER="+"\""+catsrc.publisher+"\"", "SOURCETYPE="+catsrc.sourceType,
"INTERVAL="+catsrc.interval, "IMAGETEMPLATE="+catsrc.imageTemplate)
o.Expect(err).NotTo(o.HaveOccurred())
catsrc.setSCCRestricted(oc)
dr.getIr(itName).add(newResource(oc, "catsrc", catsrc.name, requireNS, catsrc.namespace))
e2e.Logf("create catsrc %s SUCCESS", catsrc.name)
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
306b64f3-b603-466e-bb77-ae209a12cd7f
|
setSCCRestricted
|
['"strings"', '"github.com/tidwall/gjson"']
|
['catalogSourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (catsrc *catalogSourceDescription) setSCCRestricted(oc *exutil.CLI) {
output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("configmaps", "-n", "openshift-kube-apiserver", "config", `-o=jsonpath={.data.config\.yaml}`).Output()
o.Expect(err).NotTo(o.HaveOccurred())
psa := gjson.Get(output, "admission.pluginConfig.PodSecurity.configuration.defaults.enforce").String()
e2e.Logf("pod-security.kubernetes.io/enforce is %s", string(psa))
if strings.Contains(string(psa), "restricted") {
originSCC := catsrc.getSCC(oc)
e2e.Logf("spec.grpcPodConfig.securityContextConfig is %s", originSCC)
if strings.Compare(originSCC, "") == 0 {
e2e.Logf("set spec.grpcPodConfig.securityContextConfig to be restricted")
err := oc.AsAdmin().WithoutNamespace().Run("patch").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "--type=merge", "-p", `{"spec":{"grpcPodConfig":{"securityContextConfig":"restricted"}}}`).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
} else {
e2e.Logf("spec.grpcPodConfig.securityContextConfig is not empty, skip setting")
}
}
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
0e7bfe12-e466-43fa-b90f-e69127e72ab9
|
getSCC
|
['catalogSourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (catsrc *catalogSourceDescription) getSCC(oc *exutil.CLI) string {
output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.spec.grpcPodConfig.securityContextConfig}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
return output
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
aa22d5b5-1b63-4673-a2d0-151cc20fe705
|
createWithCheck
|
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
['catalogSourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (catsrc *catalogSourceDescription) createWithCheck(oc *exutil.CLI, itName string, dr describerResrouce) {
catsrc.create(oc, itName, dr)
err := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
status, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.status..lastObservedState}").Output()
if strings.Compare(status, "READY") != 0 {
e2e.Logf("catsrc %s lastObservedState is %s, not READY", catsrc.name, status)
return false, nil
}
return true, nil
})
if err != nil {
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("catsrc", catsrc.name, "-n", catsrc.namespace, "-o=jsonpath={.status}").Output()
e2e.Logf(output)
logDebugInfo(oc, catsrc.namespace, "pod", "events")
}
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("catsrc %s lastObservedState is not READY", catsrc.name))
e2e.Logf("catsrc %s lastObservedState is READY", catsrc.name)
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
495c05cf-d461-43cd-9e07-d5029c448e84
|
createwithCheck
|
['"fmt"', '"strings"']
|
['operatorGroupDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (og *operatorGroupDescription) createwithCheck(oc *exutil.CLI, itName string, dr describerResrouce) {
output, err := doAction(oc, "get", asAdmin, false, "operatorgroup")
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(output, "No resources found") {
e2e.Logf(fmt.Sprintf("No operatorgroup in project: %s, create one: %s", og.namespace, og.name))
og.create(oc, itName, dr)
} else {
e2e.Logf(fmt.Sprintf("Already exist operatorgroup in project: %s", og.namespace))
}
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
43cbbb42-c71b-49ea-887a-a5c11dc99db3
|
create
|
['"strings"']
|
['operatorGroupDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (og *operatorGroupDescription) create(oc *exutil.CLI, itName string, dr describerResrouce) {
var err error
if strings.Compare(og.multinslabel, "") != 0 && strings.Compare(og.serviceAccountName, "") != 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "MULTINSLABEL="+og.multinslabel, "SERVICE_ACCOUNT_NAME="+og.serviceAccountName)
} else if strings.Compare(og.multinslabel, "") == 0 && strings.Compare(og.serviceAccountName, "") == 0 && strings.Compare(og.upgradeStrategy, "") == 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace)
} else if strings.Compare(og.multinslabel, "") != 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "MULTINSLABEL="+og.multinslabel)
} else if strings.Compare(og.upgradeStrategy, "") != 0 {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "UPGRADESTRATEGY="+og.upgradeStrategy)
} else {
err = applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", og.template, "-p", "NAME="+og.name, "NAMESPACE="+og.namespace, "SERVICE_ACCOUNT_NAME="+og.serviceAccountName)
}
o.Expect(err).NotTo(o.HaveOccurred())
dr.getIr(itName).add(newResource(oc, "og", og.name, requireNS, og.namespace))
e2e.Logf("create og %s success", og.name)
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
ef12c767-2bc7-4e0a-8048-5ff3fba33461
|
newResource
|
['resourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func newResource(oc *exutil.CLI, kind string, name string, nsflag bool, namespace string) resourceDescription {
return resourceDescription{
oc: oc,
asAdmin: asAdmin,
withoutNamespace: withoutNamespace,
kind: kind,
name: name,
requireNS: nsflag,
namespace: namespace,
}
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
e9868f9d-ddcc-48ec-adb8-0a6677aace59
|
delete
|
['resourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (r resourceDescription) delete() {
if r.withoutNamespace && r.requireNS {
removeResource(r.oc, r.asAdmin, r.withoutNamespace, r.kind, r.name, "-n", r.namespace)
} else {
removeResource(r.oc, r.asAdmin, r.withoutNamespace, r.kind, r.name)
}
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
6566f636-4004-4b96-94f7-d6a10ac82b10
|
add
|
['resourceDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (ir itResource) add(r resourceDescription) {
ir[r.name+r.kind+r.namespace] = r
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
0cf84ca7-692c-48c2-a735-bfd10218489f
|
remove
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (ir itResource) remove(name string, kind string, namespace string) {
rKey := name + kind + namespace
if r, ok := ir[rKey]; ok {
r.delete()
delete(ir, rKey)
}
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
f5c9719a-628f-4d62-8b4d-d0cba70bb4a4
|
cleanup
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (ir itResource) cleanup() {
for _, r := range ir {
e2e.Logf("cleanup resource %s, %s", r.kind, r.name)
ir.remove(r.name, r.kind, r.namespace)
}
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
49374226-361f-4036-9ad9-96d3ec2b16fe
|
addIr
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (dr describerResrouce) addIr(itName string) {
dr[itName] = itResource{}
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
4df1d623-1fd1-4452-84eb-38adefb62e07
|
getIr
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (dr describerResrouce) getIr(itName string) itResource {
ir, ok := dr[itName]
if !ok {
e2e.Logf("!!! couldn't find the itName:%s, print the describerResrouce:%v", itName, dr)
}
o.Expect(ok).To(o.BeTrue())
return ir
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
d6111d23-b98e-43a3-a965-872db77baadf
|
rmIr
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (dr describerResrouce) rmIr(itName string) {
delete(dr, itName)
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
52e38c9f-8057-4424-9241-60c73c82e3c7
|
getResource
|
['"context"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func getResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) string {
var result string
var err error
err = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
result, err = doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil {
e2e.Logf("output is %v, error is %v, and try next", result, err)
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not get %v", parameters))
e2e.Logf("$oc get %v, the returned resource:%v", parameters, result)
return result
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
b09db164-2f81-479b-9f02-12a9e535e443
|
removeResource
|
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func removeResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) {
output, err := doAction(oc, "delete", asAdmin, withoutNamespace, parameters...)
if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) {
e2e.Logf("the resource is deleted already")
return
}
o.Expect(err).NotTo(o.HaveOccurred())
err = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) {
e2e.Logf("the resource is delete successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("can not remove %v", parameters))
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
6ff31140-9008-4fc0-8ba3-48716d8691a3
|
doAction
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func doAction(oc *exutil.CLI, action string, asAdmin bool, withoutNamespace bool, parameters ...string) (string, error) {
if asAdmin && withoutNamespace {
return oc.AsAdmin().WithoutNamespace().Run(action).Args(parameters...).Output()
}
if asAdmin && !withoutNamespace {
return oc.AsAdmin().Run(action).Args(parameters...).Output()
}
if !asAdmin && withoutNamespace {
return oc.WithoutNamespace().Run(action).Args(parameters...).Output()
}
if !asAdmin && !withoutNamespace {
return oc.Run(action).Args(parameters...).Output()
}
return "", nil
}
|
operatorsdk
| |||||
function
|
openshift/openshift-tests-private
|
83d93ef4-f2f8-4f70-920c-1388f182b830
|
newCheck
|
['checkDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func newCheck(method string, executor bool, inlineNamespace bool, expectAction bool,
expectContent string, expect bool, resource []string) checkDescription {
return checkDescription{
method: method,
executor: executor,
inlineNamespace: inlineNamespace,
expectAction: expectAction,
expectContent: expectContent,
expect: expect,
resource: resource,
}
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
b676d6f0-9081-4eae-953d-1581463cfd7b
|
check
|
['"fmt"']
|
['checkDescription']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func (ck checkDescription) check(oc *exutil.CLI) {
switch ck.method {
case "present":
ok := isPresentResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.resource...)
o.Expect(ok).To(o.BeTrue())
case "expect":
err := expectedResource(oc, ck.executor, ck.inlineNamespace, ck.expectAction, ck.expectContent, ck.expect, ck.resource...)
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("expected content %s not found by %v", ck.expectContent, ck.resource))
default:
err := fmt.Errorf("unknown method")
o.Expect(err).NotTo(o.HaveOccurred())
}
}
|
operatorsdk
| |||
function
|
openshift/openshift-tests-private
|
a9039448-3309-4875-bf7e-d6b4c7eee08f
|
isPresentResource
|
['"context"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func isPresentResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, present bool, parameters ...string) bool {
parameters = append(parameters, "--ignore-not-found")
err := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 70*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil {
e2e.Logf("the get error is %v, and try next", err)
return false, nil
}
if !present && strings.Compare(output, "") == 0 {
return true, nil
}
if present && strings.Compare(output, "") != 0 {
return true, nil
}
return false, nil
})
if err != nil {
return false
}
return true
}
|
operatorsdk
| ||||
function
|
openshift/openshift-tests-private
|
21d1a2a1-b69a-41ad-a53d-6c1a617ca574
|
expectedResource
|
['"context"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/util.go
|
func expectedResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, isCompare bool, content string, expect bool, parameters ...string) error {
expectMap := map[bool]string{
true: "do",
false: "do not",
}
cc := func(a, b string, ic bool) bool {
bs := strings.Split(b, "+2+")
ret := false
for _, s := range bs {
if (ic && strings.Compare(a, s) == 0) || (!ic && strings.Contains(a, s)) {
ret = true
}
}
return ret
}
e2e.Logf("Running: oc get asAdmin(%t) withoutNamespace(%t) %s", asAdmin, withoutNamespace, strings.Join(parameters, " "))
return wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...)
if err != nil {
e2e.Logf("the get error is %v, and try next", err)
return false, nil
}
e2e.Logf("---> we %v expect value: %s, in returned value: %s", expectMap[expect], content, output)
if isCompare && expect && cc(output, content, isCompare) {
e2e.Logf("the output %s matches one of the content %s, expected", output, content)
return true, nil
}
if isCompare && !expect && !cc(output, content, isCompare) {
e2e.Logf("the output %s does not matche the content %s, expected", output, content)
return true, nil
}
if !isCompare && expect && cc(output, content, isCompare) {
e2e.Logf("the output %s contains one of the content %s, expected", output, content)
return true, nil
}
if !isCompare && !expect && !cc(output, content, isCompare) {
e2e.Logf("the output %s does not contain the content %s, expected", output, content)
return true, nil
}
e2e.Logf("---> Not as expected! Return false")
return false, nil
})
}
|
operatorsdk
| ||||
test
|
openshift/openshift-tests-private
|
3b27e099-f4dc-460a-8e94-69c24c22f24c
|
operatorsdk
|
import (
"context"
"fmt"
"os"
"os/exec"
"strings"
"time"
"github.com/openshift/openshift-tests-private/test/extended/util/architecture"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
"path/filepath"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
container "github.com/openshift/openshift-tests-private/test/extended/util/container"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
package operatorsdk
import (
"context"
"fmt"
"os"
"os/exec"
"strings"
"time"
"github.com/openshift/openshift-tests-private/test/extended/util/architecture"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
"path/filepath"
exutil "github.com/openshift/openshift-tests-private/test/extended/util"
container "github.com/openshift/openshift-tests-private/test/extended/util/container"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
var _ = g.Describe("[sig-operators] Operator_SDK should", func() {
defer g.GinkgoRecover()
var operatorsdkCLI = NewOperatorSDKCLI()
var makeCLI = NewMakeCLI()
var mvnCLI = NewMVNCLI()
var oc = exutil.NewCLIWithoutNamespace("default")
var ocpversion = "4.18"
var ocppreversion = "4.17"
var upstream = false
/*
g.BeforeEach(func() {
g.Skip("OperatorSDK is deprecated since OCP 4.16, so skip it")
})
*/
// author: [email protected]
g.It("VMonly-Author:jfan-High-37465-SDK olm improve olm related sub commands", func() {
operatorsdkCLI.showInfo = true
exutil.By("check the olm status")
output, _ := operatorsdkCLI.Run("olm").Args("status", "--olm-namespace", "openshift-operator-lifecycle-manager").Output()
o.Expect(output).To(o.ContainSubstring("Fetching CRDs for version"))
})
// author: [email protected]
g.It("Author:jfan-High-37312-SDK olm improve manage operator bundles in new manifests metadata format", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-37312-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-37312")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins", "ansible", "--domain", "example.com", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-playbook").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Bundle manifests generate")
result, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk generate bundle --deploy-dir=config --crds-dir=config/crds --version=0.0.1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Bundle manifests generated successfully in bundle"))
})
// author: [email protected]
g.It("Author:jfan-High-37141-SDK Helm support simple structural schema generation for Helm CRDs", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-37141-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "nginx-operator-37141")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--project-name", "nginx-operator", "--plugins", "helm.sdk.operatorframework.io/v1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
result, err := operatorsdkCLI.Run("create").Args("api", "--group", "apps", "--version", "v1beta1", "--kind", "Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Created helm-charts/nginx"))
annotationsFile := filepath.Join(tmpPath, "config", "crd", "bases", "apps.my.domain_nginxes.yaml")
content := getContent(annotationsFile)
o.Expect(content).To(o.ContainSubstring("x-kubernetes-preserve-unknown-fields: true"))
})
// author: [email protected]
g.It("Author:jfan-High-37311-SDK ansible valid structural schemas for ansible based operators", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-37311-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "ansible-operator-37311")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--project-name", "nginx-operator", "--plugins", "ansible.sdk.operatorframework.io/v1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "apps", "--version", "v1beta1", "--kind", "Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
annotationsFile := filepath.Join(tmpPath, "config", "crd", "bases", "apps.my.domain_nginxes.yaml")
content := getContent(annotationsFile)
o.Expect(content).To(o.ContainSubstring("x-kubernetes-preserve-unknown-fields: true"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-37627-SDK run bundle upgrade test [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
defer func() {
output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeoperator-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradeoperator.v0.0.2", "-n", oc.Namespace()).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 0.2 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradeoperator upgrade failed in %s ", oc.Namespace()))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-38054-SDK run bundle create pods and csv and registry image pod [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/podcsvcheck-bundle:v0.0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", oc.Namespace()).Output()
o.Expect(output).To(o.ContainSubstring("quay-io-olmqe-podcsvcheck-bundle-v0-0-1"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "podcsvcheck.v0.0.1", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Succeeded"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "podcsvcheck-catalog", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("grpc"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("installplan", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("podcsvcheck.v0.0.1"))
output, err = operatorsdkCLI.Run("cleanup").Args("podcsvcheck", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
// author: [email protected]
g.It("ConnectedOnly-Author:jfan-High-38060-SDK run bundle detail message about failed", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
output, _ := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/etcd-bundle:0.0.1", "-n", oc.Namespace(), "--security-context-config=restricted").Output()
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/etcd-bundle:0.0.1: not found"))
})
// author: [email protected]
g.It("Author:jfan-LEVEL0-High-34441-SDK commad operator sdk support init help message", func() {
output, err := operatorsdkCLI.Run("init").Args("--help").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("--project-name"))
})
// author: [email protected]
g.It("Author:jfan-Medium-40521-SDK olm improve manage operator bundles in new manifests metadata format", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-40521-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-40521")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins", "ansible.sdk.operatorframework.io/v1", "--domain", "example.com", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-playbook").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Bundle manifests generate")
result, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk generate bundle --deploy-dir=config --crds-dir=config/crds --version=0.0.1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Bundle manifests generated successfully in bundle"))
exec.Command("bash", "-c", "cd "+tmpPath+" && sed -i '/icon/,+2d' ./bundle/manifests/memcached-operator-40521.clusterserviceversion.yaml").Output()
msg, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk bundle validate ./bundle &> ./validateresult && cat validateresult").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("All validation tests have completed successfully"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-40520-SDK k8sutil 1123Label creates invalid values", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
msg, _ := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/raffaelespazzoli-proactive-node-scaling-operator-bundle:latest-", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(msg).To(o.ContainSubstring("reated registry pod: raffaelespazzoli-proactive-node-scaling-operator-bundle-latest"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-35443-SDK run bundle InstallMode for own namespace [Slow] [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "olm")
var operatorGroup = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
// install the operator without og with installmode
msg, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsingleallsupport-bundle:v4.11", "--install-mode", "OwnNamespace", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-n", namespace, "-o=jsonpath={.spec.targetNamespaces}").Output()
o.Expect(msg).To(o.ContainSubstring(namespace))
output, err := operatorsdkCLI.Run("cleanup").Args("ownsingleallsupport", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-ownsingleallsupport-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-ownsingleallsupport-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-ownsingleallsupport-bundle can't be deleted in %s", namespace))
// install the operator with og and installmode
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=og-own", "NAMESPACE="+namespace).OutputToFile("config-35443.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsingleallsupport-bundle:v4.11", "--install-mode", "OwnNamespace", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("ownsingleallsupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// install the operator with og without installmode
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-ownsingleallsupport-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-ownsingleallsupport-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-ownsingleallsupport-bundle can't be deleted in %s", namespace))
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsingleallsupport-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("ownsingleallsupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// delete the og
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("og", "og-own", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-ownsingleallsupport-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("quay-io-olmqe-ownsingleallsupport-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-ownsingleallsupport-bundle can't be deleted in %s", namespace))
// install the operator without og and installmode, the csv support ownnamespace and singlenamespace
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsinglesupport-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-n", namespace, "-o=jsonpath={.spec.targetNamespaces}").Output()
o.Expect(msg).To(o.ContainSubstring(namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("ownsinglesupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-41064-SDK run bundle InstallMode for single namespace [Slow] [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
var operatorGroup = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
err := oc.AsAdmin().WithoutNamespace().Run("create").Args("ns", "test-sdk-41064").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
defer oc.AsAdmin().WithoutNamespace().Run("delete").Args("ns", "test-sdk-41064").Execute()
msg, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all1support-bundle:v4.11", "--install-mode", "SingleNamespace=test-sdk-41064", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-n", namespace, "-o=jsonpath={.spec.targetNamespaces}").Output()
o.Expect(msg).To(o.ContainSubstring("test-sdk-41064"))
output, err := operatorsdkCLI.Run("cleanup").Args("all1support", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all1support-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all1support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all1support-bundle can't be deleted in %s", namespace))
// install the operator with og and installmode
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=og-single", "NAMESPACE="+namespace, "KAKA=test-sdk-41064").OutputToFile("config-41064.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all1support-bundle:v4.11", "--install-mode", "SingleNamespace=test-sdk-41064", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("all1support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// install the operator with og without installmode
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all1support-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all1support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all1support-bundle can't be deleted in %s", namespace))
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all1support-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("all1support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// delete the og
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("og", "og-single", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all1support-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all1support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all1support-bundle can't be deleted in %s", namespace))
// install the operator without og and installmode, the csv only support singlenamespace
msg, _ = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/singlesupport-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(msg).To(o.ContainSubstring("AllNamespaces InstallModeType not supported"))
output, _ = operatorsdkCLI.Run("cleanup").Args("singlesupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-41065-SDK run bundle InstallMode for all namespace [Slow] [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "olm")
var operatorGroup = filepath.Join(buildPruningBaseDir, "og-allns.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
// install the operator without og with installmode all namespace
msg, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "--install-mode", "AllNamespaces", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
defer operatorsdkCLI.Run("cleanup").Args("all2support").Output()
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-o=jsonpath={.spec.targetNamespaces}", "-n", namespace).Output()
o.Expect(msg).To(o.ContainSubstring(""))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, err := operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all2support-bundle-v4-11", "--no-headers", "-n", namespace).Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all2support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all2support-bundle can't be deleted in %s", namespace))
// install the operator with og and installmode
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=og-allnames", "NAMESPACE="+namespace).OutputToFile("config-41065.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "--install-mode", "AllNamespaces", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// install the operator with og without installmode
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all2support-bundle-v4-11", "--no-headers", "-n", namespace).Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all2support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all2support-bundle can't be deleted in %s", namespace))
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// delete the og
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("og", "og-allnames", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all2support-bundle-v4-11", "--no-headers", "-n", namespace).Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all2support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all2support-bundle can't be deleted in %s", namespace))
// install the operator without og and installmode, the csv support allnamespace and ownnamespace
msg, _ = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-38757-SDK operator bundle upgrade from traditional operator installation", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
var catalogofupgrade = filepath.Join(buildPruningBaseDir, "catalogsource.yaml")
var ogofupgrade = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
var subofupgrade = filepath.Join(buildPruningBaseDir, "sub.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
// install operator from sub
defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", namespace).Output()
createCatalog, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", catalogofupgrade, "-p", "NAME=upgradetest", "NAMESPACE="+namespace, "ADDRESS=quay.io/olmqe/upgradeindex-index:v0.1", "DISPLAYNAME=KakaTest").OutputToFile("catalogsource-41497.json")
err := oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createCatalog, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createOg, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", ogofupgrade, "-p", "NAME=kakatest-single", "NAMESPACE="+namespace, "KAKA="+namespace).OutputToFile("createog-41497.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createOg, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createSub, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", subofupgrade, "-p", "NAME=subofupgrade", "NAMESPACE="+namespace, "SOURCENAME=upgradetest", "OPERATORNAME=upgradeindex", "SOURCENAMESPACE="+namespace, "STARTINGCSV=upgradeindex.v0.0.1").OutputToFile("createsub-41497.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createSub, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradeindex.v0.0.1", "-o=jsonpath={.status.phase}", "-n", namespace).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgradeindexv0.1 installed successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv upgradeindex.v0.0.1 %s", namespace))
// upgrade by operator-sdk
msg, err := operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("Successfully upgraded to"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-42928-SDK support the previous base ansible image [Slow]", func() {
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
// test data
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-42928-data")
crFilePath := filepath.Join(dataPath, "ansibletest_v1_previoustest.yaml")
// exec dir
tmpBasePath := "/tmp/ocp-42928-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "previousansibletest")
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
// exec ns & image tag
nsOperator := "previousansibletest-system"
imageTag := "quay.io/olmqe/previousansibletest:" + ocpversion + "-" + getRandomString()
// cleanup the test data
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "qetest.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "ansibletest", "--version", "v1", "--kind", "Previoustest", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy task main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "previoustest", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy Dockerfile
dockerfileFilePath := filepath.Join(dataPath, "Dockerfile")
err = copy(dockerfileFilePath, filepath.Join(tmpPath, "Dockerfile"))
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocppreversion)
// copy manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-42928" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("previoustests.ansibletest.qetest.com"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/previousansibletest-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "previousansibletest-controller-manager") {
e2e.Logf("found pod previousansibletest-controller-manager")
if strings.Contains(line, "2/2") {
e2e.Logf("the status of pod previousansibletest-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod previousansibletest-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No previousansibletest-controller-manager in project %s", nsOperator))
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/previousansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(msg, "Starting workers") {
e2e.Failf("Starting workers failed")
}
// max concurrent reconciles
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deploy/previousansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output()
if strings.Contains(msg, "\"worker count\":1") {
e2e.Logf("found worker count:1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/previousansibletest-controller-manager of %s doesn't have worker count:4", nsOperator))
// add the admin policy
err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "cluster-admin", "system:serviceaccount:"+nsOperator+":previousansibletest-controller-manager").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "previoustest-sample") {
e2e.Logf("found pod previoustest-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No previoustest-sample in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/previoustest-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "2 desired | 2 updated | 2 total | 2 available | 0 unavailable") {
e2e.Logf("deployment/previoustest-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events")
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/previoustest-sample is wrong")
// k8s event
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("event", "-n", nsOperator).Output()
if strings.Contains(msg, "test-reason") {
e2e.Logf("k8s_event test")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get k8s event test-name in %s", nsOperator))
// k8s status
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("previoustest.ansibletest.qetest.com/previoustest-sample", "-n", nsOperator, "-o", "yaml").Output()
if strings.Contains(msg, "hello world") {
e2e.Logf("k8s_status test hello world")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get previoustest-sample hello world in %s", nsOperator))
// migrate test
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("secret", "-n", nsOperator).Output()
if strings.Contains(msg, "test-secret") {
e2e.Logf("found secret test-secret")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("doesn't get secret test-secret %s", nsOperator))
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("secret", "test-secret", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("test: 6 bytes"))
// blacklist
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("describe").Args("configmap", "test-blacklist-watches", "-n", nsOperator).Output()
if strings.Contains(msg, "afdasdfsajsafj") {
e2e.Logf("Skipping the blacklist")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/previousansibletest-controller-manager of %s doesn't work the blacklist", nsOperator))
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
_, err = makeCLI.Run("undeploy").Output()
o.Expect(err).NotTo(o.HaveOccurred())
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-42929-SDK support the previous base helm image", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
var nginx = filepath.Join(buildPruningBaseDir, "helmbase_v1_nginx.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
defer operatorsdkCLI.Run("cleanup").Args("previoushelmbase", "-n", namespace).Output()
_, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/previoushelmbase-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
createPreviousNginx, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", nginx, "-p", "NAME=previousnginx-sample").OutputToFile("config-42929.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createPreviousNginx, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "nginx-sample") {
e2e.Logf("found pod nginx-sample")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get pod nginx-sample in %s", namespace))
err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("nginx.helmbase.previous.com", "previousnginx-sample", "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
output, _ := operatorsdkCLI.Run("cleanup").Args("previoushelmbase", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
// author: [email protected]
g.It("ConnectedOnly-VMonly-Author:jfan-High-42614-SDK validate the deprecated APIs and maxOpenShiftVersion", func() {
operatorsdkCLI.showInfo = true
exec.Command("bash", "-c", "mkdir -p /tmp/ocp-42614/traefikee-operator").Output()
defer exec.Command("bash", "-c", "rm -rf /tmp/ocp-42614").Output()
exec.Command("bash", "-c", "cp -rf test/extended/testdata/operatorsdk/ocp-42614-data/bundle/ /tmp/ocp-42614/traefikee-operator/").Output()
exutil.By("with deprecated api, with maxOpenShiftVersion")
msg, err := operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("This bundle is using APIs which were deprecated and removed in"))
o.Expect(msg).NotTo(o.ContainSubstring("error"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("with deprecated api, with higher version maxOpenShiftVersion")
exec.Command("bash", "-c", "sed -i 's/4.8/4.9/g' /tmp/ocp-42614/traefikee-operator/bundle/manifests/traefikee-operator.v2.1.1.clusterserviceversion.yaml").Output()
msg, _ = operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("This bundle is using APIs which were deprecated and removed"))
o.Expect(msg).To(o.ContainSubstring("error"))
exutil.By("with deprecated api, with wrong maxOpenShiftVersion")
exec.Command("bash", "-c", "sed -i 's/4.9/invalid/g' /tmp/ocp-42614/traefikee-operator/bundle/manifests/traefikee-operator.v2.1.1.clusterserviceversion.yaml").Output()
msg, _ = operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("csv.Annotations.olm.properties has an invalid value"))
o.Expect(msg).To(o.ContainSubstring("error"))
exutil.By("with deprecated api, without maxOpenShiftVersion")
exec.Command("bash", "-c", "sed -i '/invalid/d' /tmp/ocp-42614/traefikee-operator/bundle/manifests/traefikee-operator.v2.1.1.clusterserviceversion.yaml").Output()
msg, _ = operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("csv.Annotations not specified olm.maxOpenShiftVersion for an OCP version"))
o.Expect(msg).To(o.ContainSubstring("error"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-34462-SDK playbook ansible operator generate the catalog", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.ARM64, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
catalogofcatalog = filepath.Join(buildPruningBaseDir, "catalogsource.yaml")
ogofcatalog = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
subofcatalog = filepath.Join(buildPruningBaseDir, "sub.yaml")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-34462-data")
tmpBasePath = "/tmp/ocp-34462-" + getRandomString()
tmpPath = filepath.Join(tmpBasePath, "catalogtest")
imageTag = "quay.io/olmqe/catalogtest-operator:34462-v" + ocpversion + getRandomString()
bundleImage = "quay.io/olmqe/catalogtest-bundle:34462-v" + ocpversion + getRandomString()
catalogImage = "quay.io/olmqe/catalogtest-index:34462-v" + ocpversion + getRandomString()
quayCLI = container.NewQuayCLI()
)
operatorsdkCLI.showInfo = true
oc.SetupProject()
defer os.RemoveAll(tmpBasePath)
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
exutil.By("Create the playbook ansible operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain=catalogtest.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("Create api")
output, err = operatorsdkCLI.Run("create").Args("api", "--group=cache", "--version=v1", "--kind=Catalogtest", "--generate-playbook").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
err = copy(filepath.Join(dataPath, "Dockerfile"), filepath.Join(tmpPath, "Dockerfile"))
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-34462" + getRandomString()
defer os.RemoveAll(tokenDir)
err = os.MkdirAll(tokenDir, os.ModePerm)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
// OCP-40219
exutil.By("Generate the bundle image and catalog index image")
replaceContent(filepath.Join(tmpPath, "Makefile"), "controller:latest", imageTag)
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "catalogtest.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "catalogtest.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := makeCLI.Run("bundle").Args().Output()
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
replaceContent(filepath.Join(tmpPath, "Makefile"), " --container-tool docker ", " ")
defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1))
defer quayCLI.DeleteTag(strings.Replace(catalogImage, "quay.io/", "", 1))
_, err = makeCLI.Run("bundle-build").Args("bundle-push", "catalog-build", "catalog-push", "BUNDLE_IMG="+bundleImage, "CATALOG_IMG="+catalogImage).Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Install the operator through olm")
namespace := oc.Namespace()
createCatalog, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", catalogofcatalog, "-p", "NAME=cs-catalog", "NAMESPACE="+namespace, "ADDRESS="+catalogImage, "DISPLAYNAME=CatalogTest").OutputToFile("catalogsource-34462.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createCatalog, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createOg, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", ogofcatalog, "-p", "NAME=catalogtest-single", "NAMESPACE="+namespace, "KAKA="+namespace).OutputToFile("createog-34462.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createOg, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createSub, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", subofcatalog, "-p", "NAME=cataloginstall", "NAMESPACE="+namespace, "SOURCENAME=cs-catalog", "OPERATORNAME=catalogtest", "SOURCENAMESPACE="+namespace, "STARTINGCSV=catalogtest.v0.0.1").OutputToFile("createsub-34462.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createSub, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 390*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "catalogtest.v0.0.1", "-o=jsonpath={.status.phase}", "-n", namespace).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("catalogtest installed successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv catalogtest.v0.0.1 in %s", namespace))
})
// author: [email protected]
g.It("Author:chuo-Medium-27718-scorecard remove version flag", func() {
operatorsdkCLI.showInfo = true
output, _ := operatorsdkCLI.Run("scorecard").Args("--version").Output()
o.Expect(output).To(o.ContainSubstring("unknown flag: --version"))
})
// author: [email protected]
g.It("VMonly-Author:chuo-Critical-37655-run bundle upgrade connect to the Operator SDK CLI", func() {
operatorsdkCLI.showInfo = true
output, _ := operatorsdkCLI.Run("run").Args("bundle-upgrade", "-h").Output()
o.Expect(output).To(o.ContainSubstring("help for bundle-upgrade"))
})
// author: [email protected]
g.It("Author:jitli-VMonly-Medium-34945-ansible Add flag metricsaddr for ansible operator", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
imageTag := "registry-proxy.engineering.redhat.com/rh-osbs/openshift-ose-ansible-rhel9-operator:v" + ocpversion
containerCLI := container.NewPodmanCLI()
e2e.Logf("create container with image %s", imageTag)
id, err := containerCLI.ContainerCreate(imageTag, "test-34945", "/bin/sh", true)
defer func() {
e2e.Logf("stop container %s", id)
containerCLI.ContainerStop(id)
e2e.Logf("remove container %s", id)
err := containerCLI.ContainerRemove(id)
if err != nil {
e2e.Failf("Defer: fail to remove container %s", id)
}
}()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("container id is %s", id)
e2e.Logf("start container %s", id)
err = containerCLI.ContainerStart(id)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("start container %s successful", id)
commandStr := []string{"ansible-operator", "run", "--help"}
output, err := containerCLI.Exec(id, commandStr)
if err != nil {
e2e.Failf("command %s: %s", commandStr, output)
}
o.Expect(output).To(o.ContainSubstring("--metrics-bind-address"))
})
// author: [email protected]
g.It("Author:jitli-VMonly-Medium-77166-Check the ansible-operator-plugins version info", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
imageTag := "registry-proxy.engineering.redhat.com/rh-osbs/openshift-ose-ansible-rhel9-operator:v" + ocpversion
containerCLI := container.NewPodmanCLI()
e2e.Logf("create container with image %s", imageTag)
id, err := containerCLI.ContainerCreate(imageTag, "test-77166", "/bin/sh", true)
defer func() {
e2e.Logf("stop container %s", id)
containerCLI.ContainerStop(id)
e2e.Logf("remove container %s", id)
err := containerCLI.ContainerRemove(id)
if err != nil {
e2e.Failf("Defer: fail to remove container %s", id)
}
}()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("container id is %s", id)
e2e.Logf("start container %s", id)
err = containerCLI.ContainerStart(id)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("start container %s successful", id)
commandStr := []string{"ansible-operator", "version"}
output, err := containerCLI.Exec(id, commandStr)
if err != nil {
e2e.Failf("command %s: %s", commandStr, output)
}
o.Expect(output).To(o.ContainSubstring("v1.36."))
})
// author: [email protected]
g.It("Author:jitli-High-52126-Sync 1.29 to downstream", func() {
operatorsdkCLI.showInfo = true
output, _ := operatorsdkCLI.Run("version").Args().Output()
o.Expect(output).To(o.ContainSubstring("v1.29"))
})
// author: [email protected]
g.It("ConnectedOnly-VMonly-Author:chuo-High-34427-Ensure that Ansible Based Operators creation is working", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/memcached-operator-ansible-base:v" + ocpversion + getRandomString()
// TODO[aleskandro,chuo]: this is a workaround See https://issues.redhat.com/browse/ARMOCP-531
if clusterArchitecture == architecture.ARM64 {
imageTag = "quay.io/olmqe/memcached-operator-ansible-base:v" + ocpversion + "-34427"
}
nsSystem := "system-ocp34427" + getRandomString()
nsOperator := "memcached-operator-34427-system-" + getRandomString()
tmpBasePath := "/tmp/ocp-34427-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-34427")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
if imageTag != "quay.io/olmqe/memcached-operator-ansible-base:v"+ocpversion+"-34427" {
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}
defer func() {
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached34427", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
if !upstream {
exutil.By("step: OCP-52625 operatorsdk generate operator base image match the release version.")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
}
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-34427-data", "roles", "memcached")
err = copy(filepath.Join(dataPath, "tasks", "main.yml"), filepath.Join(tmpPath, "roles", "memcached34427", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "defaults", "main.yml"), filepath.Join(tmpPath, "roles", "memcached34427", "defaults", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$d' %s/config/samples/cache_v1alpha1_memcached34427.yaml", tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ size: 3' %s/config/samples/cache_v1alpha1_memcached34427.yaml", tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-34427-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-34427-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: Push the operator image")
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml", "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml --force")
tokenDir := "/tmp/ocp-34427-auth" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
switch clusterArchitecture {
case architecture.AMD64:
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
case architecture.ARM64:
e2e.Logf(fmt.Sprintf("platform is %s, IMG is %s", clusterArchitecture.String(), imageTag))
}
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached34427s.cache.example.com created"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "memcached34427s.cache.example.com").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-34427-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-34427-controller-manager") {
e2e.Logf("found pod memcached-operator-34427-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-34427-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-34427-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No memcached-operator-34427-controller-manager")
exutil.By("step: Create the resource")
filePath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached34427.yaml")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", filePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "memcached34427-sample") {
e2e.Logf("found pod memcached34427-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No pod memcached34427-sample")
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached34427-sample-memcached", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "3 desired | 3 updated | 3 total | 3 available | 0 unavailable") {
e2e.Logf("deployment/memcached34427-sample-memcached is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached34427-sample-memcached", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf(msg)
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("events", "-n", nsOperator).Output()
e2e.Logf(msg)
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached34427-sample-memcached is wrong")
exutil.By("34427 SUCCESS")
})
// author: [email protected]
g.It("ConnectedOnly-VMonly-Author:chuo-Medium-34366-change ansible operator flags from maxWorkers using env MAXCONCURRENTRECONCILES ", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/memcached-operator-max-worker:v" + ocpversion + getRandomString()
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
if clusterArchitecture == architecture.ARM64 {
imageTag = "quay.io/olmqe/memcached-operator-max-worker:v" + ocpversion + "-34366"
}
nsSystem := "system-ocp34366" + getRandomString()
nsOperator := "memcached-operator-34366-system-" + getRandomString()
tmpBasePath := "/tmp/ocp-34366-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-34366")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
if imageTag != "quay.io/olmqe/memcached-operator-max-worker:v"+ocpversion+"-34366" {
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}
defer func() {
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
if !upstream {
exutil.By("step: modify Dockerfile.")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
}
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached34366", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-34366-data")
err = copy(filepath.Join(dataPath, "roles", "memcached", "tasks", "main.yml"), filepath.Join(tmpPath, "roles", "memcached34366", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "config", "manager", "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-34366-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-34366-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: build and push img.")
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml", "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml --force")
tokenDir := "/tmp/ocp-34366-auth" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
switch clusterArchitecture {
case architecture.AMD64:
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
case architecture.ARM64:
e2e.Logf(fmt.Sprintf("platform is %s, IMG is %s", clusterArchitecture.String(), imageTag))
}
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached34366s.cache.example.com created"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "memcached34366s.cache.example.com").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-34366-controller-manager"))
_, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-cluster-role-to-user", "cluster-admin", fmt.Sprintf("system:serviceaccount:%s:default", nsOperator)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "Running") {
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "memcached-operator-34366-controller-manager has no Starting workers")
output, err = oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-34366-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("\"worker count\":6"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-Medium-34883-SDK stamp on Operator bundle image [Slow]", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-34883-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-34883")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-34883-data")
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached34883", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: make bundle.")
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-34883.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "memcached-operator-34883.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := makeCLI.Run("bundle").Args().Output()
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
exutil.By("Step: check annotations")
annotationsFile := filepath.Join(tmpPath, "bundle", "metadata", "annotations.yaml")
content := getContent(annotationsFile)
o.Expect(content).To(o.ContainSubstring("operators.operatorframework.io.metrics.builder: operator-sdk"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:chuo-Critical-45431-Critical-45428-Medium-43973-Medium-43976-Medium-48630-scorecard basic test migration and migrate olm tests and proxy configurable and xunit adjustment and sa ", func() {
operatorsdkCLI.showInfo = true
oc.SetupProject()
tmpBasePath := "/tmp/ocp-45431-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-43973-data")
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "memcached-operator.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args().Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
output, _ := operatorsdkCLI.Run("version").Args("").Output()
e2e.Logf("The OperatorSDK version is %s", output)
// OCP-43973
exutil.By("scorecard basic test migration")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=basic-check-spec-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("spec missing from [memcached-sample]"))
// OCP-43976
exutil.By("migrate OLM tests-bundle validation")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
exutil.By("migrate OLM tests-crds have validation test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-crds-have-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
exutil.By("migrate OLM tests-crds have resources test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-crds-have-resources-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: fail"))
o.Expect(output).To(o.ContainSubstring("Owned CRDs do not have resources specified"))
exutil.By("migrate OLM tests- spec descriptors test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-spec-descriptors-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: fail"))
exutil.By("migrate OLM tests- status descriptors test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-status-descriptors-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("memcacheds.cache.example.com does not have status spec"))
// OCP-48630
exutil.By("scorecard proxy container port should be configurable")
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\proxy-port: 9001' %s/bundle/tests/scorecard/config.yaml", tmpPath)).Output()
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
// OCP-45428 xunit adjustments - add nested tags and attributes
exutil.By("migrate OLM tests-bundle validation to generate a pass xunit output")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test", "-o", "xunit", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("<testsuite name=\"olm-bundle-validation-test\""))
o.Expect(output).To(o.ContainSubstring("<testcase name=\"olm-bundle-validation\""))
exutil.By("migrate OLM tests-status descriptors to generate a failed xunit output")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-status-descriptors-test", "-o", "xunit", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("<testcase name=\"olm-status-descriptors\""))
o.Expect(output).To(o.ContainSubstring("<system-out>Loaded ClusterServiceVersion:"))
o.Expect(output).To(o.ContainSubstring("failure"))
// OCP-45431 bring in latest o-f/api to SDK BEFORE 1.13
exutil.By("use an non-exist service account to run test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test ", "-s", "testing", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("serviceaccount \"testing\" not found"))
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", "test/extended/testdata/operatorsdk/ocp-43973-data/sa_testing.yaml", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
_, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test ", "-s", "testing", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:chuo-High-43660-scorecard support storing test output", func() {
operatorsdkCLI.showInfo = true
oc.SetupProject()
tmpBasePath := "/tmp/ocp-43660-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-43660")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-43660-data")
exutil.By("step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached43660", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: make bundle.")
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-43660.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "memcached-operator-43660.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args().Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
exutil.By("run scorecard ")
output, err := operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "4m", "--selector=test=olm-bundle-validation-test", "--test-output", "/testdata", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("Name: olm-bundle-validation"))
exutil.By("step: modify test config.")
configFilePath := filepath.Join(tmpPath, "bundle", "tests", "scorecard", "config.yaml")
replaceContent(configFilePath, "mountPath: {}", "mountPath:\n path: /test-output")
exutil.By("scorecard basic test migration")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "60s", "--selector=test=basic-check-spec-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("spec missing from [memcached43660-sample]"))
pathOutput := filepath.Join(tmpPath, "test-output", "basic", "basic-check-spec-test")
waitErr = wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) {
if _, err := os.Stat(pathOutput); os.IsNotExist(err) {
e2e.Logf("get basic-check-spec-test Failed")
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(waitErr, "get basic-check-spec-test Failed")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "60s", "--selector=test=olm-bundle-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
pathOutput = filepath.Join(tmpPath, "test-output", "olm", "olm-bundle-validation-test")
waitErr = wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) {
if _, err := os.Stat(pathOutput); os.IsNotExist(err) {
e2e.Logf("get olm-bundle-validation-test Failed")
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(waitErr, "get olm-bundle-validation-test Failed")
})
// author: [email protected]
g.It("ConnectedOnly-Author:chuo-High-31219-scorecard bundle is mandatory ", func() {
operatorsdkCLI.showInfo = true
oc.SetupProject()
tmpBasePath := "/tmp/ocp-31219-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-31219")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins", "ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
output, err := operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
result, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk generate bundle --deploy-dir=config --crds-dir=config/crds --version=0.0.1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Bundle manifests generated successfully in bundle"))
output, err = operatorsdkCLI.Run("scorecard").Args("bundle", "-c", "config/scorecard/bases/config.yaml", "-w", "60s", "--selector=test=basic-check-spec-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("tests selected"))
})
// author: [email protected]
g.It("ConnectedOnly-VMonly-Author:chuo-High-34426-Critical-52625-Medium-37142-ensure that Helm Based Operators creation and cr create delete ", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/nginx-operator-base:v" + ocpversion + "-34426" + getRandomString()
nsSystem := "system-34426-" + getRandomString()
nsOperator := "nginx-operator-34426-system"
tmpBasePath := "/tmp/ocp-34426-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "nginx-operator-34426")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer func() {
quayCLI := container.NewQuayCLI()
quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}()
defer func() {
exutil.By("delete nginx-sample")
filePath := filepath.Join(tmpPath, "config", "samples", "demo_v1_nginx34426.yaml")
oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", filePath, "-n", nsOperator).Output()
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) {
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("Nginx34426", "-n", nsOperator).Output()
if strings.Contains(output, "nginx34426-sample") {
e2e.Logf("nginx34426-sample still exists")
return false, nil
}
return true, nil
})
if waitErr != nil {
e2e.Logf("delete nginx-sample failed, still try to run make undeploy")
}
exutil.By("step: run make undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Helm Based Operators")
output, err := operatorsdkCLI.Run("init").Args("--plugins=helm").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next: define a resource with"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "demo", "--version", "v1", "--kind", "Nginx34426").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("nginx"))
if !upstream {
exutil.By("step: OCP-52625 operatorsdk generate operator base image match the release version .")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-helm-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion)
}
exutil.By("step: modify namespace")
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: nginx-operator-34426-system/namespace: %s/g' `grep -rl \"namespace: nginx-operator-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: build and Push the operator image")
tokenDir := "/tmp/ocp-34426" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("nginx34426s.demo.my.domain"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "nginx34426s.demo.my.domain").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/nginx-operator-34426-controller-manager created"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "nginx-operator-34426-controller-manager") {
e2e.Logf("found pod nginx-operator-34426-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod nginx-operator-34426-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod nginx-operator-34426-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if err != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No nginx-operator-34426-controller-manager")
_, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:nginx34426-sample", nsOperator)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
// OCP-37142
exutil.By("step: Create the resource")
filePath := filepath.Join(tmpPath, "config", "samples", "demo_v1_nginx34426.yaml")
replaceContent(filePath, "repository: nginx", "repository: quay.io/olmqe/nginx-docker")
replaceContent(filePath, "tag: \"\"", "tag: multi-arch")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", filePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(podList, "nginx34426-sample") {
e2e.Logf("No nginx34426-sample")
return false, nil
}
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "nginx34426-sample") {
e2e.Logf("found pod nginx34426-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod nginx34426-sample is Running")
return true, nil
}
e2e.Logf("the status of pod nginx34426-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No nginx34426-sample is in Running status")
})
// author: [email protected]
g.It("Author:jitli-VMonly-ConnectedOnly-Critical-38101-implement IndexImageCatalogCreator [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
exutil.By("0) check the cluster proxy configuration")
httpProxy, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxy", "cluster", "-o=jsonpath={.status.httpProxy}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
if httpProxy != "" {
g.Skip("Skip for cluster with proxy")
}
exutil.By("step: create new project")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: run bundle 1")
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/kubeturbo-bundle:v8.4.0", "-n", ns, "--timeout", "5m", "--security-context-config=restricted").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("step: check catsrc annotations")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("index-image"))
o.Expect(output).To(o.ContainSubstring("injected-bundles"))
o.Expect(output).To(o.ContainSubstring("registry-pod-name"))
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.4.0"))
o.Expect(output).NotTo(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.5.0"))
exutil.By("step: check catsrc address")
podname1, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations.operators\\.operatorframework\\.io/registry-pod-name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podname1).NotTo(o.BeEmpty())
ip, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", podname1, "-n", oc.Namespace(), "-o=jsonpath={.status.podIP}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(ip).NotTo(o.BeEmpty())
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.address}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal(ip + ":50051"))
exutil.By("step: check catsrc sourceType")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.sourceType}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("grpc"))
exutil.By("step: check packagemanifest")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].currentCSV}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("kubeturbo-operator.v8.4.0"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk-run-bundle"))
exutil.By("step: upgrade bundle")
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/kubeturbo-bundle:v8.5.0", "-n", ns, "--timeout", "5m", "--security-context-config=restricted").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "kubeturbo-operator.v8.5.0", "-n", ns).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 8.5.0 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradeoperator upgrade failed in %s ", ns))
exutil.By("step: check catsrc annotations")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("index-image"))
o.Expect(output).To(o.ContainSubstring("injected-bundles"))
o.Expect(output).To(o.ContainSubstring("registry-pod-name"))
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.4.0"))
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.5.0"))
exutil.By("step: check catsrc address")
podname2, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations.operators\\.operatorframework\\.io/registry-pod-name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podname2).NotTo(o.BeEmpty())
o.Expect(podname2).NotTo(o.Equal(podname1))
ip, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", podname2, "-n", oc.Namespace(), "-o=jsonpath={.status.podIP}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(ip).NotTo(o.BeEmpty())
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.address}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal(ip + ":50051"))
exutil.By("step: check catsrc sourceType")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.sourceType}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal("grpc"))
exutil.By("step: check packagemanifest")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].currentCSV}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("kubeturbo-operator.v8.5.0"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk-run-bundle"))
exutil.By("SUCCESS")
})
// author: [email protected]
g.It("Author:jitli-VMonly-ConnectedOnly-High-42028-Check python kubernetes package", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
imageTag := "registry-proxy.engineering.redhat.com/rh-osbs/openshift-ose-ansible-rhel9-operator:v" + ocpversion
containerCLI := container.NewPodmanCLI()
e2e.Logf("create container with image %s", imageTag)
id, err := containerCLI.ContainerCreate(imageTag, "test-42028", "/bin/sh", true)
defer func() {
e2e.Logf("stop container %s", id)
containerCLI.ContainerStop(id)
e2e.Logf("remove container %s", id)
err := containerCLI.ContainerRemove(id)
if err != nil {
e2e.Failf("Defer: fail to remove container %s", id)
}
}()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("container id is %s", id)
e2e.Logf("start container %s", id)
err = containerCLI.ContainerStart(id)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("start container %s successful", id)
commandStr := []string{"pip3", "show", "kubernetes"}
output, err := containerCLI.Exec(id, commandStr)
e2e.Logf("command %s: %s", commandStr, output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Version:"))
o.Expect(output).To(o.ContainSubstring("30.1."))
e2e.Logf("OCP 42028 SUCCESS")
})
// author: [email protected]
g.It("Author:jitli-ConnectedOnly-VMonly-High-44295-Ensure that Go type Operators creation is working [Slow]", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
architecture.SkipNonAmd64SingleArch(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-44295-data")
quayCLI := container.NewQuayCLI()
imageTag := "quay.io/olmqe/memcached-operator:44295-" + getRandomString()
tmpBasePath := "/tmp/ocp-44295-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44295")
nsSystem := "system-ocp44295" + getRandomString()
nsOperator := "memcached-operator-system-ocp44295" + getRandomString()
defer os.RemoveAll(tmpBasePath)
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("step: generate go type operator")
defer func() {
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
output, err := operatorsdkCLI.Run("init").Args("--domain=example.com", "--repo=github.com/example-inc/memcached-operator-44295").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing scaffold for you to edit"))
o.Expect(output).To(o.ContainSubstring("Next: define a resource with"))
exutil.By("step: Create a Memcached API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--resource=true", "--controller=true", "--group=cache", "--version=v1alpha1", "--kind=Memcached44295").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Update dependencies"))
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: update API")
err = copy(filepath.Join(dataPath, "memcached_types.go"), filepath.Join(tmpPath, "api", "v1alpha1", "memcached44295_types.go"))
o.Expect(err).NotTo(o.HaveOccurred())
_, err = makeCLI.Run("generate").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: make manifests")
_, err = makeCLI.Run("manifests").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: modify namespace and controllers")
crFilePath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached44295.yaml")
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$d' %s", crFilePath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ size: 3' %s", crFilePath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: system-ocp44295/g' `grep -rl \"name: system\" %s`", tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-44295-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-44295-system\" %s`", nsOperator, tmpPath)).Output()
err = copy(filepath.Join(dataPath, "memcached_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached44295_controller.go"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build the operator image")
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "golang:", "quay.io/olmqe/golang:")
output, err = makeCLI.Run("docker-build").Args("IMG=" + imageTag).Output()
if (err != nil) && strings.Contains(output, "go mod tidy") {
e2e.Logf("execute go mod tidy")
exec.Command("bash", "-c", fmt.Sprintf("cd %s; go mod tidy", tmpPath)).Output()
output, err = makeCLI.Run("docker-build").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("docker build -t"))
} else {
o.Expect(output).To(o.ContainSubstring("docker build -t"))
}
exutil.By("step: Push the operator image")
_, err = makeCLI.Run("docker-push").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Install kustomize")
kustomizePath := "/root/kustomize"
binPath := filepath.Join(tmpPath, "bin")
exec.Command("bash", "-c", fmt.Sprintf("cp %s %s", kustomizePath, binPath)).Output()
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached44295s.cache.example.com"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44295-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-44295-controller-manager") {
e2e.Logf("found pod memcached-operator-44295-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-44295-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-44295-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44295-controller-manager in project %s", nsOperator))
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44295-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("Starting workers"))
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "memcached44295-sample") {
e2e.Logf("found pod memcached44295-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44295-sample in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44295-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "3 desired | 3 updated | 3 total | 3 available | 0 unavailable") {
e2e.Logf("deployment/memcached44295-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44295-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf(msg)
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("events", "-n", nsOperator).Output()
e2e.Logf(msg)
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44295-sample is wrong")
exutil.By("OCP 44295 SUCCESS")
})
// author: [email protected]
g.It("Author:jitli-ConnectedOnly-VMonly-High-52371-Enable Micrometer Metrics from java operator plugins", func() {
g.Skip("OperatorSDK Java plugin unavailable and no plan to fix it, so skip it")
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
architecture.SkipNonAmd64SingleArch(oc)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-52371-data")
clusterrolebindingtemplate = filepath.Join(buildPruningBaseDir, "cluster-role-binding.yaml")
quayCLI = container.NewQuayCLI()
imageTag = "quay.io/olmqe/memcached-quarkus-operator:52371-" + getRandomString()
tmpBasePath = "/tmp/ocp-52371-" + getRandomString()
tmpOperatorPath = filepath.Join(tmpBasePath, "memcached-quarkus-operator-52371")
kubernetesYamlFilePath = filepath.Join(tmpOperatorPath, "target", "kubernetes", "kubernetes.yml")
)
operatorsdkCLI.ExecCommandPath = tmpOperatorPath
makeCLI.ExecCommandPath = tmpOperatorPath
mvnCLI.ExecCommandPath = tmpOperatorPath
err := os.MkdirAll(tmpOperatorPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
exutil.By("step: generate java type operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=quarkus", "--domain=example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk create api"))
exutil.By("step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--plugins=quarkus", "--group=cache", "--version=v1", "--kind=Memcached52371").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: update API and Controller")
examplePath := filepath.Join(tmpOperatorPath, "src", "main", "java", "com", "example")
err = copy(filepath.Join(dataPath, "Memcached52371Reconciler.java"), filepath.Join(examplePath, "Memcached52371Reconciler.java"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "Memcached52371Spec.java"), filepath.Join(examplePath, "Memcached52371Spec.java"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "Memcached52371Status.java"), filepath.Join(examplePath, "Memcached52371Status.java"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "pom.xml"), filepath.Join(tmpOperatorPath, "pom.xml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step:mvn clean install")
output, err = mvnCLI.Run("clean").Args("install").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS"))
exutil.By("step: Build and push the operator image")
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
output, err = makeCLI.Run("docker-build").Args("docker-push", "IMG="+imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS"))
exutil.By("step: Deploy the operator")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: Install the CRD")
defer func() {
exutil.By("step: delete crd.")
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", filepath.Join(tmpOperatorPath, "target", "kubernetes", "memcached52371s.cache.example.com-v1.yml")).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", filepath.Join(tmpOperatorPath, "target", "kubernetes", "memcached52371s.cache.example.com-v1.yml")).Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create rcbc file")
insertContent(kubernetesYamlFilePath, "- kind: ServiceAccount", " namespace: "+ns)
exutil.By("step: Deploy the operator")
defer func() {
exutil.By("step: delete operator.")
_, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", kubernetesYamlFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", kubernetesYamlFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
clusterrolebinding := clusterrolebindingDescription{
name: "memcached52371-operator-admin",
namespace: ns,
saname: "memcached-quarkus-operator-52371-operator",
template: clusterrolebindingtemplate,
}
clusterrolebinding.create(oc)
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-quarkus-operator-52371-operator") {
e2e.Logf("found pod memcached-quarkus-operator-52371-operator")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-quarkus-operator-52371-operator is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-quarkus-operator-52371-operator is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-quarkus-operator-52371-operator in project %s", ns))
label := `app.kubernetes.io/name=memcached-quarkus-operator-52371-operator`
podName, err := oc.AsAdmin().Run("get").Args("-n", ns, "pod", "-l", label, "-ojsonpath={..metadata.name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podName).NotTo(o.BeEmpty())
exutil.By("step: Create CR")
crFilePath := filepath.Join(dataPath, "memcached-sample.yaml")
defer func() {
exutil.By("step: delete cr.")
_, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached52371-sample") {
e2e.Logf("found pod memcached52371-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached52371-sample is Running")
return true, nil
}
e2e.Logf("the status of pod memcached52371-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("Memcached52371", "-n", ns).Output()
e2e.Logf(output)
output, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", ns).Output()
e2e.Logf(output)
output, _ = oc.AsAdmin().WithoutNamespace().Run("logs").Args("-n", ns, podName).Output()
e2e.Logf(output)
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52371-sample in project %s or the pod is not running", ns))
exutil.By("check Micrometer Metrics is enable")
clusterIP, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", ns, "service", "memcached-quarkus-operator-52371-operator", "-o=jsonpath={.spec.clusterIP}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(clusterIP).NotTo(o.BeEmpty())
url := fmt.Sprintf("http://%s/q/metrics", clusterIP)
output, err = oc.AsAdmin().WithoutNamespace().Run("rsh").Args("-n", ns, podName, "curl", url).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.BeEmpty())
o.Expect(output).To(o.ContainSubstring("system_cpu_count"))
exutil.By("OCP 52371 SUCCESS")
})
// author: [email protected]
g.It("Author:jitli-ConnectedOnly-VMonly-High-52377-operatorSDK support java plugin", func() {
g.Skip("OperatorSDK Java plugin unavailable and no plan to fix it, so skip it")
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
exutil.SkipOnProxyCluster(oc)
architecture.SkipNonAmd64SingleArch(oc)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-52377-data")
clusterrolebindingtemplate = filepath.Join(buildPruningBaseDir, "cluster-role-binding.yaml")
quayCLI = container.NewQuayCLI()
imageTag = "quay.io/olmqe/memcached-quarkus-operator:52377-" + getRandomString()
bundleImage = "quay.io/olmqe/memcached-quarkus-bundle:52377-" + getRandomString()
tmpBasePath = "/tmp/ocp-52377-" + getRandomString()
tmpOperatorPath = filepath.Join(tmpBasePath, "memcached-quarkus-operator-52377")
)
operatorsdkCLI.ExecCommandPath = tmpOperatorPath
makeCLI.ExecCommandPath = tmpOperatorPath
mvnCLI.ExecCommandPath = tmpOperatorPath
err := os.MkdirAll(tmpOperatorPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
exutil.By("step: generate java type operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=quarkus", "--domain=example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk create api"))
exutil.By("step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--plugins=quarkus", "--group=cache", "--version=v1", "--kind=Memcached52377").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: update API and Controller")
examplePath := filepath.Join(tmpOperatorPath, "src", "main", "java", "com", "example")
err = copy(filepath.Join(dataPath, "Memcached52377Reconciler.java"), filepath.Join(examplePath, "Memcached52377Reconciler.java"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "Memcached52377Spec.java"), filepath.Join(examplePath, "Memcached52377Spec.java"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "Memcached52377Status.java"), filepath.Join(examplePath, "Memcached52377Status.java"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "pom.xml"), filepath.Join(tmpOperatorPath, "pom.xml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step:mvn clean install")
output, err = mvnCLI.Run("clean").Args("install").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS"))
exutil.By("step: Build and push the operator image")
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
output, err = makeCLI.Run("docker-build").Args("docker-push", "IMG="+imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("BUILD SUCCESS"))
exutil.By("step: make bundle.")
output, err = makeCLI.Run("bundle").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk bundle validate"))
exutil.By("step: update csv file")
csvFile := filepath.Join(tmpOperatorPath, "bundle", "manifests", "memcached-quarkus-operator-52377.clusterserviceversion.yaml")
replaceContent(csvFile, "supported: false", "supported: true")
exutil.By("step: build and push bundle image.")
defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1))
_, err = makeCLI.Run("bundle-build").Args("bundle-push", "BUNDLE_IMG="+bundleImage).Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: create new project")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: run bundle")
defer func() {
output, err = operatorsdkCLI.Run("cleanup").Args("memcached-quarkus-operator-52377", "-n", ns).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, err = operatorsdkCLI.Run("run").Args("bundle", bundleImage, "-n", ns, "--timeout", "5m", "--security-context-config=restricted").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("step: create clusterrolebinding")
clusterrolebinding := clusterrolebindingDescription{
name: "memcached52377-operator-admin",
namespace: ns,
saname: "memcached-quarkus-operator-52377-operator",
template: clusterrolebindingtemplate,
}
clusterrolebinding.create(oc)
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-quarkus-operator-52377-operator") {
e2e.Logf("found pod memcached-quarkus-operator-52377-operator")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-quarkus-operator-52377-operator is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-quarkus-operator-52377-operator is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "pod", "csv", "catsrc")
}
exutil.By("step: Create CR")
crFilePath := filepath.Join(dataPath, "memcached-sample.yaml")
defer func() {
exutil.By("step: delete cr.")
_, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached52377-sample") {
e2e.Logf("found pod memcached52377-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached52377-sample is Running")
return true, nil
}
e2e.Logf("the status of pod memcached52377-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "Memcached52377", "pod", "events")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52377-sample in project %s or the pod is not running", ns))
exutil.By("OCP 52377 SUCCESS")
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:chuo-High-40341-Ansible operator needs a way to pass vars as unsafe ", func() {
imageTag := "quay.io/olmqe/memcached-operator-pass-unsafe:v" + ocpversion + getRandomString()
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
if clusterArchitecture == architecture.ARM64 {
imageTag = "quay.io/olmqe/memcached-operator-pass-unsafe:v" + ocpversion + "-40341"
}
nsSystem := "system-40341-" + getRandomString()
nsOperator := "memcached-operator-40341-system-" + getRandomString()
tmpBasePath := "/tmp/ocp-40341-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-40341")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer func() {
if imageTag != "quay.io/olmqe/memcached-operator-pass-unsafe:v"+ocpversion+"-40341" {
quayCLI := container.NewQuayCLI()
quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}
}()
defer func() {
deployfilepath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached40341.yaml")
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", deployfilepath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached40341", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
if !upstream {
exutil.By("step: modify Dockerfile.")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
}
deployfilepath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached40341.yaml")
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$d' %s", deployfilepath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ size: 3' %s", deployfilepath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ testKey: testVal' %s", deployfilepath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-40341-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-40341-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: build and Push the operator image")
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml", "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml --force")
tokenDir := "/tmp/ocp-34426" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
switch clusterArchitecture {
case architecture.AMD64:
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
case architecture.ARM64:
e2e.Logf(fmt.Sprintf("platform is %s, IMG is %s", clusterArchitecture, imageTag))
}
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached40341s.cache.example.com created"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "memcached40341s.cache.example.com").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-40341-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-40341-controller-manager") {
e2e.Logf("found pod memcached-operator-40341-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-40341-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-40341-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No memcached-operator-40341-controller-manager")
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", deployfilepath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 10*time.Second, false, func(ctx context.Context) (bool, error) {
output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("memcached40341s.cache.example.com", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(output, "memcached40341-sample") {
e2e.Logf("cr memcached40341-sample is created")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No cr memcached40341-sample")
exutil.By("step: check vars")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("memcached40341s.cache.example.com/memcached40341-sample", "-n", nsOperator, "-o=jsonpath={.spec.size}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal("3"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("memcached40341s.cache.example.com/memcached40341-sample", "-n", nsOperator, "-o=jsonpath={.spec.testKey}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal("testVal"))
exutil.By("40341 SUCCESS")
})
// author: [email protected]
g.It("Author:jfan-Critical-49960-verify an empty CRD description", func() {
tmpBasePath := exutil.FixturePath("testdata", "operatorsdk", "ocp-49960-data")
exutil.By("step: validate CRD description success")
output, err := operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--select-optional", "name=good-practices").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("All validation tests have completed successfully"))
exutil.By("step: validate empty CRD description")
csvFilePath := filepath.Join(tmpBasePath, "bundle", "manifests", "k8sevent.clusterserviceversion.yaml")
replaceContent(csvFilePath, "description: test", "description:")
output, err = operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--select-optional", "name=good-practices").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("has an empty description"))
exutil.By("step: validate olm unsupported resource")
crdFilePath := filepath.Join(tmpBasePath, "bundle", "manifests", "k8s.k8sevent.com_k8sevents.yaml")
replaceContent(crdFilePath, "CustomResourceDefinition", "CustomResource")
output, _ = operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--select-optional", "name=good-practices").Output()
o.Expect(output).To(o.ContainSubstring("unsupported media type"))
exutil.By("SUCCESS 49960")
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-48885-SDK generate digest type bundle of ansible", func() {
architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-48885-data")
tmpBasePath := "/tmp/ocp-48885-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-48885")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1", "--kind", "Memcached48885", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy task main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "memcached48885", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", "quay.io/olmqe/ansibledisconnected:v4.11")
replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)")
exutil.By("step: make bundle.")
// copy manifests
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-48885.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "memcached-operator-48885.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
// make bundle use image digests
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-48885.clusterserviceversion.yaml")
content := getContent(csvFile)
if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/ansibledisconnected@sha256:") {
e2e.Failf("Fail to get the image info with digest type")
}
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-52813-SDK generate digest type bundle of helm", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-52813-data")
tmpBasePath := "/tmp/ocp-52813-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-52813")
imageTag := "quay.io/olmqe/memcached-operator:52813-" + getRandomString()
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer func() {
quayCLI := container.NewQuayCLI()
quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}()
exutil.By("step: init Helm Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=helm", "--domain=disconnected.com", "--group=test", "--version=v1", "--kind=Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Created helm-charts"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy watches.yaml
err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy helm-charts/nginx/values.yaml
err = copy(filepath.Join(dataPath, "values.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "values.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the file helm-charts/nginx/templates/deployment.yaml
deployFilepath := filepath.Join(tmpPath, "helm-charts", "nginx", "templates", "deployment.yaml")
replaceContent(deployFilepath, ".Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion", ".Values.relatedImage")
// update the Dockerfile
dockerFile := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion)
// copy the manager
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-52813" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)")
exutil.By("step: make bundle.")
// copy manifests
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52813.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "memcached-operator-52813.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
// make bundle use image digests
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52813.clusterserviceversion.yaml")
content := getContent(csvFile)
if !strings.Contains(content, "quay.io/olmqe/nginx@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") {
e2e.Failf("Fail to get the image info with digest type")
}
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-52814-SDK generate digest type bundle of go", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-52814-data")
tmpBasePath := "/tmp/ocp-52814-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-52814")
imageTag := "quay.io/olmqe/memcached-operator:52814-" + getRandomString()
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer func() {
quayCLI := container.NewQuayCLI()
quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}()
exutil.By("step: init Go Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--domain=disconnected.com", "--repo=github.com/example-inc/memcached-operator").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: create api")
output, err = operatorsdkCLI.Run("create").Args("api", "--group=test", "--version=v1", "--kind=Memcached52814", "--controller", "--resource").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("make manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy api/v1/memcached52814_types.go
err = copy(filepath.Join(dataPath, "memcached52814_types.go"), filepath.Join(tmpPath, "api", "v1", "memcached52814_types.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy controllers/memcached52814_controller.go
err = copy(filepath.Join(dataPath, "memcached52814_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached52814_controller.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy the manager
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the Dockerfile
dockerfileFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerfileFilePath, "golang", "quay.io/olmqe/golang")
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-52814" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
exutil.By("step: Install kustomize")
kustomizePath := "/root/kustomize"
binPath := filepath.Join(tmpPath, "bin")
exec.Command("bash", "-c", fmt.Sprintf("cp %s %s", kustomizePath, binPath)).Output()
exutil.By("step: make bundle.")
// copy manifests
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52814.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "memcached-operator-52814.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
// make bundle use image digests
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52814.clusterserviceversion.yaml")
content := getContent(csvFile)
if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") {
e2e.Failf("Fail to get the image info with digest type")
}
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-44550-SDK support ansible type operator for http_proxy env", func() {
g.By("Check if it is a proxy platform")
proxySet, _ := oc.WithoutNamespace().AsAdmin().Run("get").Args("proxy/cluster", "-o=jsonpath={.spec.httpProxy}").Output()
if proxySet == " " {
g.Skip("Skip for no-proxy platform")
}
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
tmpBasePath := "/tmp/ocp-44550-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44550")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
nsOperator := "memcached-operator-44550-system"
imageTag := "quay.io/olmqe/memcached-operator:44550-" + getRandomString()
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-44550-data")
crFilePath := filepath.Join(dataPath, "cache_v1_memcached44550.yaml")
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1", "--kind", "Memcached44550", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy task main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "memcached44550", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
replaceContent(makefileFilePath, "build config/default | kubectl apply -f -", "build config/default | CLUSTER_PROXY=$(shell kubectl get proxies.config.openshift.io cluster -o json | jq '.spec.httpProxy') envsubst | kubectl apply -f -")
// update the Dockerfile
dockerFile := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
replaceContent(dockerFile, "install -r ${HOME}/requirements.yml", "install -r ${HOME}/requirements.yml --force")
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-44550" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached44550s.cache.example.com"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44550-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-44550-controller-manager") {
e2e.Logf("found pod memcached-operator-44550-controller-manager")
if strings.Contains(line, "1/1") {
e2e.Logf("the status of pod memcached-operator-44550-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-44550-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44550-controller-manager in project %s", nsOperator))
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44550-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(msg, "Starting workers") {
e2e.Failf("Starting workers failed")
}
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "memcached44550-sample-ansiblehttp") {
e2e.Logf("found pod memcached44550-sample-ansiblehttp")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44550-sample in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
proxyMsg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxies.config.openshift.io", "cluster", "-o=jsonpath={.spec.httpProxy}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44550-sample-ansiblehttp", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("HTTP_PROXY: " + proxyMsg))
if strings.Contains(msg, "3 desired | 3 updated | 3 total | 3 available | 0 unavailable") {
e2e.Logf("deployment/memcach44550-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events")
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44550-sample-ansiblehttp is wrong")
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-44551-SDK support helm type operator for http_proxy env", func() {
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
tmpBasePath := "/tmp/ocp-44551-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44551")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
nsOperator := "memcached-operator-44551-system"
imageTag := "quay.io/olmqe/memcached-operator:44551-" + getRandomString()
dataPath := "test/extended/testdata/operatorsdk/ocp-44551-data/"
crFilePath := filepath.Join(dataPath, "kakademo_v1_nginx.yaml")
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Helm Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=helm", "--domain=httpproxy.com", "--group=kakademo", "--version=v1", "--kind=Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Created helm-charts"))
exutil.By("step: modify files to generate the quay.io/olmqe images.")
// update the Dockerfile
dockerFile := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion)
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
replaceContent(makefileFilePath, "build config/default | kubectl apply -f -", "build config/default | CLUSTER_PROXY=$(shell kubectl get proxies.config.openshift.io cluster -o json | jq '.spec.httpProxy') envsubst | kubectl apply -f -")
// copy watches.yaml
err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy helm-charts/nginx/values.yaml
err = copy(filepath.Join(dataPath, "values.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "values.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy helm-charts/nginx/templates/deployment.yaml
err = copy(filepath.Join(dataPath, "deployment.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "templates", "deployment.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy config/manager/manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-44551" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("kakademo"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44551-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-44551-controller-manager") {
e2e.Logf("found pod memcached-operator-44551-controller-manager")
if strings.Contains(line, "1/1") {
e2e.Logf("the status of pod memcached-operator-44551-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-44551-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44551-controller-manager in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44551-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "Starting workers") {
e2e.Logf("Starting workers successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "container manager doesn't work")
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:nginx-sample", nsOperator)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "nginx-sample") {
e2e.Logf("found pod nginx-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44551-sample in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
proxyMsg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxies.config.openshift.io", "cluster", "-o=jsonpath={.spec.httpProxy}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/nginx-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("HTTP_PROXY: " + proxyMsg))
if strings.Contains(msg, "HTTP_PROXY: "+proxyMsg) {
e2e.Logf("deployment/nginx-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events")
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44551-sample-ansiblehttp is wrong")
})
// author: [email protected]
g.It("NonPreRelease-Longduration-VMonly-ConnectedOnly-Author:jitli-High-50065-SDK Add file based catalog support to run bundle", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
exutil.By("Run bundle without index")
defer operatorsdkCLI.Run("cleanup").Args("k8sevent", "-n", oc.Namespace()).Output()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/k8sevent-bundle:v4.11", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Generated a valid File-Based Catalog"))
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Run bundle with FBC index")
defer operatorsdkCLI.Run("cleanup").Args("blacklist", "-n", oc.Namespace()).Output()
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/blacklist-bundle:v4.11", "--index-image", "quay.io/olmqe/nginxolm-operator-index:v1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring(`Creating a File-Based Catalog of the bundle \"quay.io/olmqe/blacklist-bundle`))
o.Expect(output).To(o.ContainSubstring(`Rendering a File-Based Catalog of the Index Image \"quay.io/olmqe/nginxolm-operator-index:v1\"`))
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Run bundle with SQLite index")
defer operatorsdkCLI.Run("cleanup").Args("k8sstatus", "-n", oc.Namespace()).Output()
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/k8sstatus-bundle:v4.11", "--index-image", "quay.io/olmqe/ditto-index:50065", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("SQLite based index images are being deprecated and will be removed in a future release"))
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Run bundle with index that contains the bundle message")
defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", oc.Namespace()).Output()
_, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeindex-bundle:v0.1", "--index-image", "quay.io/olmqe/upgradeindex-index:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
output, _ = oc.AsAdmin().WithoutNamespace().Run("logs").Args("-n", oc.Namespace(), "quay-io-olmqe-upgradeindex-bundle-v0-1").Output()
if !strings.Contains(output, "Bundle quay.io/olmqe/upgradeindex-bundle:v0.1 already exists, Bundle already added that provides package and csv") {
e2e.Failf("Cannot get log Bundle quay.io/olmqe/upgradeindex-bundle:v0.1 already exists, Bundle already added that provides package and csv")
}
})
// author: [email protected]
g.It("Author:jitli-VMonly-ConnectedOnly-High-52364-SDK Run bundle not support large FBC index since OCP4.14 [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
exutil.By("Run bundle with large FBC index (size >3M)")
defer operatorsdkCLI.Run("cleanup").Args("upgradefbc", "-n", oc.Namespace()).Output()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradefbc-bundle:v0.1", "--index-image", "quay.io/operatorhubio/catalog:latest", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Too long: must have at most 1048576 bytes"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-High-51295-SDK-Run bundle-upgrade from bundle installation without index image [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
exutil.By("Run bundle install operator without index image v0.1")
defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", oc.Namespace()).Output()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeindex-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Run bundle-upgrade from the csv v.0.1->v0.2")
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Generated a valid Upgraded File-Based Catalog"))
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-High-51296-SDK-Run bundle-upgrade from bundle installation with index image [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
exutil.By("Run bundle install operator with SQLite index image csv 0.1")
defer operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "--index-image", "quay.io/olmqe/upgradeindex-index:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Run bundle-upgrade from the csv v.0.1->v0.2")
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeoperator-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Updated catalog source upgradeoperator-catalog"))
o.Expect(output).To(o.ContainSubstring("Successfully upgraded"))
exutil.By("Run bundle install operator with FBC index image")
defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", oc.Namespace()).Output()
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeindex-bundle:v0.1", "--index-image", "quay.io/olmqe/nginxolm-operator-index:v1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Generated a valid File-Based Catalog"))
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Run bundle-upgrade from the csv v.0.1->v0.2")
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Generated a valid Upgraded File-Based Catalog"))
o.Expect(output).To(o.ContainSubstring("Successfully upgraded"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-44553-SDK support go type operator for http_proxy env [Slow]", func() {
architecture.SkipNonAmd64SingleArch(oc)
tmpBasePath := "/tmp/ocp-44553-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-44553")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
nsOperator := "memcached-operator-44553-system"
imageTag := "quay.io/olmqe/memcached-operator:44553-" + getRandomString()
dataPath := "test/extended/testdata/operatorsdk/ocp-44553-data/"
crFilePath := filepath.Join(dataPath, "cache_v1_memcached44553.yaml")
quayCLI := container.NewQuayCLI()
exutil.By("step: clear unnecessary tokens")
githubToken := os.Getenv("GITHUB_TOKEN")
if githubToken != "" {
defer os.Setenv("GITHUB_TOKEN", githubToken)
os.Setenv("GITHUB_TOKEN", "")
}
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Go Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--domain=httpproxy.com", "--repo=github.com/example-inc/memcached-operator", "--plugins=go/v4").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("create api"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group=cache", "--version=v1", "--kind=Memcached44553", "--resource", "--controller").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("make manifests"))
exutil.By("step: modify files to generate the quay.io/olmqe images.")
// update the Dockerfile
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "golang:", "quay.io/olmqe/golang:")
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
replaceContent(makefileFilePath, "build config/default | kubectl apply -f -", "build config/default | CLUSTER_PROXY=$(shell kubectl get proxies.config.openshift.io cluster -o json | jq '.spec.httpProxy') envsubst | kubectl apply -f -")
// copy config/manager/manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy controllers/memcached44553_controller.go
err = copy(filepath.Join(dataPath, "memcached44553_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached44553_controller.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy api/v1/memcached44553_types.go
err = copy(filepath.Join(dataPath, "memcached44553_types.go"), filepath.Join(tmpPath, "api", "v1", "memcached44553_types.go"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-44553" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// replace the go.sum & go.mod
err = copy(filepath.Join(dataPath, "44553gosum"), filepath.Join(tmpPath, "go.sum"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "44553gomod"), filepath.Join(tmpPath, "go.mod"))
o.Expect(err).NotTo(o.HaveOccurred())
podmanCLI := container.NewPodmanCLI()
podmanCLI.ExecCommandPath = tmpPath
output, err = podmanCLI.Run("build").Args(tmpPath, "--arch", "amd64", "--tag", imageTag, "--authfile", fmt.Sprintf("%s/.dockerconfigjson", tokenDir)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully"))
output, err = podmanCLI.Run("push").Args(imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing manifest to image destination"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-44553-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-44553-controller-manager") {
e2e.Logf("found pod memcached-operator-44553-controller-manager")
if strings.Contains(line, "2/2") {
e2e.Logf("the status of pod memcached-operator-44553-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-44553-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-44553-controller-manager in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-44553-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "Starting workers") {
e2e.Logf("Starting workers successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "container manager doesn't work")
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "memcached44553-sample") {
e2e.Logf("found pod memcached44553-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached44553-sample in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
proxyMsg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxies.config.openshift.io", "cluster", "-o=jsonpath={.spec.httpProxy}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached44553-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "HTTP_PROXY: "+proxyMsg) {
e2e.Logf("deployment/memcached44553-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events")
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached44553-sample is wrong")
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-High-51300-SDK Run bundle upgrade from bundle installation with multi bundles index image", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
var (
dr = make(describerResrouce)
itName = g.CurrentSpecReport().FullText()
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
og = operatorGroupDescription{
name: "test-og-51300",
namespace: oc.Namespace(),
template: ogSingleTemplate,
}
catsrc = catalogSourceDescription{
name: "upgradefbc-index-51300",
namespace: oc.Namespace(),
displayName: "Test 51300 Operators",
publisher: "OperatorSDK QE",
sourceType: "grpc",
address: "quay.io/olmqe/upgradefbcmuli-index:v0.1",
interval: "15m",
template: catsrcImageTemplate,
}
sub = subscriptionDescription{
subName: "upgradefbc-index-51300",
namespace: oc.Namespace(),
catalogSourceName: catsrc.name,
catalogSourceNamespace: oc.Namespace(),
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "upgradefbc",
template: subTemplate,
}
)
dr.addIr(itName)
exutil.By("Install the OperatorGroup")
og.createwithCheck(oc, itName, dr)
exutil.By("Create catalog source")
catsrc.createWithCheck(oc, itName, dr)
exutil.By("Install operator")
sub.create(oc, itName, dr)
exutil.By("Check Operator is Succeeded")
newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", sub.installedCSV, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc)
exutil.By("Run bundle-upgrade operator")
output, err := operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradefbc-bundle:v0.0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradefbc.v0.0.2", "-n", oc.Namespace()).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 0.0.2 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradefbc upgrade failed in %s ", oc.Namespace()))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-High-50141-SDK Run bundle upgrade from OLM installed operator [Slow]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
var (
dr = make(describerResrouce)
itName = g.CurrentSpecReport().FullText()
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
og = operatorGroupDescription{
name: "test-og-50141",
namespace: oc.Namespace(),
template: ogSingleTemplate,
}
catsrcfbc = catalogSourceDescription{
name: "upgradefbc-index-50141",
namespace: oc.Namespace(),
displayName: "Test 50141 Operators FBC",
publisher: "OperatorSDK QE",
sourceType: "grpc",
address: "quay.io/olmqe/upgradefbc-index:v0.1",
interval: "15m",
template: catsrcImageTemplate,
}
subfbc = subscriptionDescription{
subName: "upgradefbc-index-50141",
namespace: oc.Namespace(),
catalogSourceName: catsrcfbc.name,
catalogSourceNamespace: oc.Namespace(),
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "upgradefbc",
template: subTemplate,
}
catsrcsqlite = catalogSourceDescription{
name: "upgradeindex-sqlite-50141",
namespace: oc.Namespace(),
displayName: "Test 50141 Operators SQLite",
publisher: "OperatorSDK QE",
sourceType: "grpc",
address: "quay.io/olmqe/upgradeindex-index:v0.1",
interval: "15m",
template: catsrcImageTemplate,
}
subsqlite = subscriptionDescription{
subName: "upgradesqlite-index-50141",
namespace: oc.Namespace(),
catalogSourceName: catsrcsqlite.name,
catalogSourceNamespace: oc.Namespace(),
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "upgradeindex",
startingCSV: "upgradeindex.v0.0.1",
template: subTemplate,
}
)
dr.addIr(itName)
exutil.By("Install the OperatorGroup")
og.createwithCheck(oc, itName, dr)
exutil.By("Create catalog source")
catsrcfbc.createWithCheck(oc, itName, dr)
exutil.By("Install operator through OLM and the index iamge is kind of FBC")
subfbc.create(oc, itName, dr)
exutil.By("Check Operator is Succeeded")
newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", subfbc.installedCSV, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc)
exutil.By("Run bundle-upgrade operator")
output, err := operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradefbc-bundle:v0.0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradefbc.v0.0.2", "-n", oc.Namespace()).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 0.0.2 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradefbc upgrade failed in %s ", oc.Namespace()))
exutil.By("Create catalog source")
catsrcsqlite.createWithCheck(oc, itName, dr)
exutil.By("Install operator through OLM and the index iamge is kind of SQLITE")
subsqlite.createWithoutCheck(oc, itName, dr)
exutil.By("Check Operator is Succeeded")
subsqlite.findInstalledCSV(oc, itName, dr)
newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", subsqlite.installedCSV, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc)
exutil.By("Run bundle-upgrade operator")
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradeindex.v0.0.2", "-n", oc.Namespace()).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 0.0.2 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradeindex upgrade failed in %s ", oc.Namespace()))
})
// author: [email protected]
g.It("VMonly-DisconnectedOnly-Author:jitli-High-52571-Disconnected test for ansible type operator", func() {
exutil.SkipOnProxyCluster(oc)
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-48885-data")
tmpBasePath = "/tmp/ocp-52571-" + getRandomString()
tmpPath = filepath.Join(tmpBasePath, "memcached-operator-52571")
imageTag = "quay.io/olmqe/memcached-operator:52571-" + getRandomString()
quayCLI = container.NewQuayCLI()
bundleImage = "quay.io/olmqe/memcached-operator-bundle:52571-" + getRandomString()
)
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain=disconnected.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group=test", "--version=v1", "--kind", "Memcached52571", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy task main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "memcached52571", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the Dockerfile
dockerFile := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
replaceContent(dockerFile, "install -r ${HOME}/requirements.yml", "install -r ${HOME}/requirements.yml --force")
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-52571" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)")
// copy manifests
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52571.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "memcached-operator-52571.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: make bundle use image digests")
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52571.clusterserviceversion.yaml")
content := getContent(csvFile)
if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") {
e2e.Failf("Fail to get the image info with digest type")
}
exutil.By("step: build and push bundle image.")
defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1))
_, err = makeCLI.Run("bundle-build").Args("BUNDLE_IMG=" + bundleImage).Output()
o.Expect(err).NotTo(o.HaveOccurred())
podmanCLI := container.NewPodmanCLI()
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
output, _ = podmanCLI.Run("push").Args(bundleImage).Output()
if strings.Contains(output, "Writing manifest to image destination") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.")
exutil.By("step: create new project")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: get digestID")
bundleImageDigest, err := quayCLI.GetImageDigest(strings.Replace(bundleImage, "quay.io/", "", 1))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(bundleImageDigest).NotTo(o.BeEmpty())
indexImage := "quay.io/olmqe/nginxolm-operator-index:v1"
indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(indexImage, "quay.io/", "", 1))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(indexImageDigest).NotTo(o.BeEmpty())
exutil.By("step: run bundle")
defer func() {
output, err = operatorsdkCLI.Run("cleanup").Args("memcached-operator-52571", "-n", ns).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/memcached-operator-bundle@"+bundleImageDigest, "--index-image", "quay.io/olmqe/nginxolm-operator-index@"+indexImageDigest, "-n", ns, "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox@sha256:e39d9c8ac4963d0b00a5af08678757b44c35ea8eb6be0cdfbeb1282e7f7e6003").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-52571-controller-manager") {
e2e.Logf("found pod memcached-operator-52571-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-52571-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-52571-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "pod", "csv", "catsrc")
}
output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pods", "-o=jsonpath={.items[*].spec.containers[*].image}", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/memcached-operator@sha256:"))
exutil.By("step: Create CR")
err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:memcached52571-sample-nginx", ns)).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
crFilePath := filepath.Join(dataPath, "memcached-sample.yaml")
defer func() {
exutil.By("step: delete cr.")
_, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached52571-sample") {
e2e.Logf("found pod memcached52571-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached52571-sample is Running")
return true, nil
}
e2e.Logf("the status of pod memcached52571-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "Memcached52571", "pod", "events")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52571-sample in project %s or the pod is not running", ns))
})
// author: [email protected]
g.It("VMonly-DisconnectedOnly-Author:jitli-High-52572-Disconnected test for helm type operator", func() {
exutil.SkipOnProxyCluster(oc)
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-52813-data")
tmpBasePath = "/tmp/ocp-52572-" + getRandomString()
tmpPath = filepath.Join(tmpBasePath, "memcached-operator-52572")
imageTag = "quay.io/olmqe/memcached-operator:52572-" + getRandomString()
quayCLI = container.NewQuayCLI()
bundleImage = "quay.io/olmqe/memcached-operator-bundle:52572-" + getRandomString()
)
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
exutil.By("step: init Helm Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=helm", "--domain=disconnected.com", "--group=test", "--version=v1", "--kind=Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Created helm-charts"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy watches.yaml
err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy helm-charts/nginx/values.yaml
err = copy(filepath.Join(dataPath, "values.yaml"), filepath.Join(tmpPath, "helm-charts", "nginx", "values.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the file helm-charts/nginx/templates/deployment.yaml
deployFilepath := filepath.Join(tmpPath, "helm-charts", "nginx", "templates", "deployment.yaml")
replaceContent(deployFilepath, ".Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion", ".Values.relatedImage")
// update the Dockerfile
dockerFile := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion)
// copy the manager
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-52572" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
replaceContent(makefileFilePath, "operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)", "operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)")
exutil.By("step: make bundle.")
// copy manifests
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52572.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "memcached-operator-52572.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
// make bundle use image digests
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52572.clusterserviceversion.yaml")
content := getContent(csvFile)
if !strings.Contains(content, "quay.io/olmqe/nginx@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") {
e2e.Failf("Fail to get the image info with digest type")
}
exutil.By("step: build and push bundle image.")
defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1))
_, err = makeCLI.Run("bundle-build").Args("BUNDLE_IMG=" + bundleImage).Output()
o.Expect(err).NotTo(o.HaveOccurred())
podmanCLI := container.NewPodmanCLI()
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
output, _ = podmanCLI.Run("push").Args(bundleImage).Output()
if strings.Contains(output, "Writing manifest to image destination") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.")
exutil.By("step: create new project")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: get digestID")
bundleImageDigest, err := quayCLI.GetImageDigest(strings.Replace(bundleImage, "quay.io/", "", 1))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(bundleImageDigest).NotTo(o.BeEmpty())
indexImage := "quay.io/olmqe/nginxolm-operator-index:v1"
indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(indexImage, "quay.io/", "", 1))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(indexImageDigest).NotTo(o.BeEmpty())
exutil.By("step: run bundle")
defer func() {
output, err = operatorsdkCLI.Run("cleanup").Args("memcached-operator-52572", "-n", ns).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/memcached-operator-bundle@"+bundleImageDigest, "--index-image", "quay.io/olmqe/nginxolm-operator-index@"+indexImageDigest, "-n", ns, "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox@sha256:e39d9c8ac4963d0b00a5af08678757b44c35ea8eb6be0cdfbeb1282e7f7e6003").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-52572-controller-manager") {
e2e.Logf("found pod memcached-operator-52572-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-52572-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-52572-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "pod", "csv", "catsrc")
}
output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pods", "-o=jsonpath={.items[*].spec.containers[*].image}", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/memcached-operator@sha256:"))
exutil.By("step: Create CR")
err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:memcached52572-sample-nginx", ns)).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
crFilePath := filepath.Join(dataPath, "memcached-sample.yaml")
defer func() {
exutil.By("step: delete cr.")
_, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached52572-sample") {
e2e.Logf("found pod memcached52572-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached52572-sample is Running")
return true, nil
}
e2e.Logf("the status of pod memcached52572-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "Memcached52572", "pod", "events")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52572-sample in project %s or the pod is not running", ns))
})
// author: [email protected]
g.It("VMonly-DisconnectedOnly-Author:jitli-High-52305-Disconnected test for go type operator [Slow]", func() {
exutil.SkipOnProxyCluster(oc)
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-52814-data")
tmpBasePath = "/tmp/ocp-52305-" + getRandomString()
tmpPath = filepath.Join(tmpBasePath, "memcached-operator-52814")
imageTag = "quay.io/olmqe/memcached-operator:52305-" + getRandomString()
quayCLI = container.NewQuayCLI()
bundleImage = "quay.io/olmqe/memcached-operator-bundle:52305-" + getRandomString()
)
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
exutil.By("step: init Go Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--domain=disconnected.com", "--repo=github.com/example-inc/memcached-operator").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: create api")
output, err = operatorsdkCLI.Run("create").Args("api", "--group=test", "--version=v1", "--kind=Memcached52814", "--controller", "--resource").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("make manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy api/v1/memcached52814_types.go
err = copy(filepath.Join(dataPath, "memcached52814_types.go"), filepath.Join(tmpPath, "api", "v1", "memcached52814_types.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy internal/controller/memcached52814_controller.go
err = copy(filepath.Join(dataPath, "memcached52814_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcached52814_controller.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy the manager
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
// update the Dockerfile
dockerfileFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerfileFilePath, "golang", "quay.io/olmqe/golang")
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-52305" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
exutil.By("step: Install kustomize")
kustomizePath := "/root/kustomize"
binPath := filepath.Join(tmpPath, "bin")
exec.Command("bash", "-c", fmt.Sprintf("cp %s %s", kustomizePath, binPath)).Output()
exutil.By("step: make bundle.")
// copy manifests
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-52814.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "memcached-operator-52814.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
// make bundle use image digests
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args("USE_IMAGE_DIGESTS=true").Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
csvFile := filepath.Join(tmpPath, "bundle", "manifests", "memcached-operator-52814.clusterserviceversion.yaml")
content := getContent(csvFile)
if !strings.Contains(content, "quay.io/olmqe/memcached@sha256:") || !strings.Contains(content, "quay.io/olmqe/memcached-operator@sha256:") {
e2e.Failf("Fail to get the image info with digest type")
}
exutil.By("step: build and push bundle image.")
defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1))
_, err = makeCLI.Run("bundle-build").Args("BUNDLE_IMG=" + bundleImage).Output()
o.Expect(err).NotTo(o.HaveOccurred())
podmanCLI := container.NewPodmanCLI()
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
output, _ = podmanCLI.Run("push").Args(bundleImage).Output()
if strings.Contains(output, "Writing manifest to image destination") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "Podman push bundle image failed.")
exutil.By("step: create new project")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: get digestID")
bundleImageDigest, err := quayCLI.GetImageDigest(strings.Replace(bundleImage, "quay.io/", "", 1))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(bundleImageDigest).NotTo(o.BeEmpty())
indexImage := "quay.io/olmqe/nginxolm-operator-index:v1"
indexImageDigest, err := quayCLI.GetImageDigest(strings.Replace(indexImage, "quay.io/", "", 1))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(indexImageDigest).NotTo(o.BeEmpty())
exutil.By("step: run bundle")
defer func() {
output, err = operatorsdkCLI.Run("cleanup").Args("memcached-operator-52814", "-n", ns).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/memcached-operator-bundle@"+bundleImageDigest, "--index-image", "quay.io/olmqe/nginxolm-operator-index@"+indexImageDigest, "-n", ns, "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox@sha256:e39d9c8ac4963d0b00a5af08678757b44c35ea8eb6be0cdfbeb1282e7f7e6003").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-52814-controller-manager") {
e2e.Logf("found pod memcached-operator-52814-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-52814-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-52814-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "pod", "csv", "catsrc")
}
output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pods", "-o=jsonpath={.items[*].spec.containers[*].image}", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/memcached-operator@sha256:"))
exutil.By("step: Create CR")
err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:memcached52305-sample", ns)).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
crFilePath := filepath.Join(dataPath, "memcached-sample.yaml")
defer func() {
exutil.By("step: delete cr.")
_, err := oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached52305-sample") {
e2e.Logf("found pod memcached52305-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached52305-sample is Running")
return true, nil
}
e2e.Logf("the status of pod memcached52305-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, ns, "Memcached52814", "pod", "events")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached52305-sample in project %s or the pod is not running", ns))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-45141-High-41497-High-34292-High-29374-High-28157-High-27977-ansible k8sevent k8sstatus maxConcurrentReconciles modules to a collect blacklist [Slow]", func() {
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
// test data
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-27977-data")
crFilePath := filepath.Join(dataPath, "ansiblebase_v1_basetest.yaml")
// exec dir
tmpBasePath := "/tmp/ocp-27977-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "ansibletest")
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
// exec ns & image tag
nsOperator := "ansibletest-system"
imageTag := "quay.io/olmqe/ansibletest:" + ocpversion + "-" + getRandomString()
// cleanup the test data
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "qetest.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "ansiblebase", "--version", "v1", "--kind", "Basetest", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy task main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "basetest", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy Dockerfile
dockerfileFilePath := filepath.Join(dataPath, "Dockerfile")
err = copy(dockerfileFilePath, filepath.Join(tmpPath, "Dockerfile"))
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
// copy manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-27977" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("basetests.ansiblebase.qetest.com"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/ansibletest-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "ansibletest-controller-manager") {
e2e.Logf("found pod ansibletest-controller-manager")
if strings.Contains(line, "2/2") {
e2e.Logf("the status of pod ansibletest-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod ansibletest-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No ansibletest-controller-manager in project %s", nsOperator))
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/ansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(msg, "Starting workers") {
e2e.Failf("Starting workers failed")
}
// OCP-34292
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deploy/ansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output()
if strings.Contains(msg, "\"worker count\":1") {
e2e.Logf("found worker count:1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/ansibletest-controller-manager of %s doesn't have worker count:4", nsOperator))
// add the admin policy
err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "cluster-admin", "system:serviceaccount:"+nsOperator+":ansibletest-controller-manager").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "basetest-sample") {
e2e.Logf("found pod basetest-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No basetest-sample in project %s", nsOperator))
// OCP-27977
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/basetest-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "2 desired | 2 updated | 2 total | 2 available | 0 unavailable") {
e2e.Logf("deployment/basetest-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events")
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/basetest-sample is wrong")
// OCP-45141
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("event", "-n", nsOperator).Output()
if strings.Contains(msg, "test-reason") {
e2e.Logf("k8s_event test")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get k8s event test-name in %s", nsOperator))
// OCP-41497
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("basetest.ansiblebase.qetest.com/basetest-sample", "-n", nsOperator, "-o", "yaml").Output()
if strings.Contains(msg, "hello world") {
e2e.Logf("k8s_status test hello world")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get basetest-sample hello world in %s", nsOperator))
// OCP-29374
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("secret", "-n", nsOperator).Output()
if strings.Contains(msg, "test-secret") {
e2e.Logf("found secret test-secret")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("doesn't get secret test-secret %s", nsOperator))
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("secret", "test-secret", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("test: 6 bytes"))
// OCP-28157
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("describe").Args("configmap", "test-blacklist-watches", "-n", nsOperator).Output()
if strings.Contains(msg, "afdasdfsajsafj") {
e2e.Logf("Skipping the blacklist")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/ansibletest-controller-manager of %s doesn't work the blacklist", nsOperator))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-28586-ansible Content Collections Support in watches.yaml", func() {
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
// test data
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-28586-data")
crFilePath := filepath.Join(dataPath, "cache5_v1_collectiontest.yaml")
// exec dir
tmpBasePath := "/tmp/ocp-28586-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "contentcollections")
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
// exec ns & image tag
nsOperator := "contentcollections-system"
imageTag := "quay.io/olmqe/contentcollections:" + ocpversion + "-" + getRandomString()
// cleanup the test data
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "cotentcollect.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache5", "--version", "v1", "--kind", "CollectionTest", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// mkdir fixture_collection
collectionFilePath := filepath.Join(tmpPath, "fixture_collection", "roles", "dummy", "tasks")
err = os.MkdirAll(collectionFilePath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
// copy galaxy.yml & main.yml
err = copy(filepath.Join(dataPath, "galaxy.yml"), filepath.Join(tmpPath, "fixture_collection", "galaxy.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(collectionFilePath, "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy Dockerfile
dockerfileFilePath := filepath.Join(dataPath, "Dockerfile")
err = copy(dockerfileFilePath, filepath.Join(tmpPath, "Dockerfile"))
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
// copy the watches.yaml
err = copy(filepath.Join(dataPath, "watches.yaml"), filepath.Join(tmpPath, "watches.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-28586" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("collectiontests.cache5.cotentcollect.com"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(output).To(o.ContainSubstring("deployment.apps/contentcollections-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 240*time.Second, false, func(ctx context.Context) (bool, error) {
podMsg, _ := oc.AsAdmin().WithoutNamespace().Run("describe").Args("pods", "-n", nsOperator).Output()
if !strings.Contains(podMsg, "Started container manager") {
e2e.Logf("Started container manager failed")
logDebugInfo(oc, nsOperator, "events", "pod")
return false, nil
}
return true, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 240*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/contentcollections-controller-manager", "-c", "manager", "-n", nsOperator).Output()
if !strings.Contains(msg, "Starting workers") {
e2e.Logf("Starting workers failed")
return false, nil
}
return true, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No contentcollections-controller-manager in project %s", nsOperator))
exutil.By("step: Create the resource")
msg, err := oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(msg, "collectiontest-sample created") {
e2e.Failf("collectiontest-sample created failed")
}
// check the dummy task
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deploy/contentcollections-controller-manager", "-c", "manager", "-n", nsOperator).Output()
if strings.Contains(msg, "dummy : Create ConfigMap") {
e2e.Logf("found dummy : Create ConfigMap")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("miss log dummy : Create ConfigMap in %s", nsOperator))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-High-48366-add ansible prometheus metrics", func() {
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
// test data
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-48366-data")
crFilePath := filepath.Join(dataPath, "metrics_v1_testmetrics.yaml")
// exec dir
tmpBasePath := "/tmp/ocp-48366-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "ansiblemetrics")
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
// exec ns & image tag
nsOperator := "ansiblemetrics-system"
imageTag := "quay.io/olmqe/testmetrics:" + ocpversion + "-" + getRandomString()
// cleanup the test data
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible metrics Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "testmetrics.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "metrics", "--version", "v1", "--kind", "Testmetrics", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy Dockerfile
dockerfileFilePath := filepath.Join(tmpPath, "Dockerfile")
err = copy(filepath.Join(dataPath, "Dockerfile"), dockerfileFilePath)
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(dockerfileFilePath, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
// copy the roles/testmetrics/tasks/main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "testmetrics", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-48366" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("metrics"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(output).To(o.ContainSubstring("deployment.apps/ansiblemetrics-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "ansiblemetrics-controller-manager") {
if strings.Contains(line, "2/2") {
e2e.Logf("the status of pod ansiblemetrics-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod ansiblemetrics-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/ansiblemetrics-controller-manager", "-c", "manager", "-n", nsOperator).Output()
if !strings.Contains(msg, "Starting workers") {
e2e.Logf("Starting workers failed")
return false, nil
}
return true, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No ansiblemetrics-controller-manager in project %s", nsOperator))
exutil.By("step: Create the resource")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", crFilePath, "-n", nsOperator).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
if strings.Contains(msg, "metrics-sample") {
e2e.Logf("metrics created success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get metrics samples in %s", nsOperator))
metricsToken, _ := exutil.GetSAToken(oc)
o.Expect(metricsToken).NotTo(o.BeEmpty())
promeEp, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("ep", "ansiblemetrics-controller-manager-metrics-service", "-o=jsonpath={.subsets[0].addresses[0].ip}", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
metricsMsg, err := exec.Command("bash", "-c", "oc exec deployment/ansiblemetrics-controller-manager -n "+nsOperator+" -- curl -k -H \"Authorization: Bearer "+metricsToken+"\" 'https://["+promeEp+"]:8443/metrics'").Output()
//Depending on the environment, the IP address may sometimes switch between ipv4 and ipv6.
if err != nil {
metricsMsg, err = exec.Command("bash", "-c", "oc exec deployment/ansiblemetrics-controller-manager -n "+nsOperator+" -- curl -k -H \"Authorization: Bearer "+metricsToken+"\" 'https://"+promeEp+":8443/metrics'").Output()
o.Expect(err).NotTo(o.HaveOccurred())
}
var strMetricsMsg string
strMetricsMsg = string(metricsMsg)
if !strings.Contains(strMetricsMsg, "my gague and set it to 2") {
e2e.Logf("%s", strMetricsMsg)
e2e.Failf("my gague and set it to 2 failed")
}
if !strings.Contains(strMetricsMsg, "counter") {
e2e.Logf("%s", strMetricsMsg)
e2e.Failf("counter failed")
}
if !strings.Contains(strMetricsMsg, "Observe my histogram") {
e2e.Logf("%s", strMetricsMsg)
e2e.Failf("Observe my histogram failed")
}
if !strings.Contains(strMetricsMsg, "Observe my summary") {
e2e.Logf("%s", strMetricsMsg)
e2e.Failf("Observe my summary failed")
}
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-48359-SDK init plugin about hybird helm operator [Slow]", func() {
g.Skip("OperatorSDK Hybrid Helm plugin unavailable and no plan to fix it, so skip it")
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
tmpBasePath := "/tmp/ocp-48359-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-48359")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
nsOperator := "memcached-operator-48359-system"
imageTag := "quay.io/olmqe/memcached-operator:48359-" + getRandomString()
dataPath := "test/extended/testdata/operatorsdk/ocp-48359-data/"
crFilePath := filepath.Join(dataPath, "cache6_v1_memcachedbackup.yaml")
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Helm Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=hybrid.helm.sdk.operatorframework.io", "--domain=hybird.com", "--project-version=3", "--repo=github.com/example/memcached-operator").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("go mod tidy"))
exutil.By("step: create the apis")
// Create helm api
output, err = operatorsdkCLI.Run("create").Args("api", "--plugins=helm.sdk.operatorframework.io/v1", "--group=cache6", "--version=v1", "--kind=Memcached").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Created helm-charts"))
// Create go api
output, err = operatorsdkCLI.Run("create").Args("api", "--group=cache6", "--version=v1", "--kind=MemcachedBackup", "--resource", "--controller", "--plugins=go/v4").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("make manifests"))
exutil.By("step: modify files to generate the operator image.")
// update the Dockerfile
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "golang:", "quay.io/olmqe/golang:")
replaceContent(dockerFilePath, "COPY controllers/ controllers/", "COPY internal/controller/ internal/controller/")
replaceContent(dockerFilePath, "RUN GOOS=linux GOARCH=amd64 go build -a -o manager cmd/main.go", "RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go")
// update the Makefile
makefileFilePath := filepath.Join(tmpPath, "Makefile")
replaceContent(makefileFilePath, "controller:latest", imageTag)
// copy memcachedbackup_types.go
err = copy(filepath.Join(dataPath, "memcachedbackup_types.go"), filepath.Join(tmpPath, "api", "v1", "memcachedbackup_types.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy memcachedbackup_controller.go ./controllers/memcachedbackup_controller.go
err = copy(filepath.Join(dataPath, "memcachedbackup_controller.go"), filepath.Join(tmpPath, "internal", "controller", "memcachedbackup_controller.go"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy kubmize
exutil.By("step: Install kustomize")
kustomizePath := "/root/kustomize"
binPath := filepath.Join(tmpPath, "bin", "kustomize")
err = copy(filepath.Join(kustomizePath), filepath.Join(binPath))
o.Expect(err).NotTo(o.HaveOccurred())
// chmod 644 watches.yaml
err = os.Chmod(filepath.Join(tmpPath, "watches.yaml"), 0o644)
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-48359" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-48359-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-48359-controller-manager") {
e2e.Logf("found pod memcached-operator-48359-controller-manager")
if strings.Contains(line, "2/2") {
e2e.Logf("the status of pod memcached-operator-48359-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-48359-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No memcached-operator-48359-controller-manager in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-48359-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "Starting workers") {
e2e.Logf("Starting workers successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "container manager doesn't work")
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "memcachedbackup-sample") {
e2e.Logf("found pod memcachedbackup-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("hybird test: No memcachedbackup-sample in project %s", nsOperator))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-High-40964-migrate packagemanifest to bundle", func() {
exutil.SkipOnProxyCluster(oc)
architecture.SkipNonAmd64SingleArch(oc)
var (
tmpBasePath = "/tmp/ocp-40964-" + getRandomString()
pacakagemanifestsPath = exutil.FixturePath("testdata", "operatorsdk", "ocp-40964-data", "manifests", "etcd")
quayCLI = container.NewQuayCLI()
containerCLI = container.NewPodmanCLI()
bundleImage = "quay.io/olmqe/etcd-operatorsdk:0.9.4"
bundleImageTag = "quay.io/olmqe/etcd-operatorsdk:0.9.4-" + getRandomString()
)
oc.SetupProject()
operatorsdkCLI.showInfo = true
defer os.RemoveAll(tmpBasePath)
err := os.MkdirAll(tmpBasePath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
operatorsdkCLI.ExecCommandPath = tmpBasePath
exutil.By("transfer the packagemanifest to bundle dir")
output, err := operatorsdkCLI.Run("pkgman-to-bundle").Args(pacakagemanifestsPath, "--output-dir=test-40964-bundle").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Bundle metadata generated successfully"))
bundleDir := filepath.Join(tmpBasePath, "test-40964-bundle", "bundle-0.9.4", "bundle")
if _, err := os.Stat(bundleDir); os.IsNotExist(err) {
e2e.Failf("bundle dir not found")
}
exutil.By("generate the bundle image")
output, err = operatorsdkCLI.Run("pkgman-to-bundle").Args(pacakagemanifestsPath, "--image-tag-base", "quay.io/olmqe/etcd-operatorsdk", "--output-dir=test-40964-bundle-image").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully built image quay.io/olmqe/etcd-operatorsdk:0.9.4"))
exutil.By("run the generated bundle")
defer quayCLI.DeleteTag(strings.Replace(bundleImageTag, "quay.io/", "", 1))
defer containerCLI.RemoveImage(bundleImage)
if output, err := containerCLI.Run("tag").Args(bundleImage, bundleImageTag).Output(); err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
if output, err = containerCLI.Run("push").Args(bundleImageTag).Output(); err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
defer func() {
output, err := operatorsdkCLI.Run("cleanup").Args("etcd", "-n", oc.Namespace()).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, _ = operatorsdkCLI.Run("run").Args("bundle", bundleImageTag, "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
})
// author: [email protected]
g.It("VMonly-Author:jitli-Critical-49884-Add support for external bundle validators", func() {
tmpPath := "/tmp/ocp-49884-" + getRandomString()
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpPath)
tmpBasePath := exutil.FixturePath("testdata", "operatorsdk", "ocp-49960-data")
exutil.By("Get the external bundle validator from container image")
podmanCLI := container.NewPodmanCLI()
podmanCLI.ExecCommandPath = tmpPath
podmanOutput, err := podmanCLI.Run("run").Args("--rm", "-v", tmpPath+":/tmp:z", "quay.io/openshifttest/validator-poc:v1", "cp", "/opt/validator-poc", "/tmp/validator-poc").Output()
if err != nil {
e2e.Logf(string(podmanOutput))
e2e.Failf("Fail to get the validator-poc from container image %v", err)
}
exvalidator := filepath.Join(tmpPath, "validator-poc")
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) {
if _, err := os.Stat(exvalidator); os.IsNotExist(err) {
e2e.Logf("get validator-poc Failed")
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(waitErr, "get validator-poc Failed")
err = os.Chmod(exvalidator, os.FileMode(0o755))
o.Expect(err).NotTo(o.HaveOccurred())
updatedFileInfo, err := os.Stat(exvalidator)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(updatedFileInfo.Mode().Perm()).To(o.Equal(os.FileMode(0o755)), "File permissions not set correctly")
exutil.By("bundle validate with external validater")
output, _ := operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--alpha-select-external", exvalidator).Output()
o.Expect(output).To(o.ContainSubstring("csv.Spec.Icon elements should contain both data and mediatype"))
exutil.By("bundle validate with 2 external validater")
output, _ = operatorsdkCLI.Run("bundle").Args("validate", tmpBasePath+"/bundle", "--alpha-select-external", exvalidator+":"+exvalidator).Output()
o.Expect(output).To(o.ContainSubstring("csv.Spec.Icon elements should contain both data and mediatype"))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-Critical-59885-Run bundle on different security level namespaces [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
defer func() {
output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
exutil.By("Run bundle without options --security-context-config=restricted")
output, _ := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m").Output()
if strings.Contains(output, "violates PodSecurity") {
e2e.Logf("violates PodSecurity, need add label to decrease namespace safety factor")
output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
exutil.By("Add label to decrease namespace safety factor")
_, err = oc.AsAdmin().WithoutNamespace().Run("label").Args("ns", oc.Namespace(), "security.openshift.io/scc.podSecurityLabelSync=false", "pod-security.kubernetes.io/enforce=privileged", "pod-security.kubernetes.io/audit=privileged", "pod-security.kubernetes.io/warn=privileged", "--overwrite").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Run bundle without options --security-context-config=restricted again")
output, _ = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
} else {
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
}
})
// author: [email protected]
g.It("ConnectedOnly-VMonly-Author:jitli-High-69005-helm operator recoilne the different namespaces", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/nginx-operator-base:v" + ocpversion + "-69005" + getRandomString()
nsSystem := "system-69005-" + getRandomString()
nsOperator := "nginx-operator-69005-system"
tmpBasePath := "/tmp/ocp-69005-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "nginx-operator-69005")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer func() {
quayCLI := container.NewQuayCLI()
quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}()
exutil.By("init Helm Based Operators")
output, err := operatorsdkCLI.Run("init").Args("--plugins=helm").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next: define a resource with"))
exutil.By("Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "demo", "--version", "v1", "--kind", "Nginx69005").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("nginx"))
if !upstream {
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-helm-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion)
}
exutil.By("modify namespace")
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: nginx-operator-69005-system/namespace: %s/g' `grep -rl \"namespace: nginx-operator-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("build and Push the operator image")
tokenDir := "/tmp/ocp-69005" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
defer func() {
exutil.By("run make undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("Edit manager.yaml to add the multiple namespaces")
managerFilePath := filepath.Join(tmpPath, "config", "manager", "manager.yaml")
replaceContent(managerFilePath, "name: manager", "name: manager\n env:\n - name: \"WATCH_NAMESPACE\"\n value: default,nginx-operator-69005-system")
exutil.By("Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/nginx-operator-69005-controller-manager created"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "nginx-operator-69005-controller-manager") {
e2e.Logf("found pod nginx-operator-69005-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod nginx-operator-69005-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod nginx-operator-69005-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if err != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No nginx-operator-69005-controller-manager")
exutil.By("Check the namespaces watching")
podName, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator, "-o=jsonpath={.items..metadata.name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podName).NotTo(o.BeEmpty())
podLogs, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args(podName, "-n", nsOperator, "--limit-bytes", "50000").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podLogs).To(o.ContainSubstring(`"msg":"Watching namespaces","namespaces":["default","nginx-operator-69005-system"]`))
exutil.By("run make undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Edit manager.yaml to add the single namespaces")
managerFilePath = filepath.Join(tmpPath, "config", "manager", "manager.yaml")
replaceContent(managerFilePath, "default,nginx-operator-69005-system", "nginx-operator-69005-system")
exutil.By("Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/nginx-operator-69005-controller-manager created"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "nginx-operator-69005-controller-manager") {
e2e.Logf("found pod nginx-operator-69005-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod nginx-operator-69005-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod nginx-operator-69005-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if err != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No nginx-operator-69005-controller-manager")
exutil.By("Check the namespaces watching")
podName, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator, "-o=jsonpath={.items..metadata.name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podName).NotTo(o.BeEmpty())
podLogs, err = oc.AsAdmin().WithoutNamespace().Run("logs").Args(podName, "-n", nsOperator, "--limit-bytes", "50000").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podLogs).To(o.ContainSubstring(`"msg":"Watching namespaces","namespaces":["nginx-operator-69005-system"]`))
})
// author: [email protected]
g.It("VMonly-ConnectedOnly-Author:jitli-Medium-69118-Run bundle init image choosable [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
defer func() {
output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
exutil.By("Run bundle")
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Check the default init image")
output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pod", "quay-io-olmqe-upgradeoperator-bundle-v0-1", "-o=jsonpath={.spec.initContainers[*].image}", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("registry.access.redhat.com/ubi9/ubi:9.4"))
output, err = operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
exutil.By("Customize the initialization image to run the bundle")
output, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted", "--decompression-image", "quay.io/olmqe/busybox:latest").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("Check the custom init image")
output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("pod", "quay-io-olmqe-upgradeoperator-bundle-v0-1", "-o=jsonpath={.spec.initContainers[*].image}", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/busybox:latest"))
})
})
|
package operatorsdk
| ||||
test case
|
openshift/openshift-tests-private
|
c07ee9eb-ffc1-468b-8e25-ac3ca526c473
|
VMonly-Author:jfan-High-37465-SDK olm improve olm related sub commands
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-Author:jfan-High-37465-SDK olm improve olm related sub commands", func() {
operatorsdkCLI.showInfo = true
exutil.By("check the olm status")
output, _ := operatorsdkCLI.Run("olm").Args("status", "--olm-namespace", "openshift-operator-lifecycle-manager").Output()
o.Expect(output).To(o.ContainSubstring("Fetching CRDs for version"))
})
| ||||||
test case
|
openshift/openshift-tests-private
|
186e3912-9f60-434f-8240-6796ef1b1e15
|
Author:jfan-High-37312-SDK olm improve manage operator bundles in new manifests metadata format
|
['"os"', '"os/exec"', '"path/filepath"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jfan-High-37312-SDK olm improve manage operator bundles in new manifests metadata format", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-37312-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-37312")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins", "ansible", "--domain", "example.com", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-playbook").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Bundle manifests generate")
result, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk generate bundle --deploy-dir=config --crds-dir=config/crds --version=0.0.1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Bundle manifests generated successfully in bundle"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
40378419-fb1c-4037-9e15-7368067cd673
|
Author:jfan-High-37141-SDK Helm support simple structural schema generation for Helm CRDs
|
['"os"', '"path/filepath"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jfan-High-37141-SDK Helm support simple structural schema generation for Helm CRDs", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-37141-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "nginx-operator-37141")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--project-name", "nginx-operator", "--plugins", "helm.sdk.operatorframework.io/v1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
result, err := operatorsdkCLI.Run("create").Args("api", "--group", "apps", "--version", "v1beta1", "--kind", "Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Created helm-charts/nginx"))
annotationsFile := filepath.Join(tmpPath, "config", "crd", "bases", "apps.my.domain_nginxes.yaml")
content := getContent(annotationsFile)
o.Expect(content).To(o.ContainSubstring("x-kubernetes-preserve-unknown-fields: true"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
f4ba154a-2cbb-4d19-81dc-0d127195b580
|
Author:jfan-High-37311-SDK ansible valid structural schemas for ansible based operators
|
['"os"', '"path/filepath"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jfan-High-37311-SDK ansible valid structural schemas for ansible based operators", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-37311-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "ansible-operator-37311")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--project-name", "nginx-operator", "--plugins", "ansible.sdk.operatorframework.io/v1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "apps", "--version", "v1beta1", "--kind", "Nginx").Output()
o.Expect(err).NotTo(o.HaveOccurred())
annotationsFile := filepath.Join(tmpPath, "config", "crd", "bases", "apps.my.domain_nginxes.yaml")
content := getContent(annotationsFile)
o.Expect(content).To(o.ContainSubstring("x-kubernetes-preserve-unknown-fields: true"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
a6a4793a-bb5f-4062-ae3e-1083aeff541e
|
VMonly-ConnectedOnly-Author:jfan-High-37627-SDK run bundle upgrade test [Serial]
|
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-High-37627-SDK run bundle upgrade test [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
defer func() {
output, err := operatorsdkCLI.Run("cleanup").Args("upgradeoperator", "-n", oc.Namespace()).Output()
if err != nil {
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
}
}()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/upgradeoperator-bundle:v0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeoperator-bundle:v0.2", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradeoperator.v0.0.2", "-n", oc.Namespace()).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 0.2 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradeoperator upgrade failed in %s ", oc.Namespace()))
})
| |||||
test case
|
openshift/openshift-tests-private
|
a7a2019d-fc07-4273-9e0b-15beeb197dbe
|
VMonly-ConnectedOnly-Author:jfan-Medium-38054-SDK run bundle create pods and csv and registry image pod [Serial]
|
['"context"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-38054-SDK run bundle create pods and csv and registry image pod [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/podcsvcheck-bundle:v0.0.1", "-n", oc.Namespace(), "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", oc.Namespace()).Output()
o.Expect(output).To(o.ContainSubstring("quay-io-olmqe-podcsvcheck-bundle-v0-0-1"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "podcsvcheck.v0.0.1", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Succeeded"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "podcsvcheck-catalog", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("grpc"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("installplan", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("podcsvcheck.v0.0.1"))
output, err = operatorsdkCLI.Run("cleanup").Args("podcsvcheck", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
e39a387d-2ed3-45e9-b993-28651e980c31
|
ConnectedOnly-Author:jfan-High-38060-SDK run bundle detail message about failed
|
['"context"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("ConnectedOnly-Author:jfan-High-38060-SDK run bundle detail message about failed", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
output, _ := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/etcd-bundle:0.0.1", "-n", oc.Namespace(), "--security-context-config=restricted").Output()
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/etcd-bundle:0.0.1: not found"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
1fe236c5-6853-4aaa-8466-fd5f1ec5d2b4
|
Author:jfan-LEVEL0-High-34441-SDK commad operator sdk support init help message
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jfan-LEVEL0-High-34441-SDK commad operator sdk support init help message", func() {
output, err := operatorsdkCLI.Run("init").Args("--help").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("--project-name"))
})
| ||||||
test case
|
openshift/openshift-tests-private
|
17c80a59-d3be-4ab7-b655-fd0bf02d55e3
|
Author:jfan-Medium-40521-SDK olm improve manage operator bundles in new manifests metadata format
|
['"os"', '"os/exec"', '"path/filepath"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jfan-Medium-40521-SDK olm improve manage operator bundles in new manifests metadata format", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-40521-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-40521")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins", "ansible.sdk.operatorframework.io/v1", "--domain", "example.com", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-playbook").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Bundle manifests generate")
result, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk generate bundle --deploy-dir=config --crds-dir=config/crds --version=0.0.1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Bundle manifests generated successfully in bundle"))
exec.Command("bash", "-c", "cd "+tmpPath+" && sed -i '/icon/,+2d' ./bundle/manifests/memcached-operator-40521.clusterserviceversion.yaml").Output()
msg, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk bundle validate ./bundle &> ./validateresult && cat validateresult").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("All validation tests have completed successfully"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
e99df89a-aa62-463f-99d1-6a87afd05147
|
VMonly-ConnectedOnly-Author:jfan-Medium-40520-SDK k8sutil 1123Label creates invalid values
|
['"context"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-40520-SDK k8sutil 1123Label creates invalid values", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
msg, _ := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/raffaelespazzoli-proactive-node-scaling-operator-bundle:latest-", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(msg).To(o.ContainSubstring("reated registry pod: raffaelespazzoli-proactive-node-scaling-operator-bundle-latest"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
a75a8f8a-d3cf-4e99-b667-e54c96d7a1d4
|
VMonly-ConnectedOnly-Author:jfan-Medium-35443-SDK run bundle InstallMode for own namespace [Slow] [Serial]
|
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-35443-SDK run bundle InstallMode for own namespace [Slow] [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "olm")
var operatorGroup = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
// install the operator without og with installmode
msg, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsingleallsupport-bundle:v4.11", "--install-mode", "OwnNamespace", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-n", namespace, "-o=jsonpath={.spec.targetNamespaces}").Output()
o.Expect(msg).To(o.ContainSubstring(namespace))
output, err := operatorsdkCLI.Run("cleanup").Args("ownsingleallsupport", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-ownsingleallsupport-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-ownsingleallsupport-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-ownsingleallsupport-bundle can't be deleted in %s", namespace))
// install the operator with og and installmode
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=og-own", "NAMESPACE="+namespace).OutputToFile("config-35443.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsingleallsupport-bundle:v4.11", "--install-mode", "OwnNamespace", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("ownsingleallsupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// install the operator with og without installmode
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-ownsingleallsupport-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-ownsingleallsupport-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-ownsingleallsupport-bundle can't be deleted in %s", namespace))
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsingleallsupport-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("ownsingleallsupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// delete the og
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("og", "og-own", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-ownsingleallsupport-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("quay-io-olmqe-ownsingleallsupport-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-ownsingleallsupport-bundle can't be deleted in %s", namespace))
// install the operator without og and installmode, the csv support ownnamespace and singlenamespace
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/ownsinglesupport-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-n", namespace, "-o=jsonpath={.spec.targetNamespaces}").Output()
o.Expect(msg).To(o.ContainSubstring(namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("ownsinglesupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
c296e0f3-32b9-4e8c-abc8-fe71cd460b34
|
VMonly-ConnectedOnly-Author:jfan-Medium-41064-SDK run bundle InstallMode for single namespace [Slow] [Serial]
|
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-41064-SDK run bundle InstallMode for single namespace [Slow] [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
var operatorGroup = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
err := oc.AsAdmin().WithoutNamespace().Run("create").Args("ns", "test-sdk-41064").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
defer oc.AsAdmin().WithoutNamespace().Run("delete").Args("ns", "test-sdk-41064").Execute()
msg, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all1support-bundle:v4.11", "--install-mode", "SingleNamespace=test-sdk-41064", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-n", namespace, "-o=jsonpath={.spec.targetNamespaces}").Output()
o.Expect(msg).To(o.ContainSubstring("test-sdk-41064"))
output, err := operatorsdkCLI.Run("cleanup").Args("all1support", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all1support-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all1support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all1support-bundle can't be deleted in %s", namespace))
// install the operator with og and installmode
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=og-single", "NAMESPACE="+namespace, "KAKA=test-sdk-41064").OutputToFile("config-41064.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all1support-bundle:v4.11", "--install-mode", "SingleNamespace=test-sdk-41064", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("all1support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// install the operator with og without installmode
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all1support-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all1support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all1support-bundle can't be deleted in %s", namespace))
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all1support-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
output, _ = operatorsdkCLI.Run("cleanup").Args("all1support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// delete the og
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("og", "og-single", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all1support-bundle-v4-11", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all1support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all1support-bundle can't be deleted in %s", namespace))
// install the operator without og and installmode, the csv only support singlenamespace
msg, _ = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/singlesupport-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(msg).To(o.ContainSubstring("AllNamespaces InstallModeType not supported"))
output, _ = operatorsdkCLI.Run("cleanup").Args("singlesupport", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
6e1282a7-6f87-4458-817b-35ee20b18a3d
|
VMonly-ConnectedOnly-Author:jfan-Medium-41065-SDK run bundle InstallMode for all namespace [Slow] [Serial]
|
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-41065-SDK run bundle InstallMode for all namespace [Slow] [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "olm")
var operatorGroup = filepath.Join(buildPruningBaseDir, "og-allns.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
// install the operator without og with installmode all namespace
msg, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "--install-mode", "AllNamespaces", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
defer operatorsdkCLI.Run("cleanup").Args("all2support").Output()
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "operator-sdk-og", "-o=jsonpath={.spec.targetNamespaces}", "-n", namespace).Output()
o.Expect(msg).To(o.ContainSubstring(""))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, err := operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("uninstalled"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all2support-bundle-v4-11", "--no-headers", "-n", namespace).Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all2support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all2support-bundle can't be deleted in %s", namespace))
// install the operator with og and installmode
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=og-allnames", "NAMESPACE="+namespace).OutputToFile("config-41065.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "--install-mode", "AllNamespaces", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// install the operator with og without installmode
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all2support-bundle-v4-11", "--no-headers", "-n", namespace).Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all2support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all2support-bundle can't be deleted in %s", namespace))
msg, err = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
// delete the og
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("og", "og-allnames", "-n", namespace).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "quay-io-olmqe-all2support-bundle-v4-11", "--no-headers", "-n", namespace).Output()
if strings.Contains(msg, "not found") {
e2e.Logf("not found pod quay-io-olmqe-all2support-bundle")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("pod quay-io-olmqe-all2support-bundle can't be deleted in %s", namespace))
// install the operator without og and installmode, the csv support allnamespace and ownnamespace
msg, _ = operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/all2support-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(msg).To(o.ContainSubstring("OLM has successfully installed"))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "-n", "openshift-operators").Output()
if strings.Contains(msg, "all2support.v0.0.1") {
e2e.Logf("csv all2support.v0.0.1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv all2support.v0.0.1 in %s", namespace))
output, _ = operatorsdkCLI.Run("cleanup").Args("all2support", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
0f3df9cb-2e40-4fb9-ac9e-96398f2a6f32
|
VMonly-ConnectedOnly-Author:jfan-Medium-38757-SDK operator bundle upgrade from traditional operator installation
|
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-Medium-38757-SDK operator bundle upgrade from traditional operator installation", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
var catalogofupgrade = filepath.Join(buildPruningBaseDir, "catalogsource.yaml")
var ogofupgrade = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
var subofupgrade = filepath.Join(buildPruningBaseDir, "sub.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
// install operator from sub
defer operatorsdkCLI.Run("cleanup").Args("upgradeindex", "-n", namespace).Output()
createCatalog, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", catalogofupgrade, "-p", "NAME=upgradetest", "NAMESPACE="+namespace, "ADDRESS=quay.io/olmqe/upgradeindex-index:v0.1", "DISPLAYNAME=KakaTest").OutputToFile("catalogsource-41497.json")
err := oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createCatalog, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createOg, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", ogofupgrade, "-p", "NAME=kakatest-single", "NAMESPACE="+namespace, "KAKA="+namespace).OutputToFile("createog-41497.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createOg, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createSub, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", subofupgrade, "-p", "NAME=subofupgrade", "NAMESPACE="+namespace, "SOURCENAME=upgradetest", "OPERATORNAME=upgradeindex", "SOURCENAMESPACE="+namespace, "STARTINGCSV=upgradeindex.v0.0.1").OutputToFile("createsub-41497.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createSub, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "upgradeindex.v0.0.1", "-o=jsonpath={.status.phase}", "-n", namespace).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgradeindexv0.1 installed successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv upgradeindex.v0.0.1 %s", namespace))
// upgrade by operator-sdk
msg, err := operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/upgradeindex-bundle:v0.2", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("Successfully upgraded to"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
118e635a-326a-4f32-a69c-a243f2969d8b
|
VMonly-ConnectedOnly-Author:jfan-High-42928-SDK support the previous base ansible image [Slow]
|
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-High-42928-SDK support the previous base ansible image [Slow]", func() {
clusterArchitecture := architecture.SkipNonAmd64SingleArch(oc)
// test data
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-42928-data")
crFilePath := filepath.Join(dataPath, "ansibletest_v1_previoustest.yaml")
// exec dir
tmpBasePath := "/tmp/ocp-42928-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "previousansibletest")
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
// exec ns & image tag
nsOperator := "previousansibletest-system"
imageTag := "quay.io/olmqe/previousansibletest:" + ocpversion + "-" + getRandomString()
// cleanup the test data
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
defer func() {
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "qetest.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "ansibletest", "--version", "v1", "--kind", "Previoustest", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
exutil.By("step: modify files to get the quay.io/olmqe images.")
// copy task main.yml
err = copy(filepath.Join(dataPath, "main.yml"), filepath.Join(tmpPath, "roles", "previoustest", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
// copy Dockerfile
dockerfileFilePath := filepath.Join(dataPath, "Dockerfile")
err = copy(dockerfileFilePath, filepath.Join(tmpPath, "Dockerfile"))
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocppreversion)
// copy manager.yaml
err = copy(filepath.Join(dataPath, "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-42928" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("previoustests.ansibletest.qetest.com"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/previousansibletest-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "previousansibletest-controller-manager") {
e2e.Logf("found pod previousansibletest-controller-manager")
if strings.Contains(line, "2/2") {
e2e.Logf("the status of pod previousansibletest-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod previousansibletest-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No previousansibletest-controller-manager in project %s", nsOperator))
msg, err := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/previousansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(msg, "Starting workers") {
e2e.Failf("Starting workers failed")
}
// max concurrent reconciles
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("logs").Args("deploy/previousansibletest-controller-manager", "-c", "manager", "-n", nsOperator).Output()
if strings.Contains(msg, "\"worker count\":1") {
e2e.Logf("found worker count:1")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/previousansibletest-controller-manager of %s doesn't have worker count:4", nsOperator))
// add the admin policy
err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "cluster-admin", "system:serviceaccount:"+nsOperator+":previousansibletest-controller-manager").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create the resource")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "previoustest-sample") {
e2e.Logf("found pod previoustest-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("No previoustest-sample in project %s", nsOperator))
waitErr = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/previoustest-sample", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "2 desired | 2 updated | 2 total | 2 available | 0 unavailable") {
e2e.Logf("deployment/previoustest-sample is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events")
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/previoustest-sample is wrong")
// k8s event
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("event", "-n", nsOperator).Output()
if strings.Contains(msg, "test-reason") {
e2e.Logf("k8s_event test")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get k8s event test-name in %s", nsOperator))
// k8s status
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("previoustest.ansibletest.qetest.com/previoustest-sample", "-n", nsOperator, "-o", "yaml").Output()
if strings.Contains(msg, "hello world") {
e2e.Logf("k8s_status test hello world")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get previoustest-sample hello world in %s", nsOperator))
// migrate test
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("secret", "-n", nsOperator).Output()
if strings.Contains(msg, "test-secret") {
e2e.Logf("found secret test-secret")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("doesn't get secret test-secret %s", nsOperator))
msg, err = oc.AsAdmin().WithoutNamespace().Run("describe").Args("secret", "test-secret", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("test: 6 bytes"))
// blacklist
waitErr = wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("describe").Args("configmap", "test-blacklist-watches", "-n", nsOperator).Output()
if strings.Contains(msg, "afdasdfsajsafj") {
e2e.Logf("Skipping the blacklist")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("log of deploy/previousansibletest-controller-manager of %s doesn't work the blacklist", nsOperator))
_, err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", crFilePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
_, err = makeCLI.Run("undeploy").Output()
o.Expect(err).NotTo(o.HaveOccurred())
})
| |||||
test case
|
openshift/openshift-tests-private
|
3fd727db-ad40-4f53-bda3-5821fc25281c
|
VMonly-ConnectedOnly-Author:jfan-High-42929-SDK support the previous base helm image
|
['"context"', '"fmt"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-High-42929-SDK support the previous base helm image", func() {
exutil.SkipOnProxyCluster(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
var nginx = filepath.Join(buildPruningBaseDir, "helmbase_v1_nginx.yaml")
operatorsdkCLI.showInfo = true
oc.SetupProject()
namespace := oc.Namespace()
defer operatorsdkCLI.Run("cleanup").Args("previoushelmbase", "-n", namespace).Output()
_, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/previoushelmbase-bundle:v4.11", "-n", namespace, "--timeout", "5m", "--security-context-config=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
createPreviousNginx, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", nginx, "-p", "NAME=previousnginx-sample").OutputToFile("config-42929.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createPreviousNginx, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, "--no-headers").Output()
if strings.Contains(msg, "nginx-sample") {
e2e.Logf("found pod nginx-sample")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get pod nginx-sample in %s", namespace))
err = oc.AsAdmin().WithoutNamespace().Run("delete").Args("nginx.helmbase.previous.com", "previousnginx-sample", "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
output, _ := operatorsdkCLI.Run("cleanup").Args("previoushelmbase", "-n", namespace).Output()
o.Expect(output).To(o.ContainSubstring("uninstalled"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
ee788841-100f-4722-949d-435e9b3b8c2e
|
ConnectedOnly-VMonly-Author:jfan-High-42614-SDK validate the deprecated APIs and maxOpenShiftVersion
|
['"os/exec"', 'g "github.com/onsi/ginkgo/v2"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("ConnectedOnly-VMonly-Author:jfan-High-42614-SDK validate the deprecated APIs and maxOpenShiftVersion", func() {
operatorsdkCLI.showInfo = true
exec.Command("bash", "-c", "mkdir -p /tmp/ocp-42614/traefikee-operator").Output()
defer exec.Command("bash", "-c", "rm -rf /tmp/ocp-42614").Output()
exec.Command("bash", "-c", "cp -rf test/extended/testdata/operatorsdk/ocp-42614-data/bundle/ /tmp/ocp-42614/traefikee-operator/").Output()
exutil.By("with deprecated api, with maxOpenShiftVersion")
msg, err := operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("This bundle is using APIs which were deprecated and removed in"))
o.Expect(msg).NotTo(o.ContainSubstring("error"))
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("with deprecated api, with higher version maxOpenShiftVersion")
exec.Command("bash", "-c", "sed -i 's/4.8/4.9/g' /tmp/ocp-42614/traefikee-operator/bundle/manifests/traefikee-operator.v2.1.1.clusterserviceversion.yaml").Output()
msg, _ = operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("This bundle is using APIs which were deprecated and removed"))
o.Expect(msg).To(o.ContainSubstring("error"))
exutil.By("with deprecated api, with wrong maxOpenShiftVersion")
exec.Command("bash", "-c", "sed -i 's/4.9/invalid/g' /tmp/ocp-42614/traefikee-operator/bundle/manifests/traefikee-operator.v2.1.1.clusterserviceversion.yaml").Output()
msg, _ = operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("csv.Annotations.olm.properties has an invalid value"))
o.Expect(msg).To(o.ContainSubstring("error"))
exutil.By("with deprecated api, without maxOpenShiftVersion")
exec.Command("bash", "-c", "sed -i '/invalid/d' /tmp/ocp-42614/traefikee-operator/bundle/manifests/traefikee-operator.v2.1.1.clusterserviceversion.yaml").Output()
msg, _ = operatorsdkCLI.Run("bundle").Args("validate", "/tmp/ocp-42614/traefikee-operator/bundle", "--select-optional", "name=community", "-o", "json-alpha1").Output()
o.Expect(msg).To(o.ContainSubstring("csv.Annotations not specified olm.maxOpenShiftVersion for an OCP version"))
o.Expect(msg).To(o.ContainSubstring("error"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
eb28d417-ae79-439d-b379-85cab2bab7e6
|
VMonly-ConnectedOnly-Author:jfan-High-34462-SDK playbook ansible operator generate the catalog
|
['"context"', '"fmt"', '"os"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jfan-High-34462-SDK playbook ansible operator generate the catalog", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.ARM64, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
var (
buildPruningBaseDir = exutil.FixturePath("testdata", "operatorsdk")
catalogofcatalog = filepath.Join(buildPruningBaseDir, "catalogsource.yaml")
ogofcatalog = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
subofcatalog = filepath.Join(buildPruningBaseDir, "sub.yaml")
dataPath = filepath.Join(buildPruningBaseDir, "ocp-34462-data")
tmpBasePath = "/tmp/ocp-34462-" + getRandomString()
tmpPath = filepath.Join(tmpBasePath, "catalogtest")
imageTag = "quay.io/olmqe/catalogtest-operator:34462-v" + ocpversion + getRandomString()
bundleImage = "quay.io/olmqe/catalogtest-bundle:34462-v" + ocpversion + getRandomString()
catalogImage = "quay.io/olmqe/catalogtest-index:34462-v" + ocpversion + getRandomString()
quayCLI = container.NewQuayCLI()
)
operatorsdkCLI.showInfo = true
oc.SetupProject()
defer os.RemoveAll(tmpBasePath)
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
exutil.By("Create the playbook ansible operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain=catalogtest.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("Create api")
output, err = operatorsdkCLI.Run("create").Args("api", "--group=cache", "--version=v1", "--kind=Catalogtest", "--generate-playbook").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
err = copy(filepath.Join(dataPath, "Dockerfile"), filepath.Join(tmpPath, "Dockerfile"))
o.Expect(err).NotTo(o.HaveOccurred())
replaceContent(filepath.Join(tmpPath, "Dockerfile"), "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-operator:vocpversion", "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
exutil.By("step: Build and push the operator image")
tokenDir := "/tmp/ocp-34462" + getRandomString()
defer os.RemoveAll(tokenDir)
err = os.MkdirAll(tokenDir, os.ModePerm)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
// OCP-40219
exutil.By("Generate the bundle image and catalog index image")
replaceContent(filepath.Join(tmpPath, "Makefile"), "controller:latest", imageTag)
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "catalogtest.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "catalogtest.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := makeCLI.Run("bundle").Args().Output()
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
replaceContent(filepath.Join(tmpPath, "Makefile"), " --container-tool docker ", " ")
defer quayCLI.DeleteTag(strings.Replace(bundleImage, "quay.io/", "", 1))
defer quayCLI.DeleteTag(strings.Replace(catalogImage, "quay.io/", "", 1))
_, err = makeCLI.Run("bundle-build").Args("bundle-push", "catalog-build", "catalog-push", "BUNDLE_IMG="+bundleImage, "CATALOG_IMG="+catalogImage).Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Install the operator through olm")
namespace := oc.Namespace()
createCatalog, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", catalogofcatalog, "-p", "NAME=cs-catalog", "NAMESPACE="+namespace, "ADDRESS="+catalogImage, "DISPLAYNAME=CatalogTest").OutputToFile("catalogsource-34462.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createCatalog, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createOg, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", ogofcatalog, "-p", "NAME=catalogtest-single", "NAMESPACE="+namespace, "KAKA="+namespace).OutputToFile("createog-34462.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createOg, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
createSub, _ := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", subofcatalog, "-p", "NAME=cataloginstall", "NAMESPACE="+namespace, "SOURCENAME=cs-catalog", "OPERATORNAME=catalogtest", "SOURCENAMESPACE="+namespace, "STARTINGCSV=catalogtest.v0.0.1").OutputToFile("createsub-34462.json")
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", createSub, "-n", namespace).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 390*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "catalogtest.v0.0.1", "-o=jsonpath={.status.phase}", "-n", namespace).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("catalogtest installed successfully")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("can't get csv catalogtest.v0.0.1 in %s", namespace))
})
| |||||
test case
|
openshift/openshift-tests-private
|
a916bced-5dd1-4c68-81ed-db4c617c56b9
|
Author:chuo-Medium-27718-scorecard remove version flag
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:chuo-Medium-27718-scorecard remove version flag", func() {
operatorsdkCLI.showInfo = true
output, _ := operatorsdkCLI.Run("scorecard").Args("--version").Output()
o.Expect(output).To(o.ContainSubstring("unknown flag: --version"))
})
| ||||||
test case
|
openshift/openshift-tests-private
|
4e20bbc2-383d-4f28-a59f-bf8ba5bbeaa9
|
VMonly-Author:chuo-Critical-37655-run bundle upgrade connect to the Operator SDK CLI
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-Author:chuo-Critical-37655-run bundle upgrade connect to the Operator SDK CLI", func() {
operatorsdkCLI.showInfo = true
output, _ := operatorsdkCLI.Run("run").Args("bundle-upgrade", "-h").Output()
o.Expect(output).To(o.ContainSubstring("help for bundle-upgrade"))
})
| ||||||
test case
|
openshift/openshift-tests-private
|
125594c9-ab20-4ab9-b25c-adce511fcd0b
|
Author:jitli-VMonly-Medium-34945-ansible Add flag metricsaddr for ansible operator
|
['"os"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jitli-VMonly-Medium-34945-ansible Add flag metricsaddr for ansible operator", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
imageTag := "registry-proxy.engineering.redhat.com/rh-osbs/openshift-ose-ansible-rhel9-operator:v" + ocpversion
containerCLI := container.NewPodmanCLI()
e2e.Logf("create container with image %s", imageTag)
id, err := containerCLI.ContainerCreate(imageTag, "test-34945", "/bin/sh", true)
defer func() {
e2e.Logf("stop container %s", id)
containerCLI.ContainerStop(id)
e2e.Logf("remove container %s", id)
err := containerCLI.ContainerRemove(id)
if err != nil {
e2e.Failf("Defer: fail to remove container %s", id)
}
}()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("container id is %s", id)
e2e.Logf("start container %s", id)
err = containerCLI.ContainerStart(id)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("start container %s successful", id)
commandStr := []string{"ansible-operator", "run", "--help"}
output, err := containerCLI.Exec(id, commandStr)
if err != nil {
e2e.Failf("command %s: %s", commandStr, output)
}
o.Expect(output).To(o.ContainSubstring("--metrics-bind-address"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
5e1df9b2-7fe2-4ebd-8647-958a658e1175
|
Author:jitli-VMonly-Medium-77166-Check the ansible-operator-plugins version info
|
['"os"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jitli-VMonly-Medium-77166-Check the ansible-operator-plugins version info", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
imageTag := "registry-proxy.engineering.redhat.com/rh-osbs/openshift-ose-ansible-rhel9-operator:v" + ocpversion
containerCLI := container.NewPodmanCLI()
e2e.Logf("create container with image %s", imageTag)
id, err := containerCLI.ContainerCreate(imageTag, "test-77166", "/bin/sh", true)
defer func() {
e2e.Logf("stop container %s", id)
containerCLI.ContainerStop(id)
e2e.Logf("remove container %s", id)
err := containerCLI.ContainerRemove(id)
if err != nil {
e2e.Failf("Defer: fail to remove container %s", id)
}
}()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("container id is %s", id)
e2e.Logf("start container %s", id)
err = containerCLI.ContainerStart(id)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("start container %s successful", id)
commandStr := []string{"ansible-operator", "version"}
output, err := containerCLI.Exec(id, commandStr)
if err != nil {
e2e.Failf("command %s: %s", commandStr, output)
}
o.Expect(output).To(o.ContainSubstring("v1.36."))
})
| |||||
test case
|
openshift/openshift-tests-private
|
ed9dfb65-b2b5-4e9b-ba69-fc700242afc4
|
Author:jitli-High-52126-Sync 1.29 to downstream
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jitli-High-52126-Sync 1.29 to downstream", func() {
operatorsdkCLI.showInfo = true
output, _ := operatorsdkCLI.Run("version").Args().Output()
o.Expect(output).To(o.ContainSubstring("v1.29"))
})
| ||||||
test case
|
openshift/openshift-tests-private
|
033a3e40-d0ef-4a59-94b7-dcf7a81f397c
|
ConnectedOnly-VMonly-Author:chuo-High-34427-Ensure that Ansible Based Operators creation is working
|
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("ConnectedOnly-VMonly-Author:chuo-High-34427-Ensure that Ansible Based Operators creation is working", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/memcached-operator-ansible-base:v" + ocpversion + getRandomString()
// TODO[aleskandro,chuo]: this is a workaround See https://issues.redhat.com/browse/ARMOCP-531
if clusterArchitecture == architecture.ARM64 {
imageTag = "quay.io/olmqe/memcached-operator-ansible-base:v" + ocpversion + "-34427"
}
nsSystem := "system-ocp34427" + getRandomString()
nsOperator := "memcached-operator-34427-system-" + getRandomString()
tmpBasePath := "/tmp/ocp-34427-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-34427")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
if imageTag != "quay.io/olmqe/memcached-operator-ansible-base:v"+ocpversion+"-34427" {
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}
defer func() {
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached34427", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
if !upstream {
exutil.By("step: OCP-52625 operatorsdk generate operator base image match the release version.")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
}
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-34427-data", "roles", "memcached")
err = copy(filepath.Join(dataPath, "tasks", "main.yml"), filepath.Join(tmpPath, "roles", "memcached34427", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "defaults", "main.yml"), filepath.Join(tmpPath, "roles", "memcached34427", "defaults", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$d' %s/config/samples/cache_v1alpha1_memcached34427.yaml", tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\ size: 3' %s/config/samples/cache_v1alpha1_memcached34427.yaml", tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-34427-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-34427-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: Push the operator image")
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml", "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml --force")
tokenDir := "/tmp/ocp-34427-auth" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
switch clusterArchitecture {
case architecture.AMD64:
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
case architecture.ARM64:
e2e.Logf(fmt.Sprintf("platform is %s, IMG is %s", clusterArchitecture.String(), imageTag))
}
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached34427s.cache.example.com created"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "memcached34427s.cache.example.com").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-34427-controller-manager"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "memcached-operator-34427-controller-manager") {
e2e.Logf("found pod memcached-operator-34427-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod memcached-operator-34427-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod memcached-operator-34427-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No memcached-operator-34427-controller-manager")
exutil.By("step: Create the resource")
filePath := filepath.Join(tmpPath, "config", "samples", "cache_v1alpha1_memcached34427.yaml")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", filePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "memcached34427-sample") {
e2e.Logf("found pod memcached34427-sample")
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No pod memcached34427-sample")
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached34427-sample-memcached", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "3 desired | 3 updated | 3 total | 3 available | 0 unavailable") {
e2e.Logf("deployment/memcached34427-sample-memcached is created successfully")
return true, nil
}
return false, nil
})
if waitErr != nil {
msg, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args("deployment/memcached34427-sample-memcached", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf(msg)
msg, _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("events", "-n", nsOperator).Output()
e2e.Logf(msg)
}
exutil.AssertWaitPollNoErr(waitErr, "the status of deployment/memcached34427-sample-memcached is wrong")
exutil.By("34427 SUCCESS")
})
| |||||
test case
|
openshift/openshift-tests-private
|
81c7fb4d-d9c7-488f-acba-8a8dd186990c
|
ConnectedOnly-VMonly-Author:chuo-Medium-34366-change ansible operator flags from maxWorkers using env MAXCONCURRENTRECONCILES
|
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("ConnectedOnly-VMonly-Author:chuo-Medium-34366-change ansible operator flags from maxWorkers using env MAXCONCURRENTRECONCILES ", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/memcached-operator-max-worker:v" + ocpversion + getRandomString()
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
if clusterArchitecture == architecture.ARM64 {
imageTag = "quay.io/olmqe/memcached-operator-max-worker:v" + ocpversion + "-34366"
}
nsSystem := "system-ocp34366" + getRandomString()
nsOperator := "memcached-operator-34366-system-" + getRandomString()
tmpBasePath := "/tmp/ocp-34366-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-34366")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
if imageTag != "quay.io/olmqe/memcached-operator-max-worker:v"+ocpversion+"-34366" {
quayCLI := container.NewQuayCLI()
defer quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}
defer func() {
exutil.By("step: undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Ansible Based Operator")
output, err := operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next"))
if !upstream {
exutil.By("step: modify Dockerfile.")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-ansible-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-ansible-rhel9-operator:v"+ocpversion)
}
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached34366", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-34366-data")
err = copy(filepath.Join(dataPath, "roles", "memcached", "tasks", "main.yml"), filepath.Join(tmpPath, "roles", "memcached34366", "tasks", "main.yml"))
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "config", "manager", "manager.yaml"), filepath.Join(tmpPath, "config", "manager", "manager.yaml"))
o.Expect(err).NotTo(o.HaveOccurred())
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: memcached-operator-34366-system/namespace: %s/g' `grep -rl \"namespace: memcached-operator-34366-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: build and push img.")
dockerFilePath := filepath.Join(tmpPath, "Dockerfile")
replaceContent(dockerFilePath, "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml", "RUN ansible-galaxy collection install -r ${HOME}/requirements.yml --force")
tokenDir := "/tmp/ocp-34366-auth" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
// TODO[aleskandro,chuo]: this is a workaround: https://issues.redhat.com/browse/ARMOCP-531
architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
switch clusterArchitecture {
case architecture.AMD64:
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
case architecture.ARM64:
e2e.Logf(fmt.Sprintf("platform is %s, IMG is %s", clusterArchitecture.String(), imageTag))
}
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("memcached34366s.cache.example.com created"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "memcached34366s.cache.example.com").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/memcached-operator-34366-controller-manager"))
_, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-cluster-role-to-user", "cluster-admin", fmt.Sprintf("system:serviceaccount:%s:default", nsOperator)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 300*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if strings.Contains(msg, "Running") {
return true, nil
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "memcached-operator-34366-controller-manager has no Starting workers")
output, err = oc.AsAdmin().WithoutNamespace().Run("logs").Args("deployment.apps/memcached-operator-34366-controller-manager", "-c", "manager", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("\"worker count\":6"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
f3f17c5f-1221-4dc4-855f-57941a3ceb62
|
VMonly-ConnectedOnly-Author:jitli-Medium-34883-SDK stamp on Operator bundle image [Slow]
|
['"context"', '"os"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:jitli-Medium-34883-SDK stamp on Operator bundle image [Slow]", func() {
operatorsdkCLI.showInfo = true
tmpBasePath := "/tmp/ocp-34883-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-34883")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-34883-data")
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached34883", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: make bundle.")
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-34883.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "memcached-operator-34883.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := makeCLI.Run("bundle").Args().Output()
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
exutil.By("Step: check annotations")
annotationsFile := filepath.Join(tmpPath, "bundle", "metadata", "annotations.yaml")
content := getContent(annotationsFile)
o.Expect(content).To(o.ContainSubstring("operators.operatorframework.io.metrics.builder: operator-sdk"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
042fb00b-cc75-4134-967a-3fc49e9d84d1
|
VMonly-ConnectedOnly-Author:chuo-Critical-45431-Critical-45428-Medium-43973-Medium-43976-Medium-48630-scorecard basic test migration and migrate olm tests and proxy configurable and xunit adjustment and sa
|
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:chuo-Critical-45431-Critical-45428-Medium-43973-Medium-43976-Medium-48630-scorecard basic test migration and migrate olm tests and proxy configurable and xunit adjustment and sa ", func() {
operatorsdkCLI.showInfo = true
oc.SetupProject()
tmpBasePath := "/tmp/ocp-45431-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-43973-data")
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "memcached-operator.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args().Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
output, _ := operatorsdkCLI.Run("version").Args("").Output()
e2e.Logf("The OperatorSDK version is %s", output)
// OCP-43973
exutil.By("scorecard basic test migration")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=basic-check-spec-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("spec missing from [memcached-sample]"))
// OCP-43976
exutil.By("migrate OLM tests-bundle validation")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
exutil.By("migrate OLM tests-crds have validation test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-crds-have-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
exutil.By("migrate OLM tests-crds have resources test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-crds-have-resources-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: fail"))
o.Expect(output).To(o.ContainSubstring("Owned CRDs do not have resources specified"))
exutil.By("migrate OLM tests- spec descriptors test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-spec-descriptors-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: fail"))
exutil.By("migrate OLM tests- status descriptors test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-status-descriptors-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("memcacheds.cache.example.com does not have status spec"))
// OCP-48630
exutil.By("scorecard proxy container port should be configurable")
exec.Command("bash", "-c", fmt.Sprintf("sed -i '$a\\proxy-port: 9001' %s/bundle/tests/scorecard/config.yaml", tmpPath)).Output()
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
// OCP-45428 xunit adjustments - add nested tags and attributes
exutil.By("migrate OLM tests-bundle validation to generate a pass xunit output")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test", "-o", "xunit", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("<testsuite name=\"olm-bundle-validation-test\""))
o.Expect(output).To(o.ContainSubstring("<testcase name=\"olm-bundle-validation\""))
exutil.By("migrate OLM tests-status descriptors to generate a failed xunit output")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-status-descriptors-test", "-o", "xunit", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("<testcase name=\"olm-status-descriptors\""))
o.Expect(output).To(o.ContainSubstring("<system-out>Loaded ClusterServiceVersion:"))
o.Expect(output).To(o.ContainSubstring("failure"))
// OCP-45431 bring in latest o-f/api to SDK BEFORE 1.13
exutil.By("use an non-exist service account to run test")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test ", "-s", "testing", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).To(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("serviceaccount \"testing\" not found"))
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", "test/extended/testdata/operatorsdk/ocp-43973-data/sa_testing.yaml", "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
_, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "100s", "--selector=test=olm-bundle-validation-test ", "-s", "testing", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
})
| |||||
test case
|
openshift/openshift-tests-private
|
76958039-7388-40d4-9020-57793783c3a5
|
VMonly-ConnectedOnly-Author:chuo-High-43660-scorecard support storing test output
|
['"context"', '"os"', '"strings"', '"time"', '"path/filepath"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("VMonly-ConnectedOnly-Author:chuo-High-43660-scorecard support storing test output", func() {
operatorsdkCLI.showInfo = true
oc.SetupProject()
tmpBasePath := "/tmp/ocp-43660-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-43660")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
buildPruningBaseDir := exutil.FixturePath("testdata", "operatorsdk")
dataPath := filepath.Join(buildPruningBaseDir, "ocp-43660-data")
exutil.By("step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins=ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: Create API.")
_, err = operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached43660", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("step: make bundle.")
manifestsPath := filepath.Join(tmpPath, "config", "manifests", "bases")
err = os.MkdirAll(manifestsPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
manifestsFile := filepath.Join(manifestsPath, "memcached-operator-43660.clusterserviceversion.yaml")
_, err = os.Create(manifestsFile)
o.Expect(err).NotTo(o.HaveOccurred())
err = copy(filepath.Join(dataPath, "manifests", "bases", "memcached-operator-43660.clusterserviceversion.yaml"), filepath.Join(manifestsFile))
o.Expect(err).NotTo(o.HaveOccurred())
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
msg, err := makeCLI.Run("bundle").Args().Output()
if err != nil {
e2e.Logf("make bundle failed, try again")
return false, nil
}
if strings.Contains(msg, "operator-sdk bundle validate ./bundle") {
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, "operator-sdk bundle generate failed")
exutil.By("run scorecard ")
output, err := operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "4m", "--selector=test=olm-bundle-validation-test", "--test-output", "/testdata", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("Name: olm-bundle-validation"))
exutil.By("step: modify test config.")
configFilePath := filepath.Join(tmpPath, "bundle", "tests", "scorecard", "config.yaml")
replaceContent(configFilePath, "mountPath: {}", "mountPath:\n path: /test-output")
exutil.By("scorecard basic test migration")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "60s", "--selector=test=basic-check-spec-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(output).To(o.ContainSubstring("State: pass"))
o.Expect(output).To(o.ContainSubstring("spec missing from [memcached43660-sample]"))
pathOutput := filepath.Join(tmpPath, "test-output", "basic", "basic-check-spec-test")
waitErr = wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) {
if _, err := os.Stat(pathOutput); os.IsNotExist(err) {
e2e.Logf("get basic-check-spec-test Failed")
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(waitErr, "get basic-check-spec-test Failed")
output, err = operatorsdkCLI.Run("scorecard").Args("./bundle", "-c", "./bundle/tests/scorecard/config.yaml", "-w", "60s", "--selector=test=olm-bundle-validation-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
e2e.Logf(" scorecard bundle %v", err)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("State: pass"))
pathOutput = filepath.Join(tmpPath, "test-output", "olm", "olm-bundle-validation-test")
waitErr = wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 6*time.Second, false, func(ctx context.Context) (bool, error) {
if _, err := os.Stat(pathOutput); os.IsNotExist(err) {
e2e.Logf("get olm-bundle-validation-test Failed")
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(waitErr, "get olm-bundle-validation-test Failed")
})
| |||||
test case
|
openshift/openshift-tests-private
|
20348bd1-a586-4e78-b5a3-08fe59eb227d
|
ConnectedOnly-Author:chuo-High-31219-scorecard bundle is mandatory
|
['"os"', '"os/exec"', '"path/filepath"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("ConnectedOnly-Author:chuo-High-31219-scorecard bundle is mandatory ", func() {
operatorsdkCLI.showInfo = true
oc.SetupProject()
tmpBasePath := "/tmp/ocp-31219-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "memcached-operator-31219")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
exutil.By("Step: init Ansible Based Operator")
_, err = operatorsdkCLI.Run("init").Args("--plugins", "ansible", "--domain", "example.com").Output()
o.Expect(err).NotTo(o.HaveOccurred())
exutil.By("Step: Create API.")
output, err := operatorsdkCLI.Run("create").Args("api", "--group", "cache", "--version", "v1alpha1", "--kind", "Memcached", "--generate-role").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Writing kustomize manifests"))
result, err := exec.Command("bash", "-c", "cd "+tmpPath+" && operator-sdk generate bundle --deploy-dir=config --crds-dir=config/crds --version=0.0.1").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.ContainSubstring("Bundle manifests generated successfully in bundle"))
output, err = operatorsdkCLI.Run("scorecard").Args("bundle", "-c", "config/scorecard/bases/config.yaml", "-w", "60s", "--selector=test=basic-check-spec-test", "-n", oc.Namespace(), "--pod-security=restricted").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("tests selected"))
})
| |||||
test case
|
openshift/openshift-tests-private
|
27a3afcb-8969-4a29-ae8c-bf178a76e27c
|
ConnectedOnly-VMonly-Author:chuo-High-34426-Critical-52625-Medium-37142-ensure that Helm Based Operators creation and cr create delete
|
['"context"', '"fmt"', '"os"', '"os/exec"', '"strings"', '"time"', '"github.com/openshift/openshift-tests-private/test/extended/util/architecture"', '"path/filepath"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("ConnectedOnly-VMonly-Author:chuo-High-34426-Critical-52625-Medium-37142-ensure that Helm Based Operators creation and cr create delete ", func() {
clusterArchitecture := architecture.SkipArchitectures(oc, architecture.MULTI, architecture.PPC64LE, architecture.S390X)
imageTag := "quay.io/olmqe/nginx-operator-base:v" + ocpversion + "-34426" + getRandomString()
nsSystem := "system-34426-" + getRandomString()
nsOperator := "nginx-operator-34426-system"
tmpBasePath := "/tmp/ocp-34426-" + getRandomString()
tmpPath := filepath.Join(tmpBasePath, "nginx-operator-34426")
err := os.MkdirAll(tmpPath, 0o755)
o.Expect(err).NotTo(o.HaveOccurred())
defer os.RemoveAll(tmpBasePath)
operatorsdkCLI.ExecCommandPath = tmpPath
makeCLI.ExecCommandPath = tmpPath
defer func() {
quayCLI := container.NewQuayCLI()
quayCLI.DeleteTag(strings.Replace(imageTag, "quay.io/", "", 1))
}()
defer func() {
exutil.By("delete nginx-sample")
filePath := filepath.Join(tmpPath, "config", "samples", "demo_v1_nginx34426.yaml")
oc.AsAdmin().WithoutNamespace().Run("delete").Args("-f", filePath, "-n", nsOperator).Output()
waitErr := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) {
output, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("Nginx34426", "-n", nsOperator).Output()
if strings.Contains(output, "nginx34426-sample") {
e2e.Logf("nginx34426-sample still exists")
return false, nil
}
return true, nil
})
if waitErr != nil {
e2e.Logf("delete nginx-sample failed, still try to run make undeploy")
}
exutil.By("step: run make undeploy")
_, err = makeCLI.Run("undeploy").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
exutil.By("step: init Helm Based Operators")
output, err := operatorsdkCLI.Run("init").Args("--plugins=helm").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Next: define a resource with"))
exutil.By("step: Create API.")
output, err = operatorsdkCLI.Run("create").Args("api", "--group", "demo", "--version", "v1", "--kind", "Nginx34426").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("nginx"))
if !upstream {
exutil.By("step: OCP-52625 operatorsdk generate operator base image match the release version .")
dockerFile := filepath.Join(tmpPath, "Dockerfile")
content := getContent(dockerFile)
o.Expect(content).To(o.ContainSubstring("registry.redhat.io/openshift4/ose-helm-rhel9-operator:v" + ocpversion))
replaceContent(dockerFile, "registry.redhat.io/openshift4/ose-helm-rhel9-operator:v"+ocpversion, "brew.registry.redhat.io/rh-osbs/openshift-ose-helm-operator-rhel9:v"+ocpversion)
}
exutil.By("step: modify namespace")
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/name: system/name: %s/g' `grep -rl \"name: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: system/namespace: %s/g' `grep -rl \"namespace: system\" %s`", nsSystem, tmpPath)).Output()
exec.Command("bash", "-c", fmt.Sprintf("sed -i 's/namespace: nginx-operator-34426-system/namespace: %s/g' `grep -rl \"namespace: nginx-operator-system\" %s`", nsOperator, tmpPath)).Output()
exutil.By("step: build and Push the operator image")
tokenDir := "/tmp/ocp-34426" + getRandomString()
err = os.MkdirAll(tokenDir, os.ModePerm)
defer os.RemoveAll(tokenDir)
if err != nil {
e2e.Failf("fail to create the token folder:%s", tokenDir)
}
_, err = oc.AsAdmin().WithoutNamespace().Run("extract").Args("secret/pull-secret", "-n", "openshift-config", fmt.Sprintf("--to=%s", tokenDir), "--confirm").Output()
if err != nil {
e2e.Failf("Fail to get the cluster auth %v", err)
}
buildPushOperatorImage(clusterArchitecture, tmpPath, imageTag, tokenDir)
exutil.By("step: Install the CRD")
output, err = makeCLI.Run("install").Args().Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("nginx34426s.demo.my.domain"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("crd", "nginx34426s.demo.my.domain").Output()
e2e.Logf(output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).NotTo(o.ContainSubstring("NotFound"))
exutil.By("step: Deploy the operator")
output, err = makeCLI.Run("deploy").Args("IMG=" + imageTag).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("deployment.apps/nginx-operator-34426-controller-manager created"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "nginx-operator-34426-controller-manager") {
e2e.Logf("found pod nginx-operator-34426-controller-manager")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod nginx-operator-34426-controller-manager is Running")
return true, nil
}
e2e.Logf("the status of pod nginx-operator-34426-controller-manager is not Running")
return false, nil
}
}
return false, nil
})
if err != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No nginx-operator-34426-controller-manager")
_, err = oc.AsAdmin().WithoutNamespace().Run("adm").Args("policy", "add-scc-to-user", "anyuid", fmt.Sprintf("system:serviceaccount:%s:nginx34426-sample", nsOperator)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
// OCP-37142
exutil.By("step: Create the resource")
filePath := filepath.Join(tmpPath, "config", "samples", "demo_v1_nginx34426.yaml")
replaceContent(filePath, "repository: nginx", "repository: quay.io/olmqe/nginx-docker")
replaceContent(filePath, "tag: \"\"", "tag: multi-arch")
_, err = oc.AsAdmin().WithoutNamespace().Run("apply").Args("-f", filePath, "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
waitErr = wait.PollUntilContextTimeout(context.TODO(), 30*time.Second, 180*time.Second, false, func(ctx context.Context) (bool, error) {
podList, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", nsOperator).Output()
o.Expect(err).NotTo(o.HaveOccurred())
if !strings.Contains(podList, "nginx34426-sample") {
e2e.Logf("No nginx34426-sample")
return false, nil
}
lines := strings.Split(podList, "\n")
for _, line := range lines {
if strings.Contains(line, "nginx34426-sample") {
e2e.Logf("found pod nginx34426-sample")
if strings.Contains(line, "Running") {
e2e.Logf("the status of pod nginx34426-sample is Running")
return true, nil
}
e2e.Logf("the status of pod nginx34426-sample is not Running")
return false, nil
}
}
return false, nil
})
if waitErr != nil {
logDebugInfo(oc, nsOperator, "events", "pod")
}
exutil.AssertWaitPollNoErr(waitErr, "No nginx34426-sample is in Running status")
})
| |||||
test case
|
openshift/openshift-tests-private
|
6b7410e5-5722-4e8e-8524-1e7741476847
|
Author:jitli-VMonly-ConnectedOnly-Critical-38101-implement IndexImageCatalogCreator [Serial]
|
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jitli-VMonly-ConnectedOnly-Critical-38101-implement IndexImageCatalogCreator [Serial]", func() {
exutil.SkipOnProxyCluster(oc)
operatorsdkCLI.showInfo = true
exutil.By("0) check the cluster proxy configuration")
httpProxy, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxy", "cluster", "-o=jsonpath={.status.httpProxy}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
if httpProxy != "" {
g.Skip("Skip for cluster with proxy")
}
exutil.By("step: create new project")
oc.SetupProject()
ns := oc.Namespace()
exutil.By("step: run bundle 1")
output, err := operatorsdkCLI.Run("run").Args("bundle", "quay.io/olmqe/kubeturbo-bundle:v8.4.0", "-n", ns, "--timeout", "5m", "--security-context-config=restricted").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("OLM has successfully installed"))
exutil.By("step: check catsrc annotations")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("index-image"))
o.Expect(output).To(o.ContainSubstring("injected-bundles"))
o.Expect(output).To(o.ContainSubstring("registry-pod-name"))
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.4.0"))
o.Expect(output).NotTo(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.5.0"))
exutil.By("step: check catsrc address")
podname1, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations.operators\\.operatorframework\\.io/registry-pod-name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podname1).NotTo(o.BeEmpty())
ip, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", podname1, "-n", oc.Namespace(), "-o=jsonpath={.status.podIP}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(ip).NotTo(o.BeEmpty())
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.address}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal(ip + ":50051"))
exutil.By("step: check catsrc sourceType")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.sourceType}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("grpc"))
exutil.By("step: check packagemanifest")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].currentCSV}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("kubeturbo-operator.v8.4.0"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk-run-bundle"))
exutil.By("step: upgrade bundle")
output, err = operatorsdkCLI.Run("run").Args("bundle-upgrade", "quay.io/olmqe/kubeturbo-bundle:v8.5.0", "-n", ns, "--timeout", "5m", "--security-context-config=restricted").Output()
if err != nil {
logDebugInfo(oc, ns, "csv", "pod", "ip")
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Successfully upgraded to"))
waitErr := wait.PollUntilContextTimeout(context.TODO(), 15*time.Second, 360*time.Second, false, func(ctx context.Context) (bool, error) {
msg, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("csv", "kubeturbo-operator.v8.5.0", "-n", ns).Output()
if strings.Contains(msg, "Succeeded") {
e2e.Logf("upgrade to 8.5.0 success")
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(waitErr, fmt.Sprintf("upgradeoperator upgrade failed in %s ", ns))
exutil.By("step: check catsrc annotations")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("index-image"))
o.Expect(output).To(o.ContainSubstring("injected-bundles"))
o.Expect(output).To(o.ContainSubstring("registry-pod-name"))
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.4.0"))
o.Expect(output).To(o.ContainSubstring("quay.io/olmqe/kubeturbo-bundle:v8.5.0"))
exutil.By("step: check catsrc address")
podname2, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.metadata.annotations.operators\\.operatorframework\\.io/registry-pod-name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(podname2).NotTo(o.BeEmpty())
o.Expect(podname2).NotTo(o.Equal(podname1))
ip, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", podname2, "-n", oc.Namespace(), "-o=jsonpath={.status.podIP}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(ip).NotTo(o.BeEmpty())
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.address}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal(ip + ":50051"))
exutil.By("step: check catsrc sourceType")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "kubeturbo-catalog", "-n", oc.Namespace(), "-o=jsonpath={.spec.sourceType}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.Equal("grpc"))
exutil.By("step: check packagemanifest")
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].currentCSV}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("kubeturbo-operator.v8.5.0"))
output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("packagemanifest", "kubeturbo", "-n", oc.Namespace(), "-o=jsonpath={.status.channels[*].name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("operator-sdk-run-bundle"))
exutil.By("SUCCESS")
})
| |||||
test case
|
openshift/openshift-tests-private
|
5db17be9-15e5-4e1c-9e4f-381a7257804c
|
Author:jitli-VMonly-ConnectedOnly-High-42028-Check python kubernetes package
|
['"os"', 'container "github.com/openshift/openshift-tests-private/test/extended/util/container"']
|
github.com/openshift/openshift-tests-private/test/extended/operatorsdk/operatorsdk.go
|
g.It("Author:jitli-VMonly-ConnectedOnly-High-42028-Check python kubernetes package", func() {
if os.Getenv("HTTP_PROXY") != "" || os.Getenv("http_proxy") != "" {
g.Skip("HTTP_PROXY is not empty - skipping test ...")
}
imageTag := "registry-proxy.engineering.redhat.com/rh-osbs/openshift-ose-ansible-rhel9-operator:v" + ocpversion
containerCLI := container.NewPodmanCLI()
e2e.Logf("create container with image %s", imageTag)
id, err := containerCLI.ContainerCreate(imageTag, "test-42028", "/bin/sh", true)
defer func() {
e2e.Logf("stop container %s", id)
containerCLI.ContainerStop(id)
e2e.Logf("remove container %s", id)
err := containerCLI.ContainerRemove(id)
if err != nil {
e2e.Failf("Defer: fail to remove container %s", id)
}
}()
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("container id is %s", id)
e2e.Logf("start container %s", id)
err = containerCLI.ContainerStart(id)
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("start container %s successful", id)
commandStr := []string{"pip3", "show", "kubernetes"}
output, err := containerCLI.Exec(id, commandStr)
e2e.Logf("command %s: %s", commandStr, output)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.ContainSubstring("Version:"))
o.Expect(output).To(o.ContainSubstring("30.1."))
e2e.Logf("OCP 42028 SUCCESS")
})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.