Distgen generated content

This commit is contained in:
phracek 2021-05-25 17:41:02 +00:00
commit adc835754e
16 changed files with 1028 additions and 323 deletions

View file

@ -145,7 +145,7 @@ function ct_os_get_pod_status() {
# Arguments: pod_prefix - prefix or whole ID of the pod
function ct_os_get_build_pod_status() {
local pod_prefix="${1}" ; shift
local query="custom-columns=NAME:.metadata.name,Ready:status.containerStatuses[0].state.terminated.reason"
local query="custom-columns=NAME:.metadata.name,Ready:status.phase"
oc get pods -o "$query" | grep -e "${pod_prefix}" | grep -E "\-build\s" \
| sort -u | awk '{print $2}' | tail -n 1
}
@ -193,7 +193,7 @@ function ct_os_wait_pod_ready() {
if ct_os_get_all_pods_name | grep -E "${pod_prefix}.*-build"; then
SECONDS=0
echo -n "Waiting for ${pod_prefix} build pod to finish ..."
while ! [ "$(ct_os_get_build_pod_status "${pod_prefix}")" == "Completed" ] ; do
while ! [ "$(ct_os_get_build_pod_status "${pod_prefix}")" == "Succeeded" ] ; do
echo -n "."
[ "${SECONDS}" -gt "${timeout}0" ] && echo " FAIL" && return 1
sleep 3
@ -219,7 +219,7 @@ function ct_os_wait_rc_ready() {
local pod_prefix="${1}" ; shift
local timeout="${1}" ; shift
SECONDS=0
echo -n "Waiting for ${pod_prefix} pod becoming ready ..."
echo -n "Waiting for ${pod_prefix} having desired numbers of replicas ..."
while ! test "$( (oc get --no-headers statefulsets; oc get --no-headers rc) 2>/dev/null \
| grep "^${pod_prefix}" | awk '$2==$3 {print "ready"}')" == "ready" ; do
echo -n "."
@ -413,6 +413,7 @@ function ct_os_install_in_centos() {
bash-completion origin-clients docker origin-clients
}
# ct_os_cluster_up [DIR, IS_PUBLIC, CLUSTER_VERSION]
# --------------------
# Runs the local OpenShift cluster using 'oc cluster up' and logs in as developer.
@ -604,8 +605,7 @@ function ct_os_test_s2i_app_func() {
local check_command=${4}
local oc_args=${5:-}
local image_name_no_namespace=${image_name##*/}
local service_name="${image_name_no_namespace}-testing"
local image_tagged="${image_name_no_namespace}:${VERSION}"
local service_name="${image_name_no_namespace%%:*}-testing"
local namespace
if [ $# -lt 4 ] || [ -z "${1}" ] || [ -z "${2}" ] || [ -z "${3}" ] || [ -z "${4}" ]; then
@ -617,17 +617,22 @@ function ct_os_test_s2i_app_func() {
ct_os_new_project
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
local image_tagged="${image_name_no_namespace%:*}:${VERSION}"
# Create a specific imagestream tag for the image so that oc cannot use anything else
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${namespace}/${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
if [ "${CT_EXTERNAL_REGISTRY:-false}" == 'true' ] ; then
ct_os_import_image_ocp4 "${image_name}" "${image_tagged}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
# Create a specific imagestream tag for the image so that oc cannot use anything else
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${namespace}/${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
fi
fi
local app_param="${app}"
@ -752,27 +757,35 @@ function ct_os_test_template_app_func() {
ct_os_new_project
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
# Create a specific imagestream tag for the image so that oc cannot use anything else
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
if [ "${CT_EXTERNAL_REGISTRY:-false}" == 'true' ] ; then
ct_os_import_image_ocp4 "${image_name}" "${image_tagged}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
# upload also other images, that template might need (list of pairs in the format <image>|<tag>
local image_tag_a
local i_t
for i_t in ${other_images} ; do
echo "${i_t}"
IFS='|' read -ra image_tag_a <<< "${i_t}"
docker pull "${image_tag_a[0]}"
ct_os_upload_image "${image_tag_a[0]}" "${image_tag_a[1]}"
done
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
fi
fi
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'false' ] ; then
# upload also other images, that template might need (list of pairs in the format <image>|<tag>
local image_tag_a
local i_t
for i_t in ${other_images} ; do
echo "${i_t}"
IFS='|' read -ra image_tag_a <<< "${i_t}"
docker pull "${image_tag_a[0]}"
if [ "${CT_EXTERNAL_REGISTRY:-false}" == 'true' ] ; then
ct_os_import_image_ocp4 "${image_tag_a[0]}" "${image_tag_a[1]}"
else
ct_os_upload_image "${image_tag_a[0]}" "${image_tag_a[1]}"
fi
done
fi
# get the template file from remote or local location; if not found, it is
@ -781,6 +794,8 @@ function ct_os_test_template_app_func() {
local local_template
local_template=$(ct_obtain_input "${template}" 2>/dev/null || echo "--template=${template}")
echo "Creating a new-app with name ${name_in_template} in namespace ${namespace} with args ${oc_args}."
# shellcheck disable=SC2086
oc new-app "${local_template}" \
--name "${name_in_template}" \
@ -916,7 +931,7 @@ ct_os_test_image_update() {
function ct_os_deploy_cmd_image() {
local image_name=${1}
oc get pod command-app &>/dev/null && echo "command POD already running" && return 0
echo "command POD not running yet, will start one called command-app"
echo "command POD not running yet, will start one called command-app ${image_name}"
oc create -f - <<EOF
apiVersion: v1
kind: Pod
@ -934,6 +949,8 @@ EOF
SECONDS=0
echo -n "Waiting for command POD ."
while [ $SECONDS -lt 180 ] ; do
# Let's show status of all pods. Not only command-container for tracking issues
oc get pods
# shellcheck disable=SC2016
sout="$(ct_os_cmd_image_run 'echo $((11*11))' 2>/dev/null)"
# shellcheck disable=SC2015
@ -980,7 +997,7 @@ ct_os_test_response_internal() {
local status
local response_code
local response_file
local util_image_name='python:3.6'
local util_image_name='ubi7/ubi'
response_file=$(mktemp /tmp/ct_test_response_XXXXXX)
ct_os_deploy_cmd_image "${util_image_name}"
@ -1219,16 +1236,30 @@ function ct_os_test_image_stream_quickstart() {
local local_template_file
echo "Running image stream test for stream ${image_stream_file} and quickstart template ${template_file}"
echo "Image name is ${IMAGE_NAME}"
# shellcheck disable=SC2119
ct_os_new_project
local_image_stream_file=$(ct_obtain_input "${image_stream_file}")
local_template_file=$(ct_obtain_input "${template_file}")
oc create -f "${local_image_stream_file}"
# ct_os_test_template_app creates a new project, but we already need
# it before for the image stream import, so tell it to skip this time
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
# Add namespace into openshift arguments
if [[ $oc_args != *"NAMESPACE"* ]]; then
oc_args="${oc_args} -p NAMESPACE=${namespace}"
fi
oc create -f "${local_image_stream_file}"
# In case we are testing on OpenShift 4 export variable for mirror image
# which means, that image is going to be mirrored from an internal registry into OpenShift 4
if [ "${CT_EXTERNAL_REGISTRY:-false}" == 'true' ]; then
export CT_TAG_IMAGE=true
fi
# ct_os_test_template_app creates a new project, but we already need
# it before for the image stream import, so tell it to skip this time
CT_SKIP_NEW_PROJECT=true \
ct_os_test_template_app "${image_name}" \
"${local_template_file}" \