diff --git a/Makefile b/Makefile index a296f3e96..1539fd1cd 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,10 @@ configure-supported-311-is: test: go test $(UNIT_TEST_ARGS) -race $(PKGS) +.PHONY: test-windows +test-windows: + go test $(UNIT_TEST_ARGS) $(PKGS) + # Run generic integration tests .PHONY: test-generic test-generic: diff --git a/scripts/openshiftci-e2e-4x-psi-tests.sh b/scripts/openshiftci-e2e-4x-psi-tests.sh index a8e66fdb4..ef80a9574 100755 --- a/scripts/openshiftci-e2e-4x-psi-tests.sh +++ b/scripts/openshiftci-e2e-4x-psi-tests.sh @@ -9,12 +9,16 @@ if [[ -f $ODO_RABBITMQ_AMQP_URL ]]; then export AMQP_URI=$(cat $ODO_RABBITMQ_AMQP_URL) 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 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 set -x -export EXCHANGE="amqp.ci.exchange.send" -export JOB_NAME="odo-pr-build" +export JOB_NAME=${JOB_NAME:-"odo-pr-build"} export REPO_URL="https://github.com/openshift/odo" # Extract PR NUMBER from prow job spec, which is injected by prow. 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" 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 -./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 + diff --git a/scripts/openshiftci-unit-psi-tests_win_mac.sh b/scripts/openshiftci-unit-psi-tests_win_mac.sh new file mode 100755 index 000000000..7dc9a4cfa --- /dev/null +++ b/scripts/openshiftci-unit-psi-tests_win_mac.sh @@ -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 \ No newline at end of file diff --git a/scripts/run_script_unit.sh b/scripts/run_script_unit.sh new file mode 100644 index 000000000..df1c2e554 --- /dev/null +++ b/scripts/run_script_unit.sh @@ -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 \ No newline at end of file diff --git a/scripts/setup_script_unit.sh b/scripts/setup_script_unit.sh new file mode 100644 index 000000000..f5228a3be --- /dev/null +++ b/scripts/setup_script_unit.sh @@ -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 + +#----------------------------------------------------------------------------- \ No newline at end of file