Skip to content

Commit

Permalink
Add tests for javadc and scaladc templates
Browse files Browse the repository at this point in the history
Includes a refactor of the common make_image routine
to build apps from s2i-integration-test-apps instead
of a local build.
  • Loading branch information
tmckayus committed Feb 2, 2018
1 parent 4379dec commit a8e385a
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 29 deletions.
25 changes: 17 additions & 8 deletions test/e2e/common
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,17 @@ function poll_build() {
}

function make_image() {
local skip_push=1
local s2i_image
if [ "$#" -gt 0 ]; then
s2i_image=$1
else
s2i_image=$S2I_TEST_IMAGE_PYSPARK
fi
if [ "$#" -gt 1 ]; then
git_repo=$2
else
git_repo=https://github.com/radanalyticsio/s2i-integration-test-apps
fi
TEST_IMAGE=play
set +e
oc get buildconfig play &> /dev/null
Expand Down Expand Up @@ -331,22 +341,22 @@ function make_image() {
user=$S2I_TEST_EXTERNAL_USER
password=$S2I_TEST_EXTERNAL_PASSWORD
pushproj=$user
pushimage=scratch-radanalytics-pyspark
pushimage=scratch-$s2i_image
registry=$S2I_TEST_EXTERNAL_REGISTRY
imagestream=false

elif [ -n "$S2I_TEST_INTEGRATED_REGISTRY" ]; then
user=$(oc whoami)
password=$(oc whoami -t)
pushproj=$PROJECT
pushimage=radanalytics-pyspark
pushimage=scratch-$s2i_image
registry=$S2I_TEST_INTEGRATED_REGISTRY
imagestream=true
fi
fi

if [ -z "$registry" ]; then
os::cmd::expect_success 'oc new-build --name=play "$S2I_TEST_IMAGE_PYSPARK" --binary'
os::cmd::expect_success 'oc new-build --name=play --docker-image="$s2i_image" "$git_repo"'
else
set +e
docker login --help | grep email &> /dev/null
Expand All @@ -357,15 +367,14 @@ function make_image() {
else
docker login -u ${user} -p ${password} ${registry}
fi
docker tag ${S2I_TEST_IMAGE_PYSPARK} ${registry}/${pushproj}/${pushimage}
docker tag ${s2i_image} ${registry}/${pushproj}/${pushimage}
docker push ${registry}/${pushproj}/${pushimage}
if [ "$imagestream" == true ]; then
os::cmd::expect_success 'oc new-build --name=play --image-stream="$pushimage" --binary'
os::cmd::expect_success 'oc new-build --name=play --image-stream="$pushimage" "$git_repo"'
else
os::cmd::expect_success 'oc new-build --name=play --docker-image="$registry"/"$pushproj"/"$pushimage":latest --binary'
os::cmd::expect_success 'oc new-build --name=play --docker-image="$registry"/"$pushproj"/"$pushimage":latest "$git_repo"'
fi
fi
os::cmd::expect_success 'oc start-build play --from-file="$RESOURCE_DIR"/play'
poll_build play
if [ "$?" -ne 0 ]; then
echo make_image failed, exiting
Expand Down
20 changes: 0 additions & 20 deletions test/e2e/resources/play/app.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/e2e/templates/builddc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function run_app_without_clustername() {

function run_app_without_application_name() {
app_preamble
oc new-app --file=$TEMPLATE $SOURCE_INFO $APP_MAIN_CLASS &> /dev/null
oc new-app --file=$TEMPLATE $SOURCE_INFO $APP_MAIN_CLASS
}

function get_driver_pod() {
Expand Down
74 changes: 74 additions & 0 deletions test/e2e/templates/java/dc/javadc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Define a bunch of functions and set a bunch of variables
TEST_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"` | grep -o '.*/oshinko-s2i/test/e2e')
source $TEST_DIR/common

SCRIPT_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"`)
source $SCRIPT_DIR/../../builddc

TEMPLATE_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"` | grep -o '.*/oshinko-s2i')/templates
set_template $TEMPLATE_DIR/javadc.json
set_worker_count $S2I_TEST_WORKERS

# Clear these flags
set_fixed_app_name

os::test::junit::declare_suite_start "$MY_SCRIPT"

function poll_build() {
# override poll_build from builddc because
# in this case we never do a build beyond the
# binary build we do directly, so polls will break!
return
}

function test_no_app_name {
set_defaults
os::cmd::expect_success 'oc delete dc --all'
os::cmd::try_until_text 'oc get pod -l deploymentconfig' 'No resources found'
run_app_without_application_name
os::cmd::try_until_not_text 'oc get pod -l deploymentconfig' 'No resources found' $((10*minute))
DRIVER=$(oc get pod -l deploymentconfig --template='{{index .items 0 "metadata" "name"}}')
os::cmd::try_until_text 'oc logs "$DRIVER"' 'cluster'
os::cmd::expect_success 'oc delete dc --all'
}

set_git_uri https://github.com/radanalyticsio/s2i-integration-test-apps
set_app_main_class org.apache.spark.examples.JavaSparkPi

# Make the S2I test image if it's not already in the project
make_image $S2I_TEST_IMAGE_JAVA $GIT_URI
set_image $TEST_IMAGE

echo "++ test_no_app_name"
test_no_app_name

echo "++ test_exit"
test_exit

echo "++ test_cluster_name"
test_cluster_name

echo "++ test_del_cluster"
test_del_cluster

echo "++ test_app_args"
test_app_args

echo "++ test_pod_info"
test_podinfo

echo "++ test_named_config"
test_named_config

echo "++ test_driver_config"
test_driver_config

echo "++ test_spark_options"
test_spark_options

echo "++ test_no_source_or_image"
test_no_source_or_image

os::test::junit::declare_suite_end
74 changes: 74 additions & 0 deletions test/e2e/templates/scala/dc/scaladc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Define a bunch of functions and set a bunch of variables
TEST_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"` | grep -o '.*/oshinko-s2i/test/e2e')
source $TEST_DIR/common

SCRIPT_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"`)
source $SCRIPT_DIR/../../builddc

TEMPLATE_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"` | grep -o '.*/oshinko-s2i')/templates
set_template $TEMPLATE_DIR/scaladc.json
set_worker_count $S2I_TEST_WORKERS

# Clear these flags
set_fixed_app_name

os::test::junit::declare_suite_start "$MY_SCRIPT"

function poll_build() {
# override poll_build from builddc because
# in this case we never do a build beyond the
# binary build we do directly, so polls will break!
return
}

function test_no_app_name {
set_defaults
os::cmd::expect_success 'oc delete dc --all'
os::cmd::try_until_text 'oc get pod -l deploymentconfig' 'No resources found'
run_app_without_application_name
os::cmd::try_until_not_text 'oc get pod -l deploymentconfig' 'No resources found' $((10*minute))
DRIVER=$(oc get pod -l deploymentconfig --template='{{index .items 0 "metadata" "name"}}')
os::cmd::try_until_text 'oc logs "$DRIVER"' 'cluster'
os::cmd::expect_success 'oc delete dc --all'
}

set_git_uri https://github.com/radanalyticsio/s2i-integration-test-apps
set_app_main_class org.apache.spark.examples.SparkPi

# Make the S2I test image if it's not already in the project
make_image $S2I_TEST_IMAGE_SCALA $GIT_URI
set_image $TEST_IMAGE

echo "++ test_no_app_name"
test_no_app_name

echo "++ test_exit"
test_exit

echo "++ test_cluster_name"
test_cluster_name

echo "++ test_del_cluster"
test_del_cluster

echo "++ test_app_args"
test_app_args

echo "++ test_pod_info"
test_podinfo

echo "++ test_named_config"
test_named_config

echo "++ test_driver_config"
test_driver_config

echo "++ test_spark_options"
test_spark_options

echo "++ test_no_source_or_image"
test_no_source_or_image

os::test::junit::declare_suite_end

0 comments on commit a8e385a

Please sign in to comment.