forked from LaconicNetwork/kompose
Merge pull request #588 from ashetty1/kompose_labels_test
Adding tests for kompose-specific labels and buildconfig dockerfile construct
This commit is contained in:
commit
aa84680d6e
@ -0,0 +1,8 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
foo:
|
||||||
|
build:
|
||||||
|
context: "../../../examples/buildconfig/build"
|
||||||
|
dockerfile: "Dockerfile"
|
||||||
|
command: "sleep 3600"
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
pival:
|
||||||
|
image: perl
|
||||||
|
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
|
||||||
|
restart: "always"
|
||||||
@ -130,7 +130,7 @@ function convert::kompose_up_check () {
|
|||||||
[ $(oc get pods | eval ${query_2} | awk '{ print $3 }' | \
|
[ $(oc get pods | eval ${query_2} | awk '{ print $3 }' | \
|
||||||
grep ${query_2_status} | wc -l) -eq $replica_2 ]; then
|
grep ${query_2_status} | wc -l) -eq $replica_2 ]; then
|
||||||
oc get pods
|
oc get pods
|
||||||
convert::print_pass "All pods are Running now. kompose up is successful."
|
convert::print_pass "All pods are Running now. kompose up is successful.\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ function convert::oc_check_route () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $(oc get route | grep ${route_key} | wc -l ) -gt 0 ]; then
|
if [ $(oc get route | grep ${route_key} | wc -l ) -gt 0 ]; then
|
||||||
convert::print_pass "Route *.${route_key} has been exposed"
|
convert::print_pass "Route *.${route_key} has been exposed\n"
|
||||||
else
|
else
|
||||||
convert::print_fail "Route *.${route_key} has not been exposed\n"
|
convert::print_fail "Route *.${route_key} has not been exposed\n"
|
||||||
fi
|
fi
|
||||||
@ -192,7 +192,7 @@ function convert::kompose_up () {
|
|||||||
# Usage: convert::kompose_up <docker_compose_file>
|
# Usage: convert::kompose_up <docker_compose_file>
|
||||||
local compose_file=$1
|
local compose_file=$1
|
||||||
convert::print_msg "Running kompose up ..."
|
convert::print_msg "Running kompose up ..."
|
||||||
kompose --provider=openshift --emptyvols -f $compose_file up
|
kompose up --provider=openshift --emptyvols -f $compose_file
|
||||||
exit_status=$?
|
exit_status=$?
|
||||||
|
|
||||||
if [ $exit_status -ne 0 ]; then
|
if [ $exit_status -ne 0 ]; then
|
||||||
|
|||||||
@ -34,13 +34,23 @@ fi
|
|||||||
|
|
||||||
convert::oc_cluster_up
|
convert::oc_cluster_up
|
||||||
|
|
||||||
for test_case in $KOMPOSE_ROOT/script/test_in_openshift/tests/*; do
|
|
||||||
$test_case; exit_status=$?
|
if [ -z $1 ]; then
|
||||||
|
for test_case in $KOMPOSE_ROOT/script/test_in_openshift/tests/*; do
|
||||||
|
$test_case; exit_status=$?
|
||||||
|
if [ $exit_status -ne 0 ]; then
|
||||||
|
openshift_exit_status=1
|
||||||
|
fi
|
||||||
|
convert::oc_cleanup
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Run individual test scripts
|
||||||
|
test_to_run=$1
|
||||||
|
$test_to_run; exit_status=$?
|
||||||
if [ $exit_status -ne 0 ]; then
|
if [ $exit_status -ne 0 ]; then
|
||||||
openshift_exit_status=1
|
openshift_exit_status=1
|
||||||
fi
|
fi
|
||||||
convert::oc_cleanup
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
convert::oc_cluster_down
|
convert::oc_cluster_down
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,6 @@ convert::kompose_up $docker_compose_file
|
|||||||
convert::kompose_up_check -p foo
|
convert::kompose_up_check -p foo
|
||||||
|
|
||||||
# Kompose down for buildconfig fails being tracked at #382
|
# Kompose down for buildconfig fails being tracked at #382
|
||||||
# convert::kompose_down $docker_compose_file
|
convert::kompose_down $docker_compose_file
|
||||||
|
|
||||||
# convert::kompose_down_check 2
|
convert::kompose_down_check 2
|
||||||
|
|||||||
35
script/test_in_openshift/tests/buildconfig_dockerfile.sh
Executable file
35
script/test_in_openshift/tests/buildconfig_dockerfile.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright 2017 The Kubernetes Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Test case for buildconfig on kompose
|
||||||
|
|
||||||
|
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
|
||||||
|
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
|
||||||
|
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
|
||||||
|
|
||||||
|
convert::print_msg "Testing buildconfig dockerfile construct in kompose"
|
||||||
|
|
||||||
|
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/docker-compose-bc-dockerfile.yml"
|
||||||
|
|
||||||
|
# Run kompose up
|
||||||
|
convert::kompose_up $docker_compose_file
|
||||||
|
|
||||||
|
# Check if the pods are up.
|
||||||
|
convert::kompose_up_check -p foo
|
||||||
|
|
||||||
|
# Kompose down for buildconfig fails being tracked at #382
|
||||||
|
# convert::kompose_down $docker_compose_file
|
||||||
|
|
||||||
|
# convert::kompose_down_check 2
|
||||||
@ -23,7 +23,7 @@ source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
|
|||||||
convert::print_msg "Running tests for replica option"
|
convert::print_msg "Running tests for replica option"
|
||||||
|
|
||||||
# Run kompose up
|
# Run kompose up
|
||||||
kompose --provider=openshift --emptyvols --replicas 2 -f ${KOMPOSE_ROOT}/examples/docker-compose-counter.yaml up; exit_status=$?
|
kompose up --provider=openshift --emptyvols --replicas 2 -f ${KOMPOSE_ROOT}/examples/docker-compose-counter.yaml; exit_status=$?
|
||||||
|
|
||||||
if [ $exit_status -ne 0 ]; then
|
if [ $exit_status -ne 0 ]; then
|
||||||
convert::print_fail "kompose up has failed"
|
convert::print_fail "kompose up has failed"
|
||||||
|
|||||||
50
script/test_in_openshift/tests/restart-options.sh
Executable file
50
script/test_in_openshift/tests/restart-options.sh
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2017 The Kubernetes Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
|
||||||
|
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
|
||||||
|
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
|
||||||
|
|
||||||
|
convert::print_msg "Testing restart: 'always'"
|
||||||
|
|
||||||
|
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/docker-compose-restart-always.yml"
|
||||||
|
|
||||||
|
# Run kompose up
|
||||||
|
convert::kompose_up $docker_compose_file
|
||||||
|
|
||||||
|
# Check if the pods are up
|
||||||
|
retry_up=0
|
||||||
|
|
||||||
|
while [ $(oc get pods --no-headers | wc -l ) -ne 1 ] ||
|
||||||
|
[ $(oc get pods --no-headers | awk '{ print $4 }') -eq 0 ]; do
|
||||||
|
if [ $retry_up -lt 240 ]; then
|
||||||
|
retry_up=$(($retry_up + 1))
|
||||||
|
sleep 1
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $(oc get pods --no-headers | awk '{ print $4 }') > 0 ]; then
|
||||||
|
convert::print_pass "restart option set to 'always' is working as expected\n"
|
||||||
|
oc get pods
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run Kompose down
|
||||||
|
convert::kompose_down $docker_compose_file
|
||||||
|
|
||||||
|
convert::kompose_down_check 1
|
||||||
40
script/test_in_openshift/tests/routes-service-expose-hostname.sh
Executable file
40
script/test_in_openshift/tests/routes-service-expose-hostname.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2017 The Kubernetes Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Test case for checking kompose.service.expose label in kompose
|
||||||
|
|
||||||
|
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
|
||||||
|
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
|
||||||
|
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
|
||||||
|
|
||||||
|
docker_compose_file="${KOMPOSE_ROOT}/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname.yml"
|
||||||
|
|
||||||
|
convert::print_msg "Testing kompose-specific label:kompose.service.expose=hostname "
|
||||||
|
|
||||||
|
# Run kompose up
|
||||||
|
convert::kompose_up $docker_compose_file
|
||||||
|
|
||||||
|
# Check if the pods are up
|
||||||
|
convert::kompose_up_check -p "web redis"
|
||||||
|
|
||||||
|
# Check if the service has been exposed
|
||||||
|
convert::oc_check_route "batman.example.com"
|
||||||
|
|
||||||
|
# Run Kompose down
|
||||||
|
convert::kompose_down $docker_compose_file
|
||||||
|
|
||||||
|
# Check if the pods have been terminated
|
||||||
|
convert::kompose_down_check 2
|
||||||
40
script/test_in_openshift/tests/routes-service-expose-true.sh
Executable file
40
script/test_in_openshift/tests/routes-service-expose-true.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2017 The Kubernetes Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Test case for checking routes construct with kompose
|
||||||
|
|
||||||
|
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
|
||||||
|
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
|
||||||
|
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
|
||||||
|
|
||||||
|
docker_compose_file="${KOMPOSE_ROOT}/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true.yml"
|
||||||
|
|
||||||
|
convert::print_msg "Running tests for kompose-specific labels: 'kompose.service.expose:True'"
|
||||||
|
|
||||||
|
# Run kompose up
|
||||||
|
convert::kompose_up $docker_compose_file
|
||||||
|
|
||||||
|
# Check if the pods are up
|
||||||
|
convert::kompose_up_check -p "web redis"
|
||||||
|
|
||||||
|
# Check if the service has been exposed
|
||||||
|
convert::oc_check_route "true"
|
||||||
|
|
||||||
|
# Run Kompose down
|
||||||
|
convert::kompose_down $docker_compose_file
|
||||||
|
|
||||||
|
# Check if the pods have been term
|
||||||
|
convert::kompose_down_check 2
|
||||||
Loading…
Reference in New Issue
Block a user