Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sleep 10 seconds after account-role created to let the role creation … #359

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions tests/ci/profile_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"regexp"
"strings"
"time"

. "github.com/onsi/gomega"
client "github.com/openshift-online/ocm-sdk-go"
Expand Down Expand Up @@ -194,6 +195,10 @@ func GenerateClusterCreationArgsByProfile(token string, profile *Profile) (clust
accountRolesOutput, err := PrepareAccountRoles(token, clusterArgs.ClusterName, clusterArgs.AWSRegion, profile.Version, profile.ChannelGroup)
Expect(err).ToNot(HaveOccurred())
clusterArgs.AccountRolePrefix = accountRolesOutput.AccountRolePrefix
Logger.Infof("Created account roles with prefix %s", accountRolesOutput.AccountRolePrefix)

Logger.Infof("Sleep for 10 sec to let aws account role async creation finished")
time.Sleep(10 * time.Second)

oidcOutput, err := PrepareOIDCProviderAndOperatorRoles(token, profile.OIDCConfig, clusterArgs.ClusterName, accountRolesOutput.AccountRolePrefix, clusterArgs.AWSRegion)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -336,7 +341,9 @@ func DestroyRHCSClusterByProfile(token string, profile *Profile) error {
OperatorRolePrefix: "",
}
err = clusterService.Destroy(clusterArgs)
Expect(err).ToNot(HaveOccurred())
if err != nil {
return err
}

// Destroy VPC
if profile.BYOVPC {
Expand All @@ -345,28 +352,38 @@ func DestroyRHCSClusterByProfile(token string, profile *Profile) error {
AWSRegion: profile.Region,
}
err := vpcService.Destroy(vpcArgs)
Expect(err).ToNot(HaveOccurred())
if err != nil {
return err
}
}
if profile.STS {
// Destroy oidc and operator roles
oidcOpService, err := EXE.NewOIDCProviderOperatorRolesService()
Expect(err).ToNot(HaveOccurred())
if err != nil {
return err
}
args := &EXE.OIDCProviderOperatorRolesArgs{
Token: token,
OIDCConfig: profile.OIDCConfig,
AWSRegion: profile.Region,
}
err = oidcOpService.Destroy(args)
Expect(err).ToNot(HaveOccurred())
if err != nil {
return err
}

// Destroy Account roles
accService, err := EXE.NewAccountRoleService()
Expect(err).ToNot(HaveOccurred())
if err != nil {
return err
}
accargs := &EXE.AccountRolesArgs{
Token: token,
}
err = accService.Destroy(accargs)
Expect(err).ToNot(HaveOccurred())
if err != nil {
return err
}

}
return nil
Expand All @@ -377,23 +394,24 @@ func DestroyRHCSClusterByProfile(token string, profile *Profile) error {
// Two ways:
// - If you created a cluster by other way, you can Export CLUSTER_ID=<cluster id>
// - If you are using this CI created the cluster, just need to Export CLUSTER_PROFILE=<profile name>
func PrepareRHCSClusterByProfileENV() string {
func PrepareRHCSClusterByProfileENV() (string, error) {
// Support the cluster ID to set to ENV in case somebody created cluster by other way
// Export CLUSTER_ID=<cluster id>
if os.Getenv(CON.ClusterIDEnv) != "" {
return os.Getenv(CON.ClusterIDEnv)
return os.Getenv(CON.ClusterIDEnv), nil
}
if os.Getenv(CON.RhcsClusterProfileENV) == "" {
Logger.Warnf("Either env variables %s and %s set. Will return an empty string.", CON.ClusterIDEnv, CON.RhcsClusterProfileENV)
return ""
return "", nil
}
profile := LoadProfileYamlFileByENV()
if profile.ManifestsDIR == "" {
profile.ManifestsDIR = CON.ROSAClassic
}
clusterService, err := EXE.NewClusterService(profile.ManifestsDIR)
Expect(err).ToNot(HaveOccurred())
if err != nil {
return "", err
}
clusterID, err := clusterService.Output()
Expect(err).ToNot(HaveOccurred())
return clusterID
return clusterID, err
}
11 changes: 8 additions & 3 deletions tests/e2e/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ var clusterID string

func TestRHCSProvider(t *testing.T) {
RegisterFailHandler(Fail)
token = os.Getenv(CON.TokenENVName)
clusterID = CI.PrepareRHCSClusterByProfileENV()
ctx = context.Background()
RunSpecs(t, "RHCS Provider Test")

}

var _ = BeforeSuite(func() {
token = os.Getenv(CON.TokenENVName)
var err error
clusterID, err = CI.PrepareRHCSClusterByProfileENV()
Expect(err).ToNot(HaveOccurred())
ctx = context.Background()
})
Loading