|
| 1 | +//go:build e2e |
| 2 | + |
| 3 | +package e2e |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "fmt" |
| 8 | + |
| 9 | + "sigs.k8s.io/cluster-api/test/e2e" |
| 10 | + |
| 11 | + "github.com/neoaggelos/cluster-api-provider-lxc/internal/incus" |
| 12 | + "github.com/neoaggelos/cluster-api-provider-lxc/internal/ptr" |
| 13 | + "github.com/neoaggelos/cluster-api-provider-lxc/test/e2e/shared" |
| 14 | + |
| 15 | + . "github.com/onsi/ginkgo/v2" |
| 16 | + . "github.com/onsi/gomega" |
| 17 | +) |
| 18 | + |
| 19 | +var _ = Describe("QuickStart", func() { |
| 20 | + Context("KubeVIP", Label("PRBlocking"), func() { |
| 21 | + var ( |
| 22 | + clusterctlVariables map[string]string |
| 23 | + ) |
| 24 | + BeforeEach(func(ctx context.Context) { |
| 25 | + if v := e2eCtx.E2EConfig.GetVariableBestEffort(shared.KubeVIPAddress); v != "" { |
| 26 | + shared.Logf("Using kube-vip address %q (from environment variable KUBE_VIP_ADDRESS)", v) |
| 27 | + clusterctlVariables = map[string]string{ |
| 28 | + "LOAD_BALANCER": fmt.Sprintf("kube-vip: {host: %q}", v), |
| 29 | + } |
| 30 | + return |
| 31 | + } |
| 32 | + |
| 33 | + // KUBE_VIP_ADDRESS is not set, look for a network |
| 34 | + client, err := incus.New(ctx, e2eCtx.Settings.LXCClientOptions) |
| 35 | + Expect(err).ToNot(HaveOccurred()) |
| 36 | + networks, err := client.Client.GetNetworks() |
| 37 | + Expect(err).ToNot(HaveOccurred()) |
| 38 | + |
| 39 | + // find network with the annotations below |
| 40 | + // -- user.capl.e2e.kube-vip-address = "<ip address>" |
| 41 | + for _, network := range networks { |
| 42 | + if v, ok := network.Config["user.capl.e2e.kube-vip-address"]; ok { |
| 43 | + shared.Logf("Using kube-vip address %q (from network %q)", v, network.Name) |
| 44 | + clusterctlVariables = map[string]string{ |
| 45 | + "LOAD_BALANCER": fmt.Sprintf("kube-vip: {host: '%s'}", v), |
| 46 | + "CONTROL_PLANE_MACHINE_DEVICES": fmt.Sprintf("['eth0,type=nic,network=%s']", network.Name), |
| 47 | + "WORKER_MACHINE_DEVICES": fmt.Sprintf("['eth0,type=nic,network=%s']", network.Name), |
| 48 | + } |
| 49 | + return |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + Skip("Did not find any network with configuration 'user.capl.e2e.kube-vip-address', and KUBE_VIP_ADDRESS is not set") |
| 54 | + }) |
| 55 | + |
| 56 | + e2e.QuickStartSpec(context.TODO(), func() e2e.QuickStartSpecInput { |
| 57 | + return e2e.QuickStartSpecInput{ |
| 58 | + E2EConfig: e2eCtx.E2EConfig, |
| 59 | + ClusterctlConfigPath: e2eCtx.Environment.ClusterctlConfigPath, |
| 60 | + BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy, |
| 61 | + ArtifactFolder: e2eCtx.Settings.ArtifactFolder, |
| 62 | + SkipCleanup: e2eCtx.Settings.SkipCleanup, |
| 63 | + PostNamespaceCreated: e2eCtx.DefaultPostNamespaceCreated(), |
| 64 | + ControlPlaneWaiters: e2eCtx.DefaultControlPlaneWaiters(), |
| 65 | + InfrastructureProvider: ptr.To("lxc:v0.88.99"), |
| 66 | + |
| 67 | + Flavor: ptr.To(shared.FlavorDefault), |
| 68 | + ControlPlaneMachineCount: ptr.To[int64](3), |
| 69 | + WorkerMachineCount: ptr.To[int64](0), |
| 70 | + |
| 71 | + ClusterctlVariables: clusterctlVariables, |
| 72 | + } |
| 73 | + }) |
| 74 | + }) |
| 75 | +}) |
0 commit comments