Skip to content

Commit

Permalink
Added sudo to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
aborkar-ibm authored Jan 16, 2020
1 parent d2c7c86 commit c42a2ef
Showing 1 changed file with 49 additions and 43 deletions.
92 changes: 49 additions & 43 deletions Knative/0.10.0/build_knative.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# © Copyright IBM Corporation 2019.
# © Copyright IBM Corporation 2019, 2020.
# LICENSE: Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
#
# Instructions:
Expand All @@ -14,7 +14,7 @@ SOURCE_ROOT="$(pwd)"

FORCE="false"
LOG_FILE="$SOURCE_ROOT/logs/${PACKAGE_NAME}-${PACKAGE_VERSION}-$(date +"%F-%T").log"
CONF_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Knative/0.10.0/patch"
CONF_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Knative/${PACKAGE_VERSION}/patch"

trap cleanup 0 1 2 ERR

Expand Down Expand Up @@ -44,24 +44,31 @@ function prepare() {
fi

#Check if Kubernetes cluster is up
kubectl get pods --field-selector=status.phase!=Running -n kube-system 2>$SOURCE_ROOT/error.txt
if grep 'No resources found in kube-system namespace.' $SOURCE_ROOT/error.txt; then
printf -- "Kubernetes cluster is up" >> "$LOG_FILE"
else
printf -- "Kubernetes cluster is not up" >> "$LOG_FILE"
exit 1
if sudo kubectl get pods --field-selector=status.phase!=Running -n kube-system >$SOURCE_ROOT/error.txt;then
if [[ $(wc -l < $SOURCE_ROOT/error.txt) -eq 0 ]]; then
printf -- "Kubernetes cluster is up\n" |& tee -a "$LOG_FILE"
else
printf -- "Kubernetes cluster is not up\n" |& tee -a "$LOG_FILE"
exit 1
fi
else
printf -- "Kubernetes not installed\n" |& tee -a "$LOG_FILE"
exit 1
fi

#Check if Istio is integrated with Kubernetes
kubectl get pods --field-selector=status.phase!=Running -n istio-system | egrep -o '(istio-[a-z]+)' >$SOURCE_ROOT/Completed.txt
printf 'istio-cleanup\nistio-grafana\nistio-security\n' >$SOURCE_ROOT/expected.txt
result=`diff Completed.txt expected.txt`
if [ -z "$result" ]; then
printf -- "Istio is integrated with Kubernetes\n" |& tee -a "$LOG_FILE"
if sudo kubectl get pods --field-selector=status.phase!=Running -n istio-system | egrep -o '(istio-[a-z]+)' >$SOURCE_ROOT/Completed.txt; then
printf 'istio-cleanup\nistio-grafana\nistio-security\n' >$SOURCE_ROOT/expected.txt
if ! diff -q $SOURCE_ROOT/Completed.txt $SOURCE_ROOT/expected.txt &>/dev/null; then
printf -- "Istio is not integrated with Kubenetes\n" |& tee -a "$LOG_FILE"
exit 1
else
printf -- "Istio is integrated with Kubernetes\n" |& tee -a "$LOG_FILE"
fi
else
printf -- "Istio is not integrated with Kubenetes\n" |& tee -a "$LOG_FILE"
exit 1
fi
printf -- "Istio not integrated with Kubernetes\n" |& tee -a $LOG_FILE
exit 1
fi

if [[ "$FORCE" == "true" ]]; then
printf -- 'Force attribute provided hence continuing with install without confirmation message\n' |& tee -a "$LOG_FILE"
Expand Down Expand Up @@ -91,15 +98,15 @@ function cleanup() {
}
function installDependencies() {
#Create a local registry to push images to
docker pull sinenomine/registry-s390x
docker tag sinenomine/registry-s390x:latest s390x/registry:2
docker run -it -d -p 5000:5000 s390x/registry:2
sudo docker pull sinenomine/registry-s390x
sudo docker tag sinenomine/registry-s390x:latest s390x/registry:2
sudo docker run -it -d -p 5000:5000 s390x/registry:2
export KO_DOCKER_REPO="localhost:5000/v0.7.0"

#Install go version 12.5
sudo rm -rf /usr/local/go
wget https://dl.google.com/go/go1.12.5.linux-s390x.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.12.5.linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go1.12.5.linux-s390x.tar.gz
export GOROOT=/usr/local/go
export GOPATH=$SOURCE_ROOT
export PATH=/usr/local/go/bin:$PATH
Expand All @@ -122,45 +129,44 @@ function configureAndInstall() {
git clone https://github.com/knative/build.git
cd build/
git checkout v0.7.0
./hack/release.sh --skip-tests --nopublish --notag-release
docker tag ko.local/github.com/knative/build/build-base:latest localhost:5000/v0.7.0/ko.local/github.com/knative/build/build-base:latest
docker push localhost:5000/v0.7.0/ko.local/github.com/knative/build/build-base:latest
sudo -E env PATH=$PATH ./hack/release.sh --skip-tests --nopublish --notag-release
sudo docker tag ko.local/github.com/knative/build/build-base:latest localhost:5000/v0.7.0/ko.local/github.com/knative/build/build-base:latest
sudo docker push localhost:5000/v0.7.0/ko.local/github.com/knative/build/build-base:latest

#Build knative-serving
#Update go version to 1.13
cd $GOPATH
sudo rm -rf /usr/local/go
wget https://dl.google.com/go/go1.13.linux-s390x.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.13.linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go1.13.linux-s390x.tar.gz
#Download the code
cd ${GOPATH}/src/knative.dev/
git clone https://github.com/knative/serving.git
cd serving/
git checkout v0.10.0
git checkout v$PACKAGE_VERSION

#Edit .ko.yaml:
curl -o .ko.yaml.patch $CONF_URL/.ko.yaml.patch
patch -l .ko.yaml .ko.yaml.patch

#Generate yaml, publish docker images and deploy knative-serving pods
./hack/release.sh --skip-tests --nopublish --notag-release
ko publish ./cmd/activator ./cmd/autoscaler ./cmd/autoscaler-hpa ./cmd/controller ./cmd/default-domain ./cmd/networking/certmanager/ ./cmd/queue ./cmd/webhook
kubectl apply -f serving.yaml -n knative-serving || true
sudo -E env PATH=$PATH ./hack/release.sh --skip-tests --nopublish --notag-release
sudo -E env PATH=$PATH KO_DOCKER_REPO=$KO_DOCKER_REPO ko publish ./cmd/activator ./cmd/autoscaler ./cmd/autoscaler-hpa ./cmd/controller ./cmd/default-domain ./cmd/networking/certmanager/ ./cmd/queue ./cmd/webhook
sudo kubectl apply -f serving.yaml -n knative-serving || true

#Check all knative-serving pods are up:
sleep 30s
kubectl get pods --field-selector=status.phase!=Running -n knative-serving 2>$SOURCE_ROOT/error.txt
if grep 'No resources found in knative-serving namespace.' $SOURCE_ROOT/error.txt; then
sudo kubectl get pods --field-selector=status.phase!=Running -n knative-serving >$SOURCE_ROOT/error.txt
if [[ $(wc -l < $SOURCE_ROOT/error.txt) -eq 0 ]]; then
printf -- "Knative-serving pods are up\n"
else
printf -- "Knative-serving pods are not up\n"
exit 1
fi

#Edit vendor/knative.dev/test-infra/scripts/e2e-tests.sh and vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
#Remove '-race' keyword occurrences from these files.
sed -i -e 's/-race//g' vendor/knative.dev/test-infra/scripts/e2e-tests.sh
sed -i -e 's/-race//g' vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
#and remove '-race' keyword occurrences from these files.
sed -i -e 's/-race//g' vendor/knative.dev/test-infra/scripts/presubmit-tests.sh

#Execute unit tests
runTest knative-serving
Expand All @@ -170,22 +176,22 @@ function configureAndInstall() {
cd ${GOPATH}/src/knative.dev/
git clone https://github.com/knative/eventing.git
cd eventing/
git checkout v0.10.0
git checkout v$PACKAGE_VERSION
cp ../serving/.ko.yaml .
./hack/release.sh --skip-tests --nopublish --notag-release
kubectl apply -f eventing.yaml -n knative-eventing
sudo -E env PATH=$PATH ./hack/release.sh --skip-tests --nopublish --notag-release
sudo kubectl apply -f eventing.yaml -n knative-eventing

#Check all knative-eventing pods are up
sleep 30s
kubectl get pods --field-selector=status.phase!=Running -n knative-eventing 2>$SOURCE_ROOT/error.txt
if grep 'No resources found in knative-eventing namespace.' $SOURCE_ROOT/error.txt; then
sudo kubectl get pods --field-selector=status.phase!=Running -n knative-eventing >$SOURCE_ROOT/error.txt
if [[ $(wc -l < $SOURCE_ROOT/error.txt) -eq 0 ]]; then
printf -- "Knative-eventing pods are up\n"
else
printf -- "Knative-eventing pods are not up\n"
exit 1
fi

#Edit vendor/knative.dev/test-infra/scripts/e2e-tests.sh and vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
#Remove '-race' keyword occurrences from these files.
sed -i -e 's/-race//g' vendor/knative.dev/test-infra/scripts/e2e-tests.sh
sed -i -e 's/-race//g' vendor/knative.dev/test-infra/scripts/presubmit-tests.sh

Expand All @@ -197,12 +203,12 @@ function runTest() {
set +e
if [[ "$TESTS" == "true" ]]; then
if [ $1 == "knative-serving" ]; then
./test/presubmit-tests.sh --unit-tests
sudo -E env PATH=$PATH ./test/presubmit-tests.sh --unit-tests
if grep 'FAIL: TestAutoscalerPanicModeExponentialTrackAndStablize' "$LOG_FILE"; then
printf -- "Expected failure found\n"
fi
elif [ $1 == "knative-eventing" ]; then
./test/presubmit-tests.sh --unit-tests
sudo -E env PATH=$PATH ./test/presubmit-tests.sh --unit-tests
fi
else
printf -- "TEST FLAG not set\n"
Expand Down

0 comments on commit c42a2ef

Please sign in to comment.