Skip to content

Commit

Permalink
DB Client application tests and tools example refactoring.
Browse files Browse the repository at this point in the history
Applied rewiew comments from Romain.

Signed-off-by: Tomas Kraus <Tomas.Kraus@oracle.com>
  • Loading branch information
Tomas-Kraus committed Apr 29, 2021
1 parent 71f09ce commit 71c8367
Show file tree
Hide file tree
Showing 30 changed files with 781 additions and 515 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"name": "com.codahale.metrics.MetricRegistry",
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredFields": true,
"allPublicFields": true
}
]
27 changes: 6 additions & 21 deletions etc/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
# Copyright (c) 2018, 2021 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,29 +15,14 @@
# limitations under the License.
#

set -o pipefail || true # trace ERR through pipes
set -o errtrace || true # trace ERR through commands and functions
set -o errexit || true # exit the script if any statement returns a non-true return value

on_error(){
CODE="${?}" && \
set +x && \
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
"${CODE}" "${BASH_SOURCE}" "${LINENO}" "${BASH_COMMAND}"
}
trap on_error ERR

# Path to this script
if [ -h "${0}" ] ; then
readonly SCRIPT_PATH="$(readlink "${0}")"
else
readonly SCRIPT_PATH="${0}"
fi
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"

# Path to the root of the workspace
readonly WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P)
# Load pipeline environment setup and define WS_DIR
. $(dirname -- "${SCRIPT_PATH}")/includes/pipeline-env.sh "${SCRIPT_PATH}" '../..'

source ${WS_DIR}/etc/scripts/pipeline-env.sh
# Setup error handling using default settings (defined in includes/error_handlers.sh)
error_trap_setup

mvn ${MAVEN_ARGS} --version

Expand Down
31 changes: 8 additions & 23 deletions etc/scripts/checkstyle.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
# Copyright (c) 2018, 2021 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,35 +15,20 @@
# limitations under the License.
#

set -o pipefail || true # trace ERR through pipes
set -o errtrace || true # trace ERR through commands and functions
set -o errexit || true # exit the script if any statement returns a non-true return value

on_error(){
CODE="${?}" && \
set +x && \
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
"${CODE}" "${BASH_SOURCE}" "${LINENO}" "${BASH_COMMAND}"
}
trap on_error ERR

# Path to this script
if [ -h "${0}" ] ; then
readonly SCRIPT_PATH="$(readlink "${0}")"
else
readonly SCRIPT_PATH="${0}"
fi
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"

# Path to the root of the workspace
readonly WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P)
# Load pipeline environment setup and define WS_DIR
. $(dirname -- "${SCRIPT_PATH}")/includes/pipeline-env.sh "${SCRIPT_PATH}" '../..'

# Setup error handling using default settings (defined in includes/error_handlers.sh)
error_trap_setup

readonly LOG_FILE=$(mktemp -t XXXcheckstyle-log)

readonly RESULT_FILE=$(mktemp -t XXXcheckstyle-result)

source ${WS_DIR}/etc/scripts/pipeline-env.sh

die(){ echo "${1}" ; exit 1 ;}
die() { echo "${1}" ; exit 1 ;}

mvn ${MAVEN_ARGS} checkstyle:checkstyle-aggregate \
-f ${WS_DIR}/pom.xml \
Expand Down
31 changes: 8 additions & 23 deletions etc/scripts/copyright.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
# Copyright (c) 2018, 2021 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,33 +15,18 @@
# limitations under the License.
#

set -o pipefail || true # trace ERR through pipes
set -o errtrace || true # trace ERR through commands and functions
set -o errexit || true # exit the script if any statement returns a non-true return value

on_error(){
CODE="${?}" && \
set +x && \
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
"${CODE}" "${BASH_SOURCE}" "${LINENO}" "${BASH_COMMAND}"
}
trap on_error ERR

# Path to this script
if [ -h "${0}" ] ; then
readonly SCRIPT_PATH="$(readlink "${0}")"
else
readonly SCRIPT_PATH="${0}"
fi
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"

# Path to the root of the workspace
readonly WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P)
# Load pipeline environment setup and define WS_DIR
. $(dirname -- "${SCRIPT_PATH}")/includes/pipeline-env.sh "${SCRIPT_PATH}" '../..'

readonly RESULT_FILE=$(mktemp -t XXXcopyright-result)
# Setup error handling using default settings (defined in includes/error_handlers.sh)
error_trap_setup

source ${WS_DIR}/etc/scripts/pipeline-env.sh
readonly RESULT_FILE=$(mktemp -t XXXcopyright-result)

die(){ echo "${1}" ; exit 1 ;}
die() { echo "${1}" ; exit 1 ;}

mvn ${MAVEN_ARGS} -q org.glassfish.copyright:glassfish-copyright-maven-plugin:copyright \
-f ${WS_DIR}/pom.xml \
Expand Down
8 changes: 2 additions & 6 deletions etc/scripts/gen-javadoc-packagelist.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e
#
# Copyright (c) 2019, 2020 Oracle and/or its affiliates.
# Copyright (c) 2019, 2021 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,11 +32,7 @@
#

# Path to this script
if [ -h "${0}" ] ; then
readonly SCRIPT_PATH="$(readlink "${0}")"
else
readonly SCRIPT_PATH="${0}"
fi
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"

# Path to the root of the workspace
readonly WS_DIR=$(cd $(dirname -- "${SCRIPT_PATH}") ; cd ../.. ; pwd -P)
Expand Down
19 changes: 8 additions & 11 deletions etc/scripts/github-release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2020 Oracle and/or its affiliates.
# Copyright (c) 2020, 2021 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,17 +15,14 @@
# limitations under the License.
#

set -o pipefail || true # trace ERR through pipes
set -o errtrace || true # trace ERR through commands and functions
set -o errexit || true # exit the script if any statement returns a non-true return value
# Path to this script
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"

on_error(){
CODE="${?}" && \
set +x && \
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
"${CODE}" "${BASH_SOURCE}" "${LINENO}" "${BASH_COMMAND}"
}
trap on_error ERR
# Load error handling functions and define error handling
. $(dirname -- "${SCRIPT_PATH}")/includes/error_handlers.sh

# Setup error handling using default settings (defined in includes/error_handlers.sh)
error_trap_setup

usage(){
cat <<EOF
Expand Down
55 changes: 55 additions & 0 deletions etc/scripts/includes/error_handlers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
#
# Copyright (c) 2018, 2021 Oracle and/or its affiliates.
#
# 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.
#

###############################################################################
# Error handling functions #
###############################################################################

# Multiple definition protection.
# The same code is included in both local and pipeline environment setup.
if [ -z "${__ERROR_HANDLER_INCLUDED__}" ]; then
readonly __ERROR_HANDLER_INCLUDED__='true'

# Default error handler.
# Shell variables: CODE
# BASH_SOURCE
# LINENO
# BASH_COMMAND
on_error() {
CODE="${?}" && \
set +x && \
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
"${CODE}" "${BASH_SOURCE}" "${LINENO}" "${BASH_COMMAND}"
}

# Error handling setup
# Arguments: $1 - error handler name (optional, default name is 'on_error')
error_trap_setup() {
# trace ERR through pipes
set -o pipefail || true
# trace ERR through commands and functions
set -o errtrace || true
# exit the script if any statement returns a non-true return value
set -o errexit || true
# Set error handler
trap "${1:-on_error}" ERR
}

else
echo "WARNING: ${WS_DIR}/etc/scripts/includes/error_handlers.sh included multiple times."
echo "WARNING: Make sure that only one from local and pipeline environment setups is loaded."
fi
82 changes: 82 additions & 0 deletions etc/scripts/includes/local-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright (c) 2021 Oracle and/or its affiliates.
#
# 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.
#

###############################################################################
# Local environment setup #
###############################################################################
# Shell variables: WS_DIR
# Arguments: $1 - Script path
# $2 - cd to Helidon root directory from script path
#
# Atleast WS_DIR or both arguments must be passed.

# WS_DIR variable verification.
if [ -z "${WS_DIR}" ]; then

if [ -z "${1}" ]; then
echo "ERROR: Missing required script path, exitting"
exit 1
fi

if [ -z "${2}" ]; then
echo "ERROR: Missing required cd to Helidon root directory from script path, exitting"
exit 1
fi

readonly WS_DIR=$(cd $(dirname -- "${1}") ; cd ${2} ; pwd -P)

fi

# Multiple definition protection.
if [ -z "${__LOCAL_ENV_INCLUDED__}" ]; then
readonly __LOCAL_ENV_INCLUDED__='true'

. ${WS_DIR}/etc/scripts/includes/error_handlers.sh

# Docker helper functions

# Docker database container start.
# Database containers require listening TCP port to be mapped to specific host:port.
# Arguments: $1 - name:version of the image
# $2 - name of the container (--name ${2})
# $3 - container port publishing (--publish ${3})
# $4 - additional docker run command arguments
# $5 - name of variable with container running status
# $6 - container start trigger variable name (optional, default true)
docker_db_start() {
if [ -z "${6}" ] || [ -n "${6}" -a -n "${!6}" ]; then
echo -n 'Starting Docker container: '
docker run -d \
--name "${2}" \
--publish "${3}" \
${4} \
--rm ${1} && \
[ -n "${5}" ] && eval "${5}='1'"
fi
}

# Docker container stop.
# Arguments: $1 - name of the container
# $2 - docker trigger variable name (optional, default true)
docker_stop() {
if [ -z "${2}" ] || [ -n "${2}" -a -n "${!2}" ]; then
echo -n 'Stopping Docker container: '
docker stop "${1}"
fi
}

else
echo "WARNING: ${WS_DIR}/etc/scripts/includes/local-env.sh included multiple times."
fi
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 71c8367

Please sign in to comment.