-
Notifications
You must be signed in to change notification settings - Fork 96
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
🌱Add log and manifest collection for clusterctl upgrade test #1124
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package e2e | |
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
|
@@ -49,6 +50,7 @@ var _ = Describe(fmt.Sprintf("When testing cluster upgrade from releases %s > cu | |
// Override capi/capm3 versions exported in preInit | ||
os.Setenv("CAPI_VERSION", "v1beta1") | ||
os.Setenv("CAPM3_VERSION", "v1beta1") | ||
os.Setenv("KUBECONFIG_BOOTSTRAP", bootstrapClusterProxy.GetKubeconfigPath()) | ||
}, | ||
PreWaitForCluster: preWaitForCluster, | ||
PreUpgrade: preUpgrade, | ||
|
@@ -197,6 +199,21 @@ func preInitFunc(clusterProxy framework.ClusterProxy) { | |
Expect(clusterProxy.Apply(ctx, certManagerYaml)).ShouldNot(HaveOccurred()) | ||
} | ||
|
||
By("Fetch manifest for bootstrap cluster") | ||
path := filepath.Join(os.Getenv("CAPM3PATH"), "scripts") | ||
cmd := exec.Command("./fetch_manifests.sh") // #nosec G204:gosec | ||
cmd.Dir = path | ||
_ = cmd.Run() | ||
|
||
By("Fetch target cluster kubeconfig for target cluster log collection") | ||
kconfigPathWorkload := clusterProxy.GetKubeconfigPath() | ||
os.Setenv("KUBECONFIG_WORKLOAD", kconfigPathWorkload) | ||
Logf("Save kubeconfig in temp folder for project-infra target log collection") | ||
kubeconfigPathTemp := "/tmp/kubeconfig-test1.yaml" | ||
cmd = exec.Command("cp", kconfigPathWorkload, kubeconfigPathTemp) // #nosec G204:gosec | ||
stdoutStderr, er := cmd.CombinedOutput() | ||
Logf("%s\n", stdoutStderr) | ||
Expect(er).To(BeNil(), "Cannot fetch target cluster kubeconfig") | ||
// install certmanager | ||
installCertManager(clusterProxy) | ||
// Remove ironic | ||
|
@@ -295,10 +312,36 @@ func preUpgrade(clusterProxy framework.ClusterProxy) { | |
func preCleanupManagementCluster(clusterProxy framework.ClusterProxy) { | ||
// Abort the test in case of failure and keepTestEnv is true during keep VM trigger | ||
if CurrentSpecReport().Failed() { | ||
// Fetch logs in case of failure in management cluster | ||
By("Fetch logs from management cluster") | ||
path := filepath.Join(os.Getenv("CAPM3PATH"), "scripts") | ||
cmd := exec.Command("./fetch_target_logs.sh") // #nosec G204:gosec | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
cmd.Dir = path | ||
errorPipe, _ := cmd.StderrPipe() | ||
_ = cmd.Start() | ||
errorData, _ := io.ReadAll(errorPipe) | ||
if len(errorData) > 0 { | ||
Logf("Error of the shell: %v\n", string(errorData)) | ||
} | ||
|
||
if keepTestEnv { | ||
AbortSuite("e2e test aborted and skip cleaning the VM", 4) | ||
} | ||
} | ||
// Fetch logs from management cluster | ||
By("Fetch logs from management cluster") | ||
path := filepath.Join(os.Getenv("CAPM3PATH"), "scripts") | ||
cmd := exec.Command("./fetch_target_logs.sh") // #nosec G204:gosec | ||
cmd.Dir = path | ||
errorPipe, _ := cmd.StderrPipe() | ||
_ = cmd.Start() | ||
errorData, _ := io.ReadAll(errorPipe) | ||
if len(errorData) > 0 { | ||
Logf("Error of the shell: %v\n", string(errorData)) | ||
} | ||
os.Unsetenv("KUBECONFIG_WORKLOAD") | ||
os.Unsetenv("KUBECONFIG_BOOTSTRAP") | ||
|
||
// Reinstall ironic | ||
reInstallIronic := func() { | ||
By("Reinstate Ironic containers and BMH") | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to avoid this invoking of shell inside go code? As you can see you have to ignore the gosec error and we are trying to get rid of such invocations from other places too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running of these script are part of e2e test and used the approach in different place of e2e tests. I think we need to check for a solution for that separately with new ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theres already ticket for that , I am concerned about adding new cases when old cases are being worked upon.