-
Notifications
You must be signed in to change notification settings - Fork 42
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
8 changed files
with
231 additions
and
4 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
File renamed without changes.
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,78 @@ | ||
#!/bin/bash | ||
|
||
# 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. | ||
|
||
############################################################################### | ||
|
||
# This script is executed by presubmit `pull-cluster-api-provider-azure-e2e` | ||
# To run locally, set PACKET_API_KEY, PROJECT_ID, `` | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
cd "${REPO_ROOT}" || exit 1 | ||
|
||
# shellcheck source=../hack/ensure-go.sh | ||
source "${REPO_ROOT}/hack/ensure-go.sh" | ||
# shellcheck source=../hack/ensure-kind.sh | ||
source "${REPO_ROOT}/hack/ensure-kind.sh" | ||
# shellcheck source=../hack/ensure-kubectl.sh | ||
source "${REPO_ROOT}/hack/ensure-kubectl.sh" | ||
# shellcheck source=../hack/ensure-kustomize.sh | ||
source "${REPO_ROOT}/hack/ensure-kustomize.sh" | ||
# shellcheck source=../hack/ensure-packet-cli.sh | ||
source "${REPO_ROOT}/hack/ensure-packet-cli.sh" | ||
|
||
# Verify the required Environment Variables are present. | ||
: "${PACKET_API_KEY:?Environment variable empty or not defined.}" | ||
: "${PROJECT_ID:?Environment variable empty or not defined.}" | ||
|
||
get_random_facility() { | ||
# local FACILITIES=("sjc1" "lax1" "ams1" "dfw2" "ewr1" "ny5") | ||
local FACILITIES=("ewr1") | ||
echo "${FACILITIES[${RANDOM} % ${#FACILITIES[@]}]}" | ||
} | ||
|
||
export GINKGO_NODES=3 | ||
export FACILITY="${FACILITY:-$(get_random_facility)}" | ||
export PACKET_TOKEN=${PACKET_API_KEY} | ||
|
||
export SSH_KEY_NAME=capp-e2e-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '') | ||
export SSH_KEY_PATH=/tmp/${SSH_KEY_NAME} | ||
export SSH_KEY_UUID="" | ||
create_ssh_key() { | ||
echo "generating new ssh key" | ||
ssh-keygen -t rsa -f ${SSH_KEY_PATH} -N '' 2>/dev/null <<< y >/dev/null | ||
echo "importing ssh key " | ||
SSH_KEY_STRING=$(cat ${SSH_KEY_PATH}.pub) | ||
SSH_KEY_UUID=$(packet ssh-key create --key "${SSH_KEY_STRING}" --label "${SSH_KEY_NAME}" --json | jq -r '.id') | ||
} | ||
|
||
cleanup() { | ||
echo "removing ssh key" | ||
packet ssh-key delete --id ${SSH_KEY_UUID} --force || true | ||
rm -f ${SSH_KEY_PATH} || true | ||
|
||
${REPO_ROOT}/hack/log/redact.sh || true | ||
} | ||
|
||
create_ssh_key | ||
trap cleanup EXIT | ||
|
||
export SSH_KEY=${SSH_KEY_NAME} | ||
make conformance | ||
test_status="${?}" |
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,117 @@ | ||
// +build e2e | ||
|
||
/* | ||
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" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/utils/pointer" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" | ||
capi_e2e "sigs.k8s.io/cluster-api/test/e2e" | ||
"sigs.k8s.io/cluster-api/test/framework/clusterctl" | ||
"sigs.k8s.io/cluster-api/test/framework/kubetest" | ||
"sigs.k8s.io/cluster-api/util" | ||
) | ||
|
||
var _ = Describe("Conformance Tests", func() { | ||
var ( | ||
ctx = context.TODO() | ||
specName = "conformance-tests" | ||
namespace *corev1.Namespace | ||
cancelWatches context.CancelFunc | ||
cluster *clusterv1.Cluster | ||
clusterName string | ||
clusterctlLogFolder string | ||
) | ||
|
||
BeforeEach(func() { | ||
Expect(e2eConfig).ToNot(BeNil(), "Invalid argument. e2eConfig can't be nil when calling %s spec", specName) | ||
Expect(clusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. clusterctlConfigPath must be an existing file when calling %s spec", specName) | ||
Expect(bootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. bootstrapClusterProxy can't be nil when calling %s spec", specName) | ||
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid argument. artifactFolder can't be created for %s spec", specName) | ||
Expect(kubetestConfigFilePath).ToNot(BeNil(), "Invalid argument. kubetestConfigFilePath can't be nil") | ||
|
||
Expect(e2eConfig.Variables).To(HaveKey(capi_e2e.KubernetesVersion)) | ||
Expect(e2eConfig.Variables).To(HaveKey(capi_e2e.CNIPath)) | ||
|
||
clusterName = fmt.Sprintf("capp-conf-%s", util.RandomString(6)) | ||
|
||
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events. | ||
namespace, cancelWatches = setupSpecNamespace(ctx, specName, bootstrapClusterProxy, artifactFolder) | ||
|
||
// We need to override clusterctl apply log folder to avoid getting our credentials exposed. | ||
clusterctlLogFolder = filepath.Join(os.TempDir(), "clusters", bootstrapClusterProxy.GetName()) | ||
}) | ||
|
||
Measure(specName, func(b Benchmarker) { | ||
var err error | ||
|
||
workerMachineCount, err := strconv.ParseInt(e2eConfig.GetVariable("CONFORMANCE_WORKER_MACHINE_COUNT"), 10, 64) | ||
Expect(err).NotTo(HaveOccurred()) | ||
controlPlaneMachineCount, err := strconv.ParseInt(e2eConfig.GetVariable("CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT"), 10, 64) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
runtime := b.Time("cluster creation", func() { | ||
result := clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ | ||
ClusterProxy: bootstrapClusterProxy, | ||
ConfigCluster: clusterctl.ConfigClusterInput{ | ||
LogFolder: clusterctlLogFolder, | ||
ClusterctlConfigPath: clusterctlConfigPath, | ||
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(), | ||
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider, | ||
Flavor: clusterctl.DefaultFlavor, | ||
Namespace: namespace.Name, | ||
ClusterName: clusterName, | ||
KubernetesVersion: e2eConfig.GetVariable(capi_e2e.KubernetesVersion), | ||
ControlPlaneMachineCount: pointer.Int64Ptr(controlPlaneMachineCount), | ||
WorkerMachineCount: pointer.Int64Ptr(workerMachineCount), | ||
}, | ||
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"), | ||
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"), | ||
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), | ||
}) | ||
|
||
cluster = result.Cluster | ||
}) | ||
|
||
b.RecordValue("cluster creation", runtime.Seconds()) | ||
workloadProxy := bootstrapClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterName) | ||
runtime = b.Time("conformance suite", func() { | ||
kubetest.Run( | ||
kubetest.RunInput{ | ||
ClusterProxy: workloadProxy, | ||
NumberOfNodes: int(workerMachineCount), | ||
ConfigFilePath: kubetestConfigFilePath, | ||
}, | ||
) | ||
}) | ||
b.RecordValue("conformance suite run time", runtime.Seconds()) | ||
}, 1) | ||
|
||
AfterEach(func() { | ||
dumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, artifactFolder, namespace, cancelWatches, cluster, e2eConfig.GetIntervals, clusterName, clusterctlLogFolder, skipCleanup) | ||
}) | ||
}) |
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,7 @@ | ||
ginkgo.focus: \[Conformance\] | ||
disable-log-dump: true | ||
ginkgo.progress: true | ||
ginkgo.slowSpecThreshold: 120.0 | ||
ginkgo.flakeAttempts: 3 | ||
ginkgo.trace: true | ||
ginkgo.v: true |
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