#!/usr/bin/env bash
# Copyright 2021 DataRobot, Inc. and its affiliates.
#
# All rights reserved.
# This is proprietary source code of DataRobot, Inc. and its affiliates.
#
# Released under the terms of DataRobot Tool and Utility Agreement.

set -ex
GIT_ROOT=$(git rev-parse --show-toplevel)

source "$(dirname "$0")/../tools/image-build-utils.sh"

# The "jenkins_artifacts" folder is created in the groovy script
DRUM_WHEEL_REAL_PATH="$(realpath "$(find jenkins_artifacts/datarobot_drum*.whl)")"

build_all_dropin_env_dockerfiles "$DRUM_WHEEL_REAL_PATH"

pip install -U pip
# installing DRUM into the test env is required for push test
pip install -U $DRUM_WHEEL_REAL_PATH
# requirements_test may install newer packages for testing, e.g. `datarobot`
pip install -r requirements_test_e2e_training.txt

# put tests in this exact order as they build images and as a result jenkins instance may run out of space
py.test tests/e2e/test_custom_task_templates.py \
        tests/e2e/test_drum_push.py \
        -v \
        --junit-xml="${GIT_ROOT}/results_drop_in.xml"
