Automate psi ci for mac and windows (#4460)

* adding setup script and e2e-intigration,unit test script

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* adding mac and windows jobs

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fixing typo

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Consolidating scripts

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fixing unit test for windows and typo

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Fixing tests for windows and mac

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Fixing  mac unit test go not found

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Fixing  unit tests on windows mac

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Fixing  unit tests on windows

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Fixing  unit tests on windows

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* adding exchange for PSI tests

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* adding exchange for PSI tests

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fixing typo

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fixing unit test

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* fix unit test using cache

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* rebase

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* increase oc download time

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* windows unit test fix & fix for oc on mac

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* windows unit test

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* remove e2e test from this PR

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* increase timeout for test & change ci-firewall version

Signed-off-by: anandrkskd <anandrkskd@gmail.com>
This commit is contained in:
Anand Kumar Singh
2021-05-05 12:44:15 +05:30
committed by GitHub
parent bad22e0531
commit 9848769234
5 changed files with 96 additions and 4 deletions

View File

@@ -155,6 +155,10 @@ configure-supported-311-is:
test: test:
go test $(UNIT_TEST_ARGS) -race $(PKGS) go test $(UNIT_TEST_ARGS) -race $(PKGS)
.PHONY: test-windows
test-windows:
go test $(UNIT_TEST_ARGS) $(PKGS)
# Run generic integration tests # Run generic integration tests
.PHONY: test-generic .PHONY: test-generic
test-generic: test-generic:

View File

@@ -9,12 +9,16 @@ if [[ -f $ODO_RABBITMQ_AMQP_URL ]]; then
export AMQP_URI=$(cat $ODO_RABBITMQ_AMQP_URL) export AMQP_URI=$(cat $ODO_RABBITMQ_AMQP_URL)
fi fi
export AMQP_URI=${AMQP_URI:?"Please set AMQP_URI env with amqp uri or provide path of file containing it as ODO_RABBITMQ_AMQP_URL env"} export AMQP_URI=${AMQP_URI:?"Please set AMQP_URI env with amqp uri or provide path of file containing it as ODO_RABBITMQ_AMQP_URL env"}
export SENDQUEUE=${SENDQUEUE:-"amqp.ci.queue.send"}
export SENDTOPIC=${SENDTOPIC:-"amqp.ci.topic.send"}
export SETUPSCRIPT=${SETUPSCRIPT:-"scripts/setup_script_e2e.sh"}
export RUNSCRIPT=${RUNSCRIPT:-"scripts/run_script_e2e.sh"}
export SENDEXCHANGE=${SENDEXCHANGE:-"amqp.ci.exchange.send"}
# show commands # show commands
set -x set -x
export EXCHANGE="amqp.ci.exchange.send" export JOB_NAME=${JOB_NAME:-"odo-pr-build"}
export JOB_NAME="odo-pr-build"
export REPO_URL="https://github.com/openshift/odo" export REPO_URL="https://github.com/openshift/odo"
# Extract PR NUMBER from prow job spec, which is injected by prow. # Extract PR NUMBER from prow job spec, which is injected by prow.
export TARGET="$(jq .refs.pulls[0].number <<< $(echo $JOB_SPEC))" export TARGET="$(jq .refs.pulls[0].number <<< $(echo $JOB_SPEC))"
@@ -25,6 +29,8 @@ export CUSTOM_HOMEDIR=$ARTIFACT_DIR
export CI_FIREWALL_VERSION="v0.1.1" export CI_FIREWALL_VERSION="v0.1.1"
echo "Getting ci-firewall, see https://github.com,/mohammedzee1000/ci-firewall" echo "Getting ci-firewall, see https://github.com,/mohammedzee1000/ci-firewall"
curl -kLO https://github.com/mohammedzee1000/ci-firewall/releases/download/valpha/ci-firewall-linux-amd64.tar.gz curl -kLO https://github.com/mohammedzee1000/ci-firewall/releases/download/$CI_FIREWALL_VERSION/ci-firewall-linux-amd64.tar.gz
tar -xzf ci-firewall-linux-amd64.tar.gz tar -xzf ci-firewall-linux-amd64.tar.gz
./ci-firewall request --sendexchange $EXCHANGE --runscript scripts/run_all_tests.sh --timeout 4h00m --mainbranch main
./ci-firewall request --sendQName $SENDQUEUE --sendTopic $SENDTOPIC --sendexchange $SENDEXCHANGE --setupscript $SETUPSCRIPT --runscript $RUNSCRIPT --timeout 4h00m

View File

@@ -0,0 +1,25 @@
#!/bin/sh
case $1 in
win)
export SENDQUEUE=amqp.ci.queue.win.unit.send
export SENDTOPIC=amqp.ci.topic.win.unit.send
export SETUPSCRIPT="scripts/setup_script_unit.sh"
export RUNSCRIPT="scripts/run_script_unit.sh"
export JOBNAME=odo-mac-unit-pr-build
export SENDEXCHANGE=amqp.ci.exchange.win.unit.send
;;
mac)
export SENDQUEUE=amqp.ci.queue.mac.unit.send
export SENDTOPIC=amqp.ci.topic.mac.unit.send
export SETUPSCRIPT="scripts/setup_script_unit.sh"
export RUNSCRIPT="scripts/run_script_unit.sh"
export JOB_NAME=odo-mac-unit-pr-build
export SENDEXCHANGE=amqp.ci.exchange.mac.unit.send
;;
esac
. scripts/openshiftci-e2e-4x-psi-tests.sh

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
shout() {
set +x
echo -e "\n!!!!!!!!!!!!!!!!!!!!\n${1}\n!!!!!!!!!!!!!!!!!!!!\n"
set -x
}
shout "Running unit tests"
# Run unit tests
if [[ $BASE_OS == "windows" ]]; then
GOFLAGS='-mod=vendor' make test-windows
else
GOFLAGS='-mod=vendor' make test
fi

View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
shout() {
set +x
echo -e "\n!!!!!!!!!!!!!!!!!!!!\n${1}\n!!!!!!!!!!!!!!!!!!!!\n"
set -x
}
set -ex
shout "Setting up some stuff"
# Create a bin directory whereever script runs. This will be where all binaries that need to be in PATH will reside.
mkdir bin artifacts
# Change the default location of go's bin directory (without affecting GOPATH). This is where compiled binaries will end up by default
# for eg go get ginkgo later on will produce ginkgo binary in GOBIN
export GOBIN="`pwd`/bin"
# Set kubeconfig to current dir. This ensures no clashes with other test runs
export KUBECONFIG="`pwd`/config"
export ARTIFACT_DIR=${ARTIFACT_DIR:-"`pwd`/artifacts"}
export CUSTOM_HOMEDIR=$ARTIFACT_DIR
# Changing gocache to prevent unit test to use cache and pass
export GOCACHE=`pwd`/.gocache && mkdir $GOCACHE
# This si one of the variables injected by ci-firewall. Its purpose is to allow scripts to handle uniqueness as needed
SCRIPT_IDENTITY=${SCRIPT_IDENTITY:-"def-id"}
if [[ $BASE_OS == "windows" ]]; then
shout "Setting GOBIN for windows"
GOBIN="$(cygpath -pw $GOBIN)"
GOCACHE="$(cygpath -pw $GOCACHE)"
CUSTOM_HOMEDIR="$(cygpath -pw $CUSTOM_HOMEDIR)"
elif [[ $BASE_OS == "mac" ]]; then
PATH="$PATH:/usr/local/bin:/usr/local/go/bin" #Path to `go` command as `/usr/local/go/bin:/usr/local/bin` is not included in $PATH while running test
fi
shout "Setting PATH"
# Add GOBIN which is the bin dir we created earlier to PATH so any binaries there are automatically available in PATH
export PATH=$PATH:$GOBIN
#-----------------------------------------------------------------------------