Skip to content

Commit

Permalink
Change tests run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriPapousek committed Oct 27, 2023
1 parent 619e2ea commit 25ac278
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
profiles:
- test-notification-services
- test-aggregator
- test-sha-extractor
image: quay.io/ccxdev/kafka-no-zk:latest
ports:
- 9092:9092
Expand Down
41 changes: 31 additions & 10 deletions insights_sha_extractor_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

export PATH_TO_LOCAL_SHA_EXTRACTOR=${PATH_TO_LOCAL_SHA_EXTRACTOR:="../ccx-sha-extractor"}
export exit_trap_command=""

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
Expand All @@ -23,12 +26,16 @@ function prepare_venv() {
python3 "$(which pip3)" install --no-cache -r requirements.in || exit 1
python3 "$(which pip3)" install --no-cache -r requirements/insights_sha_extractor.txt || exit 1

git clone --depth=1 [email protected]:ccx/ccx-sha-extractor.git
cd ccx-sha-extractor || exit
if [[ ! -d $PATH_TO_LOCAL_SHA_EXTRACTOR ]] ; then
git clone --depth=1 [email protected]:ccx/ccx-sha-extractor.git $PATH_TO_LOCAL_SHA_EXTRACTOR
add_trap "rm -rf ./ccx-sha-extractor"
fi
cwd=$(pwd)
cd $PATH_TO_LOCAL_SHA_EXTRACTOR || exit
pip install --no-cache-dir -U pip setuptools wheel
pip install --no-cache-dir -r requirements.txt
pip install -e .
cd ..
cd $cwd

echo "Environment ready"
}
Expand Down Expand Up @@ -56,25 +63,39 @@ function run_kafka() {
done

export kafka_cid
echo $kafka_cid
add_trap "docker kill ${kafka_cid}"
}

function run_mock_s3(){
function run_mock_s3() {
uvicorn mocks.s3.s3:app &
s3_pid=$!
add_trap "kill -9 $s3_pid"
}

run_kafka
function cleanup {
eval "$exit_trap_command"
}

run_mock_s3
function add_trap() {
local to_add=$1
if [ -z $exit_trap_command ]; then
exit_trap_command="$to_add"
else
exit_trap_command="$exit_trap_command; $to_add"
fi
trap cleanup EXIT
}

if ! [ $ENV_DOCKER ] ; then
run_kafka
fi

run_mock_s3
prepare_venv

# shellcheck disable=SC2068
PYTHONDONTWRITEBYTECODE=1 python3 -m behave --no-capture \
--format=progress2 \
--tags=-skip --tags=-managed \
-D dump_errors=true @test_list/insights_sha_extractor.txt "$@"

docker kill "$kafka_cid"
kill -9 $s3_pid
rm -rf ./ccx-sha-extractor
7 changes: 2 additions & 5 deletions run_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ copy_files() {
copy_python_project "$cid" "$path_to_service"
;;
"insights-sha-extractor-tests")
echo -e "\033[0;31mThese tests are not ready to be run. Aborting!\033[0m"
echo "This option will be enabled after https://issues.redhat.com/browse/CCXDEV-11895 is done."
exit 0
# copy_python_project $cid $path_to_service
copy_python_project $cid $path_to_service
;;
"notification-service-tests")
copy_go_executable "$cid" "$path_to_service" "ccx-notification-service"
Expand Down Expand Up @@ -103,7 +100,7 @@ docker_compose_profiles["exporter-tests"]="test-exporter"
docker_compose_profiles["inference-service-tests"]=""
docker_compose_profiles["insights-content-service-tests"]=""
docker_compose_profiles["insights-content-template-renderer-tests"]=""
docker_compose_profiles["insights-sha-extractor-tests"]="text-sha-extractor"
docker_compose_profiles["insights-sha-extractor-tests"]="test-sha-extractor"
docker_compose_profiles["notification-service-tests"]="test-notification-services"
docker_compose_profiles["notification-writer-tests"]="test-notification-services"
docker_compose_profiles["smart-proxy-tests"]=""
Expand Down

0 comments on commit 25ac278

Please sign in to comment.