Skip to content

Commit

Permalink
[WIP] v1alpah2 e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
jadarsie committed Dec 10, 2019
1 parent ce38b44 commit 1567581
Show file tree
Hide file tree
Showing 25 changed files with 1,558 additions and 555 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ test-integration: ## Run integration tests
.PHONY: test-e2e
test-e2e: ## Run e2e tests
PULL_POLICY=IfNotPresent $(MAKE) docker-build
go test -v -tags=e2e -timeout=1h ./test/e2e/... -args --managerImage $(CONTROLLER_IMG)-$(ARCH):$(TAG)
MANAGER_IMAGE=$(CONTROLLER_IMG)-$(ARCH):$(TAG) \
go test ./test/e2e -v -tags=e2e -ginkgo.v -ginkgo.trace -count=1 -timeout=30m

$(KUBECTL) $(KUBE_APISERVER) $(ETCD): ## install test asset kubectl, kube-apiserver, etcd
source ./scripts/fetch_ext_bins.sh && fetch_tools
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ require (
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d // indirect
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/mock v1.2.0
github.com/google/uuid v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/json-iterator/go v1.1.7 // indirect
github.com/onsi/ginkgo v1.10.1
github.com/onsi/gomega v1.7.0
github.com/pelletier/go-toml v1.6.0
github.com/pkg/errors v0.8.1
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.4.0 // indirect
Expand All @@ -24,16 +26,19 @@ require (
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b
golang.org/x/sys v0.0.0-20190911201528-7ad0cfa0b7b5 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
k8s.io/api v0.0.0-20190918195907-bd6ac527cfd2
k8s.io/apimachinery v0.0.0-20190817020851-f2f3a405f61d
k8s.io/client-go v0.0.0-20190918200256-06eb1244587a
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf // indirect
k8s.io/utils v0.0.0-20190809000727-6c36bc71fc4a
sigs.k8s.io/cluster-api v0.2.7
sigs.k8s.io/cluster-api-bootstrap-provider-kubeadm v0.1.1
sigs.k8s.io/controller-runtime v0.3.0
)

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.2.0+incompatible
replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.2.0+incompatible
k8s.io/client-go => k8s.io/client-go v0.0.0-20190918200256-06eb1244587a
)
64 changes: 53 additions & 11 deletions go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion go.vendor

This file was deleted.

2 changes: 1 addition & 1 deletion hack/ensure-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -o nounset
set -o pipefail

GOPATH_BIN="$(go env GOPATH)/bin/"
MINIMUM_KIND_VERSION=v0.4.0
MINIMUM_KIND_VERSION=v0.5.1

# Ensure the kind tool exists and is a viable version, or installs it
verify_kind_version() {
Expand Down
54 changes: 54 additions & 0 deletions hack/ensure-kustomize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# Copyright 2019 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.

set -o errexit
set -o nounset
set -o pipefail

GOPATH_BIN="$(go env GOPATH)/bin/"
MINIMUM_KUSTOMIZE_VERSION=3.1.0

# Ensure the kustomize tool exists and is a viable version, or installs it
verify_kustomize_version() {

# If kustomize is not available on the path, get it
if ! [ -x "$(command -v kustomize)" ]; then
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
echo 'kustomize not found, installing'
if ! [ -d "${GOPATH_BIN}" ]; then
mkdir -p "${GOPATH_BIN}"
fi
curl -sLo "${GOPATH_BIN}/kustomize" https://github.com/kubernetes-sigs/kustomize/releases/download/v${MINIMUM_KUSTOMIZE_VERSION}/kustomize_${MINIMUM_KUSTOMIZE_VERSION}_linux_amd64
chmod +x "${GOPATH_BIN}/kustomize"
else
echo "Missing required binary in path: kustomize"
return 2
fi
fi

local kustomize_version
kustomize_version=$(kustomize version)
if [[ "${MINIMUM_KUSTOMIZE_VERSION}" != $(echo -e "${MINIMUM_KUSTOMIZE_VERSION}\n${kustomize_version}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) ]]; then
cat <<EOF
Detected kustomize version: ${kustomize_version}.
Requires ${MINIMUM_KUSTOMIZE_VERSION} or greater.
Please install ${MINIMUM_KUSTOMIZE_VERSION} or later.
EOF
return 2
fi
}

verify_kustomize_version
29 changes: 25 additions & 4 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,31 @@
# 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 AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID

set -o nounset
set -o pipefail

# This script is part of the e2e effort. Current plan is to:
# - Merge dummy ci-e2e script
# - Create a prow presubmit that calls the dummy script
# - Fill in the ci-e2e along with the e2e PR
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"

export REGISTRY=e2e

make test-e2e
test_status="${?}"

# TODO last chance to clean up resources if prow job leaves something behind

exit "${test_status}"
66 changes: 66 additions & 0 deletions test/e2e/auth/creds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2019 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 auth

import (
"fmt"
"io/ioutil"
"os"

"github.com/pelletier/go-toml"
)

// Config stores the auth info
type Config struct {
Creds
}

// Creds stores the auth info
type Creds struct {
ClientID string
ClientSecret string
TenantID string
SubscriptionID string
StorageAccountName string
StorageAccountKey string
}

// LoadFromFile loads auth info from the input file path
// This was mostly copied from the test-infra repo
func LoadFromFile(credsFile string) (Creds, error) {
fmt.Printf("Loading credentials from file %v\n", credsFile)
content, err := ioutil.ReadFile(credsFile)
if err != nil {
return Creds{}, fmt.Errorf("error reading credentials file %v %v", credsFile, err)
}
config := Config{}
if err = toml.Unmarshal(content, &config); err != nil {
return Creds{}, fmt.Errorf("error parsing credentials file %v %v", credsFile, err)
}
return config.Creds, nil
}

// LoadFromEnvironment loads auth info from the environment
func LoadFromEnvironment() (Creds, error) {
fmt.Print("Loading credentials from environment\n")
return Creds{
TenantID: os.Getenv("AZURE_TENANT_ID"),
SubscriptionID: os.Getenv("AZURE_SUBSCRIPTION_ID"),
ClientID: os.Getenv("AZURE_CLIENT_ID"),
ClientSecret: os.Getenv("AZURE_CLIENT_SECRET"),
}, nil
}
Loading

0 comments on commit 1567581

Please sign in to comment.