Skip to content

Commit

Permalink
WIP: e2e scenario test: Build with workspace
Browse files Browse the repository at this point in the history
For discussion.
  • Loading branch information
justinsb committed Feb 26, 2023
1 parent 0e6d24b commit 421f3e2
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 6 deletions.
21 changes: 15 additions & 6 deletions e2e/scenarios/kops-simple
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ echo "IMAGE_TAG=${IMAGE_REPO}"
# Build and push cloud-controller-manager
cd ${REPO_ROOT}
export KO_DOCKER_REPO="${IMAGE_REPO}"
ko build --tags ${IMAGE_TAG} --base-import-paths --push=true ./cmd/cloud-controller-manager/
go run github.com/google/ko@v0.12.0 build --tags ${IMAGE_TAG} --base-import-paths --push=true ./cmd/cloud-controller-manager/

# TODO: Only if running in a test project?
gsutil iam ch allAuthenticatedUsers:objectViewer gs://artifacts.${GCP_PROJECT}.appspot.com
Expand All @@ -86,7 +86,9 @@ if [[ -z "${ADMIN_ACCESS}" ]]; then
fi
echo "ADMIN_ACCESS=${ADMIN_ACCESS}"

create_args="--networking gce"
# cilium does not yet pass conformance tests (shared hostport test)
#create_args="--networking cilium"
create_args="--networking kubenet"
if [[ -n "${ZONES:-}" ]]; then
create_args="${create_args} --zones=${ZONES}"
fi
Expand All @@ -103,13 +105,21 @@ echo "KOPS_FEATURE_FLAGS=${KOPS_FEATURE_FLAGS}"
# Note that these arguments for kubetest2 and kOps, not (for example) the arguments passed to the cloud-provider-gcp
KUBETEST2_ARGS="kops --kops-binary-path=${BINDIR}/kops"
KUBETEST2_ARGS="${KUBETEST2_ARGS} -v=2 --cloud-provider=${CLOUD_PROVIDER}"
KUBETEST2_ARGS="${KUBETEST2_ARGS} --cluster-name=${CLUSTER_NAME:-} --kops-root=${REPO_ROOT}"
KUBETEST2_ARGS="${KUBETEST2_ARGS} --cluster-name=${CLUSTER_NAME:-} --kops-root=${WORKSPACE}/kops"
KUBETEST2_ARGS="${KUBETEST2_ARGS} --admin-access=${ADMIN_ACCESS:-} --env=KOPS_FEATURE_FLAGS=${KOPS_FEATURE_FLAGS}"

if [[ -n "${GCP_PROJECT:-}" ]]; then
KUBETEST2_ARGS="${KUBETEST2_ARGS} --gcp-project=${GCP_PROJECT}"
fi

if [[ -n "${STAGE_LOCATION:-}" ]]; then
KUBETEST2_ARGS="${KUBETEST2_ARGS} --stage-location=${STAGE_LOCATION}"
fi

if [[ -n "${SSH_PRIVATE_KEY:-}" ]]; then
KUBETEST2_ARGS="${KUBETEST2_ARGS} --ssh-private-key=${SSH_PRIVATE_KEY}"
fi

function delete-cluster {
# shellcheck disable=SC2153
if [[ "${DELETE_CLUSTER:-}" == "true" ]]; then
Expand All @@ -125,18 +135,17 @@ fi

kubetest2 ${KUBETEST2_ARGS} \
--up \
\
--build \
--kubernetes-version="${K8S_VERSION}" \
--create-args="${create_args}" \
--control-plane-size="${KOPS_CONTROL_PLANE_SIZE:-1}" \
--template-path="${KOPS_TEMPLATE:-}"


kubetest2 ${KUBETEST2_ARGS} \
--test=kops \
-- \
--test-package-version="${K8S_VERSION}" \
--parallel=25 \
--parallel=30 \
--skip-regex="\[Serial\]" \
--focus-regex="\[Conformance\]"

Expand Down
29 changes: 29 additions & 0 deletions e2e/setup-kops.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Copyright 2022 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 -e
set -x

REPO_ROOT=$(git rev-parse --show-toplevel)
cd ${REPO_ROOT}
cd ..
WORKSPACE=$(pwd)

# Clone kOps into ${WORKSPACE}/kops
cd "${WORKSPACE}"

KOPS_VERSION=${KOPS_VERSION:-master}
git clone --depth 1 --branch ${KOPS_VERSION} https://github.com/kubernetes/kops kops
48 changes: 48 additions & 0 deletions e2e/setup-kube.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# Copyright 2022 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 -e
set -x

REPO_ROOT=$(git rev-parse --show-toplevel)
cd ${REPO_ROOT}
cd ..
WORKSPACE=$(pwd)

# Clone kubernetes into ${WORKSPACE}/kubernetes
cd "${WORKSPACE}"
KUBE_VERSION=${KUBE_VERSION:-master}
git clone --depth 1 --branch ${KUBE_VERSION} https://github.com/kubernetes/kubernetes kubernetes


# Set up go workspace to build with this version
cd "${REPO_ROOT}"

go work init

go work use .
go work use crd
go work use providers

# Workaround for go.mod replacements
sed -i 's/^\s*k8s.io.*//g' go.mod

go work use ${WORKSPACE}/kubernetes
for d in ${WORKSPACE}/kubernetes/staging/src/k8s.io/*; do
go work use $d
done

go work sync

0 comments on commit 421f3e2

Please sign in to comment.