Skip to content

Commit

Permalink
🌱 Fixed e2e tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
guettli committed Jan 18, 2024
1 parent 8cf7a01 commit 9a0ddb5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/e2e/caphv.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package e2e
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"runtime/trace"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
Expand Down Expand Up @@ -60,7 +62,7 @@ func CaphvClusterDeploymentSpec(ctx context.Context, inputGetter func() CaphvClu
gomega.Expect(input.E2EConfig).ToNot(gomega.BeNil(), "Invalid argument. input.E2EConfig can't be nil when calling %s spec", specName)
gomega.Expect(input.ClusterctlConfigPath).To(gomega.BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName)
gomega.Expect(input.BootstrapClusterProxy).ToNot(gomega.BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName)
gomega.Expect(os.MkdirAll(input.ArtifactFolder, 0750)).To(gomega.Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName)
gomega.Expect(os.MkdirAll(input.ArtifactFolder, 0o750)).To(gomega.Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName)
gomega.Expect(input.E2EConfig.Variables).To(gomega.HaveKey(KubernetesVersion))
gomega.Expect(input.E2EConfig.Variables).To(gomega.HaveKey(HivelocityRegion))
gomega.Expect(input.E2EConfig.Variables).To(HaveValidVersion(input.E2EConfig.GetVariable(KubernetesVersion)))
Expand All @@ -74,6 +76,14 @@ func CaphvClusterDeploymentSpec(ctx context.Context, inputGetter func() CaphvClu
clusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6))
})

traceFile := filepath.Join(input.ArtifactFolder, "trace.out")
f, err := os.Create(traceFile)
if err != nil {
log.Fatal("could not open file for tracing output: ", err)
}
if err := trace.Start(f); err != nil {
log.Fatal("could not start trace: ", err)
}
ginkgo.It("Should successfully create a cluster with control planes and worker machines", func() {
ginkgo.By(fmt.Sprintf("Creating a cluster: %d control-planes %d worker", input.ControlPlaneMachineCount,
input.WorkerMachineCount))
Expand All @@ -98,7 +108,9 @@ func CaphvClusterDeploymentSpec(ctx context.Context, inputGetter func() CaphvClu

ginkgo.By("PASSED!")
})

trace.Stop()
fmt.Printf("Created trace file ----------------- %s\n", traceFile)
f.Close()
ginkgo.AfterEach(func() {
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
dumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
Expand Down

0 comments on commit 9a0ddb5

Please sign in to comment.