|
| 1 | +#!/bin/bash -ex |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +# |
| 4 | +# Package : opensearch-prometheus-exporter |
| 5 | +# Version : 3.6.0.0 |
| 6 | +# Source repo : https://github.com/opensearch-project/opensearch-prometheus-exporter.git |
| 7 | +# Tested on : UBI 9.6 |
| 8 | +# Language : Java |
| 9 | +# Ci-Check : True |
| 10 | +# Script License : Apache License, Version 2 or later |
| 11 | +# Maintainer : Ethan Choe <ethanchoe@ibm.com> |
| 12 | +# |
| 13 | +# Disclaimer : This script has been tested in non-root mode on given |
| 14 | +# ========== platform using the mentioned version of the package. |
| 15 | +# It may not work as expected with newer versions of the |
| 16 | +# package and/or distribution. In such case, please |
| 17 | +# contact "Maintainer" of this script. |
| 18 | +# |
| 19 | +# --------------------------------------------------------------------------- |
| 20 | + |
| 21 | +PACKAGE_NAME=opensearch-prometheus-exporter |
| 22 | +PACKAGE_URL=https://github.com/opensearch-project/opensearch-prometheus-exporter.git |
| 23 | +PACKAGE_VERSION=${1:-3.6.0.0} |
| 24 | +BUILD_HOME=`pwd` |
| 25 | + |
| 26 | +# ---------------------------------------------- |
| 27 | +# Install system packages |
| 28 | +# ---------------------------------------------- |
| 29 | +sudo dnf install -y git wget |
| 30 | + |
| 31 | +# ---------------------------------------------- |
| 32 | +# Install java25 |
| 33 | +# ---------------------------------------------- |
| 34 | +sudo dnf install -y java-25-openjdk-devel |
| 35 | + |
| 36 | +export JAVA_HOME=/usr/lib/jvm/java-25-openjdk |
| 37 | +export PATH="/usr/local/bin:$HOME/.local/bin:$JAVA_HOME/bin:$PATH" |
| 38 | + |
| 39 | +sudo chown -R test_user:test_user /home/tester |
| 40 | + |
| 41 | +# ------------------------------- |
| 42 | +# Remove exiting repository (if exists) |
| 43 | +# ------------------------------- |
| 44 | +if [ -d "${PACKAGE_NAME}" ]; then |
| 45 | + echo "Removing existing ${PACKAGE_NAME} directory..." |
| 46 | + rm -rf "${PACKAGE_NAME}" |
| 47 | +fi |
| 48 | + |
| 49 | +# ------------------------------- |
| 50 | +# Clone and Prepare Repository |
| 51 | +# ------------------------------- |
| 52 | +cd "${BUILD_HOME}" |
| 53 | +git clone "${PACKAGE_URL}" |
| 54 | +cd "${PACKAGE_NAME}" && git checkout "${PACKAGE_VERSION}" |
| 55 | + |
| 56 | +# -------- |
| 57 | +# Build |
| 58 | +# -------- |
| 59 | +ret=0 |
| 60 | +./gradlew clean build || ret=$? |
| 61 | +if [ $ret -ne 0 ]; then |
| 62 | + set +ex |
| 63 | + echo "------------------ ${PACKAGE_NAME}: Build Failed ------------------" |
| 64 | + exit 1 |
| 65 | +fi |
| 66 | + |
| 67 | +export OPENSEARCH_PROMETHEUS_EXPORTER_ZIP=${BUILD_HOME}/${PACKAGE_NAME}/build/distributions/prometheus-exporter-${PACKAGE_VERSION}.zip |
| 68 | + |
| 69 | +# ---------------------------------- |
| 70 | +# Run complete test suite |
| 71 | +# ---------------------------------- |
| 72 | +ret=0 |
| 73 | +./gradlew clean check || ret=$? |
| 74 | +if [ $ret -ne 0 ]; then |
| 75 | + ret=0 |
| 76 | + set +ex |
| 77 | + echo "------------------ ${PACKAGE_NAME}: Test Suite Failed ------------------" |
| 78 | + exit 2 |
| 79 | +fi |
| 80 | + |
| 81 | +# --------------------------------------- |
| 82 | +# Backward Compatibility (BWC) Testing |
| 83 | +# --------------------------------------- |
| 84 | +ret=0 |
| 85 | +./bwctest.sh || ret=$? |
| 86 | +if [ $ret -ne 0 ]; then |
| 87 | + set +ex |
| 88 | + echo "------------------ ${PACKAGE_NAME}: BWC Tests Failed ------------------" |
| 89 | + exit 2 |
| 90 | +fi |
| 91 | + |
| 92 | +# If we reach here, both the build and tests were successful |
| 93 | +set +ex |
| 94 | +echo "------------------ ${PACKAGE_NAME} ${PACKAGE_VERSION} Build and Tests Successful ------------------" |
| 95 | +echo "------------------ Plugin zip available at $OPENSEARCH_PROMETHEUS_EXPORTER_ZIP --------------------------------" |
| 96 | +exit 0 |
0 commit comments