Skip to content

Commit 2a4a1a3

Browse files
Improve logging in e2e tests
Signed-off-by: Muhammad Adil Ghaffar <[email protected]>
1 parent 69c9cae commit 2a4a1a3

File tree

5 files changed

+39
-90
lines changed

5 files changed

+39
-90
lines changed

scripts/fetch_manifests.sh

Lines changed: 0 additions & 61 deletions
This file was deleted.

test/e2e/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func DumpSpecResourcesAndCleanup(ctx context.Context, specName string, bootstrap
142142
bootstrapClusterProxy.CollectWorkloadClusterLogs(ctx, namespace, clusterName, artifactFolder)
143143

144144
By("Fetch logs from target cluster")
145-
err := FetchClusterLogs(targetClusterProxy, clusterLogCollectionBasePath)
145+
err := FetchClusterLogs(targetClusterProxy, targetClusterLogCollectionBasePath)
146146
if err != nil {
147147
Logf("Error: %v", err)
148148
}

test/e2e/logcollector.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func FetchManifests(clusterProxy framework.ClusterProxy, outputPath string) erro
159159
"m3data",
160160
"m3dataclaim",
161161
"m3datatemplate",
162+
"ironic",
162163
}
163164
client := clusterProxy.GetClient()
164165

test/e2e/pivoting.go

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
. "github.com/onsi/gomega"
1717
corev1 "k8s.io/api/core/v1"
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19-
"k8s.io/apimachinery/pkg/runtime"
2019
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2120
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
2221
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/config"
@@ -26,17 +25,18 @@ import (
2625
)
2726

2827
const (
29-
bmoPath = "BMOPATH"
30-
ironicTLSSetup = "IRONIC_TLS_SETUP"
31-
ironicBasicAuth = "IRONIC_BASIC_AUTH"
32-
ironicKeepalived = "IRONIC_KEEPALIVED"
33-
ironicMariadb = "IRONIC_USE_MARIADB"
34-
Kind = "kind"
35-
NamePrefix = "NAMEPREFIX"
36-
restartContainerCertUpdate = "RESTART_CONTAINER_CERTIFICATE_UPDATED"
37-
ironicNamespace = "IRONIC_NAMESPACE"
38-
clusterLogCollectionBasePath = "/tmp/target_cluster_logs"
39-
Metal3ipamProviderName = "metal3"
28+
bmoPath = "BMOPATH"
29+
ironicTLSSetup = "IRONIC_TLS_SETUP"
30+
ironicBasicAuth = "IRONIC_BASIC_AUTH"
31+
ironicKeepalived = "IRONIC_KEEPALIVED"
32+
ironicMariadb = "IRONIC_USE_MARIADB"
33+
Kind = "kind"
34+
NamePrefix = "NAMEPREFIX"
35+
restartContainerCertUpdate = "RESTART_CONTAINER_CERTIFICATE_UPDATED"
36+
ironicNamespace = "IRONIC_NAMESPACE"
37+
targetClusterLogCollectionBasePath = "/tmp/target_cluster_logs"
38+
managementClusterLogCollectionBasePath = "/tmp/management_cluster_logs"
39+
Metal3ipamProviderName = "metal3"
4040
)
4141

4242
type PivotingInput struct {
@@ -64,7 +64,7 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
6464
ListNodes(ctx, input.TargetCluster.GetClient())
6565

6666
By("Fetch logs from target cluster before pivot")
67-
err := FetchClusterLogs(input.TargetCluster, filepath.Join(clusterLogCollectionBasePath, "beforePivot"))
67+
err := FetchClusterLogs(input.TargetCluster, filepath.Join(targetClusterLogCollectionBasePath, "beforePivot"))
6868
if err != nil {
6969
Logf("Error: %v", err)
7070
}
@@ -83,17 +83,20 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
8383
}
8484

8585
By("Fetch container logs")
86-
bootstrapCluster := os.Getenv("BOOTSTRAP_CLUSTER")
8786
fetchContainerLogs(&generalContainers, input.ArtifactFolder, input.E2EConfig.MustGetVariable("CONTAINER_RUNTIME"))
88-
if bootstrapCluster == Kind {
87+
if input.BootstrapClusterProxy.GetName() == Kind {
8988
fetchContainerLogs(&ironicContainers, input.ArtifactFolder, input.E2EConfig.MustGetVariable("CONTAINER_RUNTIME"))
9089
}
9190

9291
By("Fetch manifest for bootstrap cluster before pivot")
93-
err = FetchManifests(input.BootstrapClusterProxy, "/tmp/manifests/")
92+
err = FetchManifests(input.BootstrapClusterProxy, filepath.Join(managementClusterLogCollectionBasePath, "beforePivot", "manifests"))
9493
if err != nil {
9594
Logf("Error fetching manifests for bootstrap cluster before pivot: %v", err)
9695
}
96+
err = FetchManifests(input.TargetCluster, filepath.Join(targetClusterLogCollectionBasePath, "beforePivot", "manifests"))
97+
if err != nil {
98+
Logf("Error fetching manifests for Target cluster before pivot: %v", err)
99+
}
97100
By("Fetch target cluster kubeconfig for target cluster log collection")
98101
kconfigPathWorkload := input.TargetCluster.GetKubeconfigPath()
99102
os.Setenv("KUBECONFIG_WORKLOAD", kconfigPathWorkload)
@@ -109,7 +112,7 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
109112

110113
By("Remove Ironic containers from the source cluster")
111114
ironicDeploymentType := IronicDeploymentTypeBMO
112-
if bootstrapCluster == Kind {
115+
if input.BootstrapClusterProxy.GetName() == Kind {
113116
ironicDeploymentType = IronicDeploymentTypeLocal
114117
} else if GetBoolVariable(input.E2EConfig, "USE_IRSO") {
115118
ironicDeploymentType = IronicDeploymentTypeIrSO
@@ -368,18 +371,20 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
368371
numberOfAllBmh := numberOfWorkers + numberOfControlplane
369372

370373
By("Fetch logs from target cluster after pivot")
371-
err := FetchClusterLogs(input.TargetCluster, filepath.Join(clusterLogCollectionBasePath, "afterPivot"))
374+
err := FetchClusterLogs(input.TargetCluster, filepath.Join(targetClusterLogCollectionBasePath, "afterPivot"))
372375
if err != nil {
373376
Logf("Error: %v", err)
374377
}
375378

376379
By("Fetch manifest for workload cluster after pivot")
377-
workloadClusterProxy := framework.NewClusterProxy("workload-cluster-after-pivot", os.Getenv("KUBECONFIG"), runtime.NewScheme())
378-
err = FetchManifests(workloadClusterProxy, "/tmp/manifests/")
380+
err = FetchManifests(input.TargetCluster, filepath.Join(targetClusterLogCollectionBasePath, "afterPivot", "manifests"))
379381
if err != nil {
380382
Logf("Error fetching manifests for workload cluster after pivot: %v", err)
381383
}
382-
os.Unsetenv("KUBECONFIG_WORKLOAD")
384+
err = FetchManifests(input.BootstrapClusterProxy, filepath.Join(managementClusterLogCollectionBasePath, "afterPivot", "manifests"))
385+
if err != nil {
386+
Logf("Error fetching manifests for bootstrap cluster before pivot: %v", err)
387+
}
383388

384389
By("Remove Ironic deployment from target cluster")
385390
ironicDeploymentType := IronicDeploymentTypeBMO
@@ -497,7 +502,11 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
497502
})
498503

499504
By("Fetch manifest for bootstrap cluster after re-pivot")
500-
err = FetchManifests(input.BootstrapClusterProxy, "/tmp/manifests/")
505+
err = FetchManifests(input.TargetCluster, filepath.Join(targetClusterLogCollectionBasePath, "afterRePivot", "manifests"))
506+
if err != nil {
507+
Logf("Error fetching manifests for workload cluster after pivot: %v", err)
508+
}
509+
err = FetchManifests(input.BootstrapClusterProxy, filepath.Join(managementClusterLogCollectionBasePath, "afterRePivot", "manifests"))
501510
if err != nil {
502511
Logf("Error fetching manifests for bootstrap cluster before pivot: %v", err)
503512
}

test/e2e/upgrade_clusterctl_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func preInitFunc(clusterProxy framework.ClusterProxy, bmoRelease string, ironicR
333333
bmoIronicNamespace := e2eConfig.MustGetVariable(ironicNamespace)
334334
// install ironic
335335
By("Install Ironic in the target cluster")
336-
ironicDeployLogFolder := filepath.Join(clusterLogCollectionBasePath, clusterProxy.GetName(), "ironic-deploy-logs")
336+
ironicDeployLogFolder := filepath.Join(targetClusterLogCollectionBasePath, clusterProxy.GetName(), "ironic-deploy-logs")
337337
ironicKustomizePath := "IRONIC_RELEASE_" + ironicRelease
338338
initIronicKustomization := e2eConfig.MustGetVariable(ironicKustomizePath)
339339
By(fmt.Sprintf("Installing Ironic from kustomization %s on the upgrade cluster", initIronicKustomization))
@@ -351,7 +351,7 @@ func preInitFunc(clusterProxy framework.ClusterProxy, bmoRelease string, ironicR
351351

352352
// install bmo
353353
By("Install BMO in the target cluster")
354-
bmoDeployLogFolder := filepath.Join(clusterLogCollectionBasePath, clusterProxy.GetName(), "bmo-deploy-logs")
354+
bmoDeployLogFolder := filepath.Join(targetClusterLogCollectionBasePath, clusterProxy.GetName(), "bmo-deploy-logs")
355355
bmoKustomizePath := "BMO_RELEASE_" + bmoRelease
356356
initBMOKustomization := e2eConfig.MustGetVariable(bmoKustomizePath)
357357
By(fmt.Sprintf("Installing BMO from kustomization %s on the upgrade cluster", initBMOKustomization))
@@ -396,7 +396,7 @@ func preUpgrade(clusterProxy framework.ClusterProxy, bmoUpgradeToRelease string,
396396

397397
bmoIronicNamespace := e2eConfig.MustGetVariable(ironicNamespace)
398398
By("Upgrade Ironic in the target cluster")
399-
ironicDeployLogFolder := filepath.Join(clusterLogCollectionBasePath, clusterProxy.GetName(), "ironic-deploy-logs")
399+
ironicDeployLogFolder := filepath.Join(targetClusterLogCollectionBasePath, clusterProxy.GetName(), "ironic-deploy-logs")
400400
ironicKustomizePath := "IRONIC_RELEASE_" + ironicTag
401401
initIronicKustomization := e2eConfig.MustGetVariable(ironicKustomizePath)
402402
By(fmt.Sprintf("Upgrading Ironic from kustomization %s on the upgrade cluster", initIronicKustomization))
@@ -414,7 +414,7 @@ func preUpgrade(clusterProxy framework.ClusterProxy, bmoUpgradeToRelease string,
414414

415415
// install bmo
416416
By("Upgrade BMO in the target cluster")
417-
bmoDeployLogFolder := filepath.Join(clusterLogCollectionBasePath, clusterProxy.GetName(), "bmo-deploy-logs")
417+
bmoDeployLogFolder := filepath.Join(targetClusterLogCollectionBasePath, clusterProxy.GetName(), "bmo-deploy-logs")
418418
bmoKustomizePath := "BMO_RELEASE_" + bmoTag
419419
initBMOKustomization := e2eConfig.MustGetVariable(bmoKustomizePath)
420420
By(fmt.Sprintf("Upgrading BMO from kustomization %s on the upgrade cluster", initBMOKustomization))
@@ -435,7 +435,7 @@ func preUpgrade(clusterProxy framework.ClusterProxy, bmoUpgradeToRelease string,
435435
// when upgrading from CAPM3 bundled IPAM.
436436
func postUpgrade(managementClusterProxy framework.ClusterProxy, _ string, _ string) {
437437
By("Installing Metal3 IPAM provider")
438-
ipamDeployLogFolder := filepath.Join(clusterLogCollectionBasePath, managementClusterProxy.GetName(), "ipam-deploy-logs")
438+
ipamDeployLogFolder := filepath.Join(targetClusterLogCollectionBasePath, managementClusterProxy.GetName(), "ipam-deploy-logs")
439439
ipamVersions := e2eConfig.GetProviderLatestVersionsByContract(capm3Contract, e2eConfig.IPAMProviders()...)
440440
Expect(ipamVersions).To(HaveLen(1), "Failed to get the latest version for the IPAM provider")
441441
input := clusterctl.InitInput{
@@ -451,7 +451,7 @@ func postUpgrade(managementClusterProxy framework.ClusterProxy, _ string, _ stri
451451
// it moves back Ironic to the bootstrap cluster.
452452
func preCleanupManagementCluster(clusterProxy framework.ClusterProxy, ironicRelease string) {
453453
By("Fetch logs from target cluster")
454-
err := FetchClusterLogs(clusterProxy, clusterLogCollectionBasePath)
454+
err := FetchClusterLogs(clusterProxy, targetClusterLogCollectionBasePath)
455455
if err != nil {
456456
Logf("Error: %v", err)
457457
}

0 commit comments

Comments
 (0)