Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cli ecosystem testing #286

Merged
merged 8 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions dockerfiles/dockerfile.galasactl
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
FROM harbor.galasa.dev/docker_proxy_cache/library/ubuntu:20.04

RUN apt-get update \
&& apt-get install -y ca-certificates
# Install Java, Maven and Gradle as they are pre-reqs for galasactl

ENV MAVEN_VERSION=3.8.5
ENV MAVEN_HOME=/opt/maven
ENV GRADLE_VERSION=8.9
ENV GRADLE_HOME=/opt/gradle

RUN apt-get update && \
apt-get install -y \
ca-certificates \
openjdk-17-jdk \
wget \
unzip \
tar && \
# Install Gradle
wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -O /tmp/gradle.zip && \
mkdir -p ${GRADLE_HOME} && \
unzip /tmp/gradle.zip -d ${GRADLE_HOME} && \
rm /tmp/gradle.zip && \
ln -s ${GRADLE_HOME}/gradle-${GRADLE_VERSION} ${GRADLE_HOME}/latest && \
ln -s ${GRADLE_HOME}/latest/bin/gradle /usr/local/bin/gradle && \
# Install Maven
wget https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz -O /tmp/maven.tar.gz && \
mkdir -p ${MAVEN_HOME} && \
tar -xzf /tmp/maven.tar.gz -C ${MAVEN_HOME} --strip-components=1 && \
rm /tmp/maven.tar.gz && \
ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin/mvn && \
# Clean up
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN java -version && \
gradle --version && \
mvn --version

ARG platform

Expand Down
3 changes: 2 additions & 1 deletion test-galasactl-ecosystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
echo "Running script test-galasactl-ecosystem.sh"

# This script can be ran locally or executed in a pipeline to test the various built binaries of galasactl
# This script can also be ran in a pipeline to test a published binary of galasactl in GHCR built by the GitHub workflow
# This script tests the 'galasactl' commands against the ecosystem
# Pre-requesite: the CLI must have been built first so the binaries are present in the /bin directory


# Where is this script executing from ?
Expand Down Expand Up @@ -101,6 +101,7 @@ export GALASA_TEST_RUN_GET_EXPECTED_NUMBER_ARTIFACT_RUNNING_COUNT="10"

CALLED_BY_MAIN="true"
# Bootstrap is in the $bootstrap variable.

source ${BASEDIR}/test-scripts/calculate-galasactl-executables.sh
calculate_galasactl_executable

Expand Down
63 changes: 43 additions & 20 deletions test-scripts/calculate-galasactl-executables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# SPDX-License-Identifier: EPL-2.0
#

# Where is this script executing from ?
BASEDIR=$(dirname "$0");pushd $BASEDIR 2>&1 >> /dev/null ;BASEDIR=$(pwd);popd 2>&1 >> /dev/null
export ORIGINAL_DIR=$(pwd)
cd "${BASEDIR}"

#--------------------------------------------------------------------------
#
Expand Down Expand Up @@ -81,26 +85,45 @@ export GALASA_TEST_RUN_GET_EXPECTED_NUMBER_ARTIFACT_RUNNING_COUNT="10"
function calculate_galasactl_executable {
h2 "Calculate the name of the galasactl executable for this machine/os"

raw_os=$(uname -s) # eg: "Darwin"
os=""
case $raw_os in
Darwin*)
os="darwin"
;;
Windows*)
os="windows"
;;
Linux*)
os="linux"
;;
*)
error "Failed to recognise which operating system is in use. $raw_os"
exit 1
esac

architecture=$(uname -m)
# Determine if the /bin directory exists i.e. if the script is testing
# a built binary or if it is testing a published Docker image in GHCR
# If testing a built binary, it will use it from the /bin, otherwise
# `galasactl` will be used as it is installed on the path within the image.
path_to_bin="${BASEDIR}/bin"

# Check if the /bin directory exists
if [ -d "$directory_path" ]; then
echo "The /bin directory exists so assume the script is testing a locally built binary."

raw_os=$(uname -s) # eg: "Darwin"
os=""
case $raw_os in
Darwin*)
os="darwin"
;;
Windows*)
os="windows"
;;
Linux*)
os="linux"
;;
*)
error "Failed to recognise which operating system is in use. $raw_os"
exit 1
esac

architecture=$(uname -m)

export binary="galasactl-${os}-${architecture}"
info "galasactl binary is ${binary}"

export BINARY_LOCATION="${ORIGINAL_DIR}/bin/${binary}"
info "binary location is ${BINARY_LOCATION}"
else
echo "The /bin directory does not exist so assume the script is testing a published image in GHCR."

export BINARY_LOCATION="galasactl"
fi

export binary="galasactl-${os}-${architecture}"
info "galasactl binary is ${binary}"
success "OK"
}
52 changes: 26 additions & 26 deletions test-scripts/properties-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function properties_create {

prop_name="properties.test.name.value.$PROP_NUM"

cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties set --namespace ecosystemtest \
--name $prop_name \
--value test-value \
--bootstrap $bootstrap \
Expand All @@ -122,7 +122,7 @@ function properties_create {
fi

# check that property has been created
cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -167,7 +167,7 @@ function properties_update {

prop_name="properties.test.name.value.$PROP_NUM"

cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties set --namespace ecosystemtest \
--name $prop_name \
--value updated-value \
--bootstrap $bootstrap \
Expand All @@ -184,7 +184,7 @@ function properties_update {
fi

# check that property has been updated
cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -219,7 +219,7 @@ function properties_delete {

prop_name="properties.test.name.value.$PROP_NUM"

cmd="$ORIGINAL_DIR/bin/${binary} properties delete --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties delete --namespace ecosystemtest \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand All @@ -235,7 +235,7 @@ function properties_delete {
fi

# check that property has been deleted
cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -268,7 +268,7 @@ function properties_delete_invalid_property {

set -o pipefail # Fail everything if anything in the pipeline fails. Else we are just checking the 'tee' return code.

cmd="$ORIGINAL_DIR/bin/${binary} properties delete --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties delete --namespace ecosystemtest \
--name this.property.shouldnt.exist \
--bootstrap $bootstrap \
--log -"
Expand All @@ -292,7 +292,7 @@ function properties_delete_without_name {

set -o pipefail # Fail everything if anything in the pipeline fails. Else we are just checking the 'tee' return code.

cmd="$ORIGINAL_DIR/bin/${binary} properties delete --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties delete --namespace ecosystemtest \
--bootstrap $bootstrap \
--log -"

Expand All @@ -314,7 +314,7 @@ function properties_set_with_name_without_value {

prop_name="properties.test.name.$PROP_NUM"

cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties set --namespace ecosystemtest \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand All @@ -335,7 +335,7 @@ function properties_set_with_name_without_value {
function properties_set_without_name_with_value {
h2 "Performing properties set without name parameter and with value parameter..."

cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties set --namespace ecosystemtest \
--value random-arbitrary-value \
--bootstrap $bootstrap \
--log -"
Expand All @@ -359,7 +359,7 @@ function properties_set_without_name_and_value {

prop_name="properties.test.name.value.$PROP_NUM"

cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties set --namespace ecosystemtest \
--bootstrap $bootstrap \
--log -"

Expand All @@ -378,7 +378,7 @@ function properties_set_without_name_and_value {
#--------------------------------------------------------------------------
function properties_get_setup {
h2 "Performing setup for subsequent properties get commands."
cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties set --namespace ecosystemtest \
--name get.test.property \
--value this-shouldnt-be-deleted \
--bootstrap $bootstrap \
Expand All @@ -390,7 +390,7 @@ function properties_get_setup {
function properties_get_with_namespace {
h2 "Performing properties get with only namespace used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--bootstrap $bootstrap \
--log -"

Expand Down Expand Up @@ -420,7 +420,7 @@ function properties_get_with_namespace {
function properties_get_with_name {
h2 "Performing properties get with only name used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--name get.test.property \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -451,7 +451,7 @@ function properties_get_with_name {
function properties_get_with_prefix {
h2 "Performing properties get with prefix used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--prefix get \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -482,7 +482,7 @@ function properties_get_with_prefix {
function properties_get_with_suffix {
h2 "Performing properties get with suffix used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--suffix property \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -513,7 +513,7 @@ function properties_get_with_suffix {
function properties_get_with_infix {
h2 "Performing properties get with infix used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--infix test \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -544,7 +544,7 @@ function properties_get_with_infix {
function properties_get_with_prefix_infix_and_suffix {
h2 "Performing properties get with prefix, infix, and suffix used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--prefix get \
--suffix property \
--infix test \
Expand Down Expand Up @@ -577,7 +577,7 @@ function properties_get_with_prefix_infix_and_suffix {
function properties_get_with_namespace_raw_format {
h2 "Performing properties get with only namespace used, expecting list of properties..."

cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace ecosystemtest \
cmd="${BINARY_LOCATION} properties get --namespace ecosystemtest \
--bootstrap $bootstrap \
--format raw \
--log -"
Expand Down Expand Up @@ -610,7 +610,7 @@ function properties_secure_namespace_set {

prop_name="properties.secure.namespace"

cmd="$ORIGINAL_DIR/bin/${binary} properties set --namespace secure \
cmd="${BINARY_LOCATION} properties set --namespace secure \
--name $prop_name \
--value dummy.value
--bootstrap $bootstrap \
Expand All @@ -626,7 +626,7 @@ function properties_secure_namespace_set {
fi

# check that property resource has been created
cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace secure \
cmd="${BINARY_LOCATION} properties get --namespace secure \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -665,7 +665,7 @@ function properties_secure_namespace_delete {

prop_name="properties.secure.namespace.test"

cmd="$ORIGINAL_DIR/bin/${binary} properties delete --namespace secure \
cmd="${BINARY_LOCATION} properties delete --namespace secure \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand All @@ -681,7 +681,7 @@ function properties_secure_namespace_delete {
fi

# check that property has been deleted
cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace secure \
cmd="${BINARY_LOCATION} properties get --namespace secure \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -719,7 +719,7 @@ function properties_secure_namespace_non_existent_prop_delete {

prop_name="properties.test.name.value.$PROP_NUM"

cmd="$ORIGINAL_DIR/bin/${binary} properties delete --namespace secure \
cmd="${BINARY_LOCATION} properties delete --namespace secure \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand All @@ -735,7 +735,7 @@ function properties_secure_namespace_non_existent_prop_delete {
fi

# check that property has been deleted
cmd="$ORIGINAL_DIR/bin/${binary} properties get --namespace secure \
cmd="${BINARY_LOCATION} properties get --namespace secure \
--name $prop_name \
--bootstrap $bootstrap \
--log -"
Expand Down Expand Up @@ -769,7 +769,7 @@ function properties_secure_namespace_non_existent_prop_delete {
function properties_namespaces_get {
h2 "Performing namespaces get, expecting a list of all namespaces in the cps..."

cmd="$ORIGINAL_DIR/bin/${binary} properties namespaces get \
cmd="${BINARY_LOCATION} properties namespaces get \
--bootstrap $bootstrap \
--log -"

Expand Down
Loading
Loading