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 8db2547
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 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,7 +76,27 @@ 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() {
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)
}
defer f.Close()
if err := trace.Start(f); err != nil {
log.Fatal("could not start trace: ", err)
}
defer trace.Stop()
fmt.Printf("Created trace file ----------------- %s\n", traceFile)

ginkgo.By(fmt.Sprintf("Creating a cluster: %d control-planes %d worker", input.ControlPlaneMachineCount,
input.WorkerMachineCount))
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
Expand All @@ -98,7 +120,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
2 changes: 1 addition & 1 deletion test/e2e/config/hivelocity-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ intervals:
default/wait-cluster: ["5m", "10s"] ## wait until Infrastructure == ready and ControlPlaneEndpoint is valid
default/wait-control-plane: ["26m", "10s"] ## wait until first control plane is ready.
default/wait-worker-nodes: ["26m", "10s"] ## wait until all workers are ready from the moment when the control plane is ready
default/wait-delete-cluster: ["20m", "10s"] ## wait until cluster is deleted
default/wait-delete-cluster: ["5m", "10s"] ## wait until cluster is deleted

0 comments on commit 8db2547

Please sign in to comment.