-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
879 additions
and
10 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# E2E Test | ||
|
||
This document is to help developers understand how to run e2e test CAPDO. | ||
|
||
## Requirements | ||
|
||
In order to run the e2e tests the following requirements must be met: | ||
|
||
* Ginkgo | ||
* Docker | ||
* Kind v0.6.0+ (*Kind v0.7.0+ not working due upstream dependencies*) | ||
|
||
### Environment variables | ||
|
||
The first step to running the e2e tests is setting up the required environment variables: | ||
|
||
| Environment variable | Description | | ||
| ----------------------------- | ----------------------------------------------------------------------------------------------------- | | ||
| `DIGITALOCEAN_ACCESS_TOKEN` | The DigitalOcean API V2 access token | | ||
| `MACHINE_TYPE` | The DigitalOcean Droplet size | | ||
| `MACHINE_IMAGE` | The DigitalOcean Image id or slug | | ||
| `MACHINE_SSHKEY` | The ssh key id or fingerprint (Should already registered in the DigitalOcean Account) | | ||
|
||
### Running e2e test | ||
|
||
In the root project directory run: | ||
|
||
``` | ||
make test-e2e | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"io/ioutil" | ||
"path" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"sigs.k8s.io/cluster-api/util" | ||
"sigs.k8s.io/cluster-api/util/kubeconfig" | ||
) | ||
|
||
var _ = Describe("CAPDO", func() { | ||
Describe("Cluster lifecycle", func() { | ||
var ( | ||
clusterName string | ||
clusterNamespace string | ||
clusterGenenerator ClusterGenerator | ||
machineGenerator MachineGenerator | ||
) | ||
|
||
BeforeEach(func() { | ||
var err error | ||
clusterName = "capdo-test-" + util.RandomString(6) | ||
clusterNamespace = "default" | ||
|
||
testTmpDir, err = ioutil.TempDir(suiteTmpDir, "e2e-test") | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
Context("Single control plane with one worker node", func() { | ||
It("It should be creatable and deletable", func() { | ||
cluster, docluster := clusterGenenerator.Generate(clusterNamespace, clusterName) | ||
By("Creating a Cluster") | ||
Expect(kindclient.Create(context.TODO(), cluster)).To(Succeed()) | ||
|
||
By("Creating a DOCluster") | ||
Expect(kindclient.Create(context.TODO(), docluster)).To(Succeed()) | ||
|
||
By("Ensuring Cluster Infrastructure is Ready") | ||
WaitForClusterInfrastructureReady(kindclient, cluster.Namespace, cluster.Name) | ||
|
||
By("Creating a single controlplane") | ||
controlPlaneMachine, controlPlaneKubeadmconfig, controlPlaneDomachine := machineGenerator.Generate(clusterNamespace, clusterName, true) | ||
By("Creating a Controlplane KubeadmConfig") | ||
Expect(kindclient.Create(context.TODO(), controlPlaneKubeadmconfig)).To(Succeed()) | ||
|
||
By("Creating a Controlplane DOMachine") | ||
Expect(kindclient.Create(context.TODO(), controlPlaneDomachine)).To(Succeed()) | ||
|
||
By("Creating a Controlplane Machine") | ||
Expect(kindclient.Create(context.TODO(), controlPlaneMachine)).To(Succeed()) | ||
|
||
By("Ensuring Controlplane Machine Bootstrap is Ready") | ||
WaitForMachineBootstrapReady(kindclient, controlPlaneMachine.Namespace, controlPlaneMachine.Name) | ||
|
||
By("Ensuring Controlplane DOMachine is Running") | ||
WaitForDOMachineRunning(kindclient, controlPlaneDomachine.Namespace, controlPlaneDomachine.Name) | ||
|
||
By("Ensuring Controlplane DOMachine is Ready") | ||
WaitForDOMachineReady(kindclient, controlPlaneDomachine.Namespace, controlPlaneDomachine.Name) | ||
|
||
By("Ensuring Controlplane MachineNodeRef") | ||
WaitForMachineNodeRef(kindclient, controlPlaneMachine.Namespace, controlPlaneMachine.Name) | ||
|
||
By("Ensuring Cluster Controlplane Initialized") | ||
WaitForClusterControlplaneInitialized(kindclient, cluster.Namespace, cluster.Name) | ||
|
||
By("Exporting Cluster kubeconfig") | ||
kubeConfigData, err := kubeconfig.FromSecret(kindclient, cluster) | ||
Expect(err).NotTo(HaveOccurred()) | ||
kubeConfigPath := path.Join(testTmpDir, clusterName+".kubeconfig") | ||
Expect(ioutil.WriteFile(kubeConfigPath, kubeConfigData, 0640)).To(Succeed()) | ||
|
||
By("Deploying CNI") | ||
ApplyYaml(kubeConfigPath, "https://docs.projectcalico.org/manifests/calico.yaml") | ||
|
||
By("Deploying Cloud Controller Manager") | ||
var ccmManifest string | ||
buildCloudControllerManager(&ccmManifest) | ||
ApplyYaml(kubeConfigPath, ccmManifest) | ||
|
||
By("Create one worker") | ||
workerMachine, workerKubeadmconfig, workerDomachine := machineGenerator.Generate(clusterNamespace, clusterName, false) | ||
By("Creating a Worker KubeadmConfig") | ||
Expect(kindclient.Create(context.TODO(), workerKubeadmconfig)).To(Succeed()) | ||
|
||
By("Creating a Worker DOMachine") | ||
Expect(kindclient.Create(context.TODO(), workerDomachine)).To(Succeed()) | ||
|
||
By("Creating a Worker Machine") | ||
Expect(kindclient.Create(context.TODO(), workerMachine)).To(Succeed()) | ||
|
||
By("Ensuring Worker Machine Bootstrap is Ready") | ||
WaitForMachineBootstrapReady(kindclient, workerMachine.Namespace, workerMachine.Name) | ||
|
||
By("Ensuring Worker DOMachine is Running") | ||
WaitForDOMachineRunning(kindclient, workerDomachine.Namespace, workerDomachine.Name) | ||
|
||
By("Ensuring Worker DOMachine is Ready") | ||
WaitForDOMachineReady(kindclient, workerDomachine.Namespace, workerDomachine.Name) | ||
|
||
By("Ensuring Worker MachineNodeRef") | ||
WaitForMachineNodeRef(kindclient, workerMachine.Namespace, workerMachine.Name) | ||
|
||
By("Deleting a Worker KubeadmConfig") | ||
Expect(kindclient.Delete(context.TODO(), workerKubeadmconfig)).To(Succeed()) | ||
WaitForDeletion(kindclient, workerKubeadmconfig, workerKubeadmconfig.Namespace, workerKubeadmconfig.Name) | ||
|
||
By("Deleting a Worker DOMachine") | ||
Expect(kindclient.Delete(context.TODO(), workerDomachine)).To(Succeed()) | ||
WaitForDeletion(kindclient, workerDomachine, workerDomachine.Namespace, workerDomachine.Name) | ||
|
||
By("Deleting a Worker Machine") | ||
Expect(kindclient.Delete(context.TODO(), workerMachine)).To(Succeed()) | ||
WaitForDeletion(kindclient, workerMachine, workerMachine.Namespace, workerMachine.Name) | ||
|
||
By("Deleting a Controlplane KubeadmConfig") | ||
Expect(kindclient.Delete(context.TODO(), controlPlaneKubeadmconfig)).To(Succeed()) | ||
WaitForDeletion(kindclient, controlPlaneKubeadmconfig, controlPlaneKubeadmconfig.Namespace, controlPlaneKubeadmconfig.Name) | ||
|
||
By("Deleting a Controlplane DOMachine") | ||
Expect(kindclient.Delete(context.TODO(), controlPlaneDomachine)).To(Succeed()) | ||
WaitForDeletion(kindclient, controlPlaneDomachine, controlPlaneDomachine.Namespace, controlPlaneDomachine.Name) | ||
|
||
By("Deleting a Controlplane Machine") | ||
Expect(kindclient.Delete(context.TODO(), controlPlaneMachine)).To(Succeed()) | ||
WaitForDeletion(kindclient, controlPlaneMachine, controlPlaneMachine.Namespace, controlPlaneMachine.Name) | ||
|
||
By("Deleting a DOCluster") | ||
Expect(kindclient.Delete(context.TODO(), docluster)).To(Succeed()) | ||
WaitForDeletion(kindclient, docluster, docluster.Namespace, docluster.Name) | ||
|
||
By("Deleting a Cluster") | ||
Expect(kindclient.Delete(context.TODO(), cluster)).To(Succeed()) | ||
WaitForDeletion(kindclient, cluster, cluster.Namespace, cluster.Name) | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.