Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,11 @@ test-e2e:

test-e2e-single-node:
go test -tags=$(GOTAGS) -failfast -timeout 90m -v$${WHAT:+ -run="$$WHAT"} ./test/e2e-single-node/

bootstrap-e2e:
./hack/bootstrap-e2e-test.sh

bootstrap-e2e-local:
# Use GOTAGS to exclude the default CGO implementation of signatures, which is not used by MCO
# but dragged in by containers/image/signature
CGO_ENABLED=0 go test -tags=$(GOTAGS) -v$${WHAT:+ -run="$$WHAT"} ./test/e2e-bootstrap/
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ require (
github.com/gostaticanalysis/analysisutil v0.0.3 // indirect
github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.12
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/opencontainers/go-digest v1.0.0
github.com/openshift/api v0.0.0-20210924154557-a4f696157341
github.com/openshift/client-go v0.0.0-20210916133943-9acee1a0fb83
Expand All @@ -57,7 +56,8 @@ require (
k8s.io/klog/v2 v2.10.0 // indirect
k8s.io/kubectl v0.22.1
k8s.io/kubelet v0.22.1
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9
k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471
sigs.k8s.io/controller-runtime v0.9.6
)

replace (
Expand Down
39 changes: 31 additions & 8 deletions go.sum

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions hack/bootstrap-e2e-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

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

REPO_ROOT=$(dirname "${BASH_SOURCE}")/..

OPENSHIFT_CI=${OPENSHIFT_CI:-""}
ARTIFACT_DIR=${ARTIFACT_DIR:-""}

function runTestsCI() {
echo "CI env detected, run tests with jUnit report extraction"
if [ -n "$ARTIFACT_DIR" ] && [ -d "$ARTIFACT_DIR" ]; then
JUNIT_LOCATION="$ARTIFACT_DIR"/junit_machine_config_operator_bootstrap_e2e.xml
echo "jUnit location: $JUNIT_LOCATION"
go install -mod= github.com/jstemmer/go-junit-report@latest
make bootstrap-e2e-local | tee >(go-junit-report > "$JUNIT_LOCATION")
else
echo "\$ARTIFACT_DIR not set or does not exists, no jUnit will be published"
make bootstrap-e2e-local
fi
}


cd $REPO_ROOT && \
source ./hack/fetch-ext-bins.sh && \
fetch_tools && \
setup_envs && \
if [ "$OPENSHIFT_CI" == "true" ]; then # detect ci environment there
runTestsCI
else
make bootstrap-e2e-local
fi
124 changes: 124 additions & 0 deletions hack/fetch-ext-bins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env bash
# Copyright 2018 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

# Enable tracing in this script off by setting the TRACE variable in your
# environment to any value:
#
# $ TRACE=1 test.sh
TRACE=${TRACE:-""}
if [ -n "$TRACE" ]; then
set -x
fi

k8s_version=1.22.1
goarch=amd64
goos="unknown"

if [[ "$OSTYPE" == "linux"* ]]; then
goos="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
goos="darwin"
fi

if [[ "$goos" == "unknown" ]]; then
echo "OS '$OSTYPE' not supported. Aborting." >&2
exit 1
fi

# Turn colors in this script off by setting the NO_COLOR variable in your
# environment to any value:
#
# $ NO_COLOR=1 test.sh
NO_COLOR=${NO_COLOR:-""}
if [ -z "$NO_COLOR" ]; then
header=$'\e[1;33m'
reset=$'\e[0m'
else
header=''
reset=''
fi

function header_text {
echo "$header$*$reset"
}

rc=0
tmp_root=/tmp

kb_root_dir=$tmp_root/kubebuilder
kb_orig=$(pwd)

# Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
# in your environment to any value:
#
# $ SKIP_FETCH_TOOLS=1 ./fetch_ext_bins.sh
#
# If you skip fetching tools, this script will use the tools already on your
# machine, but rebuild the kubebuilder and kubebuilder-bin binaries.
SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}

function prepare_staging_dir {
header_text "preparing staging dir"

if [ -z "$SKIP_FETCH_TOOLS" ]; then
rm -rf "$kb_root_dir"
else
rm -f "$kb_root_dir/kubebuilder/bin/kubebuilder"
rm -f "$kb_root_dir/kubebuilder/bin/kubebuilder-gen"
rm -f "$kb_root_dir/kubebuilder/bin/vendor.tar.gz"
fi
}

# fetch k8s API gen tools and make it available under kb_root_dir/bin.
function fetch_tools {
if [ -n "$SKIP_FETCH_TOOLS" ]; then
return 0
fi

header_text "fetching tools"
kb_tools_archive_name="kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz"
kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name"

kb_tools_archive_path="$tmp_root/$kb_tools_archive_name"
echo "download url: ${kb_tools_download_url}"
if [ ! -f $kb_tools_archive_path ]; then
echo "downloading kubebuilder"
echo "archive path: $kb_tools_archive_path"
curl -fsL ${kb_tools_download_url} -o "$kb_tools_archive_path"
fi
ls $tmp_root/
echo "temp root: $tmp_root"
tar -zvxf "$kb_tools_archive_path" -C "$tmp_root/"
}

function setup_envs {
header_text "setting up env vars"

# Setup env vars
export PATH=/tmp/kubebuilder/bin:$PATH
export TEST_ASSET_KUBECTL=/tmp/kubebuilder/bin/kubectl
export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver
export TEST_ASSET_ETCD=/tmp/kubebuilder/bin/etcd

# Ensure that some home var is set and that it's not the root
export HOME=${HOME:=/tmp/kubebuilder-testing}
if [ $HOME == "/" ]; then
export HOME=/tmp/kubebuilder-testing
fi
}
7 changes: 7 additions & 0 deletions internal/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ func NewBuilder(kubeconfig string) (*Builder, error) {
config: config,
}, nil
}

// BuilderFromConfig creates a *Builder with the given rest config.
func BuilderFromConfig(config *rest.Config) *Builder {
return &Builder{
config: config,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ spec:
apiServerInternalURI: https://api-int.domain.example.com:6443
apiServerURL: https://api.domain.example.com:6443
infrastructureName: lab-0aaaa
infrastructureTopology: HighlyAvailable
controlPlaneTopology: HighlyAvailable
platformStatus:
type: None
kubeAPIServerServingCAData: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCktVQkUgQVBJIFNFUlZFUiBTRVJWSU5HIENBIERBVEEKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
osImageURL: registry.product.example.org/ocp/4.2-DATE-VERSION@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
releaseImage: release-registry.product.example.org/ocp/4.2-date-version@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
proxy: null
rootCAData: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tClJPT1QgQ0EgREFUQQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==

Loading