|
| 1 | +#!/bin/bash -ex |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +# |
| 4 | +# Package : index-management |
| 5 | +# Version : 3.5.0.0 |
| 6 | +# Source repo : https://github.com/opensearch-project/index-management |
| 7 | +# Tested on : UBI:9.6 |
| 8 | +# Language : Java |
| 9 | +# Ci-Check : True |
| 10 | +# Script License : Apache License, Version 2 or later |
| 11 | +# Maintainer : Jason Cho <jason.cho2@@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 | + |
| 22 | +# --------------------------- |
| 23 | +# Configuration |
| 24 | +# --------------------------- |
| 25 | + |
| 26 | +PACKAGE_NAME=index-management |
| 27 | +PACKAGE_URL=https://github.com/opensearch-project/index-management |
| 28 | +SCRIPT_PACKAGE_VERSION="3.5.0.0" |
| 29 | +PACKAGE_VERSION="${1:-$SCRIPT_PACKAGE_VERSION}" |
| 30 | +OPENSEARCH_VERSION="${PACKAGE_VERSION::-2}" |
| 31 | +RUNTESTS=1 |
| 32 | +wdir="$(pwd)" |
| 33 | +SCRIPT=$(readlink -f $0) |
| 34 | +SCRIPT_DIR=$(dirname $SCRIPT) |
| 35 | + |
| 36 | + |
| 37 | +# ------------------- |
| 38 | +# Parse CLI Arguments |
| 39 | +# ------------------- |
| 40 | +for i in "$@"; do |
| 41 | + case $i in |
| 42 | + --skip-tests) |
| 43 | + RUNTESTS=0 |
| 44 | + echo "Skipping tests" |
| 45 | + shift |
| 46 | + ;; |
| 47 | + -*|--*) |
| 48 | + echo "Unknown option $i" |
| 49 | + exit 3 |
| 50 | + ;; |
| 51 | + *) |
| 52 | + PACKAGE_VERSION=$i |
| 53 | + echo "Building ${PACKAGE_NAME} ${PACKAGE_VERSION}" |
| 54 | + ;; |
| 55 | + esac |
| 56 | +done |
| 57 | + |
| 58 | + |
| 59 | +# --------------------------- |
| 60 | +# Dependency Installation |
| 61 | +# --------------------------- |
| 62 | +sudo yum install -y git java-25-openjdk-devel |
| 63 | +export JAVA_HOME=/usr/lib/jvm/java-25-openjdk |
| 64 | +export PATH=$PATH:$JAVA_HOME/bin |
| 65 | + |
| 66 | +sudo chown -R test_user:test_user /home/tester |
| 67 | + |
| 68 | +#-------------------------------- |
| 69 | +#Build opensearch-project and publish build tools |
| 70 | +#------------------------------- |
| 71 | +cd $wdir |
| 72 | +git clone https://github.com/opensearch-project/OpenSearch.git |
| 73 | +cd OpenSearch |
| 74 | +git checkout $OPENSEARCH_VERSION |
| 75 | +./gradlew -p distribution/archives/linux-ppc64le-tar assemble |
| 76 | +./gradlew -Prelease=true publishToMavenLocal |
| 77 | +./gradlew :build-tools:publishToMavenLocal |
| 78 | + |
| 79 | + |
| 80 | +# ------------------------------ |
| 81 | +# Build Opensearch common-utils |
| 82 | +# ------------------------------ |
| 83 | +cd $wdir |
| 84 | +git clone https://github.com/opensearch-project/common-utils.git |
| 85 | +cd common-utils |
| 86 | +git checkout $PACKAGE_VERSION |
| 87 | +git apply $SCRIPT_DIR/common-utils_${PACKAGE_VERSION}.patch |
| 88 | +./gradlew assemble |
| 89 | +./gradlew -Prelease=true publishToMavenLocal |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +# --------------------------- |
| 94 | +# Build Job Scheduler |
| 95 | +# --------------------------- |
| 96 | +cd $wdir |
| 97 | +git clone https://github.com/opensearch-project/job-scheduler |
| 98 | +cd job-scheduler |
| 99 | +git checkout $PACKAGE_VERSION |
| 100 | +git apply $SCRIPT_DIR/job-scheduler_${PACKAGE_VERSION}.patch |
| 101 | +./gradlew assemble |
| 102 | +./gradlew -Prelease=true publishToMavenLocal |
| 103 | + |
| 104 | + |
| 105 | +# --------------------------- |
| 106 | +# Clone and Prepare Repository |
| 107 | +# --------------------------- |
| 108 | +cd $wdir |
| 109 | +git clone $PACKAGE_URL |
| 110 | +cd $PACKAGE_NAME && git checkout $PACKAGE_VERSION |
| 111 | +git apply $SCRIPT_DIR/${PACKAGE_NAME}_${PACKAGE_VERSION}.patch |
| 112 | + |
| 113 | + |
| 114 | +# -------- |
| 115 | +# Build |
| 116 | +# -------- |
| 117 | +ret=0 |
| 118 | +./gradlew build -x test -x integTest || ret=$? |
| 119 | +if [ $ret -ne 0 ]; then |
| 120 | + set +ex |
| 121 | + echo "------------------ ${PACKAGE_NAME}: Build Failed ------------------" |
| 122 | + exit 1 |
| 123 | +fi |
| 124 | + |
| 125 | + |
| 126 | +# --------------------------- |
| 127 | +# Skip Tests? |
| 128 | +# --------------------------- |
| 129 | +if [ "$RUN_TESTS" -eq 0 ]; then |
| 130 | + set +ex |
| 131 | + echo "------------------ Complete: Build and install successful! Tests skipped. ------------------" |
| 132 | + exit 0 |
| 133 | +fi |
| 134 | + |
| 135 | +# ---------- |
| 136 | +# Unit Test |
| 137 | +# ---------- |
| 138 | +ret=0 |
| 139 | + ./gradlew test -x integTest || ret=$? |
| 140 | + if [ $ret -ne 0 ]; then |
| 141 | + set +ex |
| 142 | + echo "------------------ ${PACKAGE_NAME}: Unit Test Failed ------------------" |
| 143 | + exit 2 |
| 144 | + fi |
| 145 | + |
| 146 | +# ----------------- |
| 147 | +# Integration Test |
| 148 | +# ----------------- |
| 149 | +ret=0 |
| 150 | +./gradlew integTest -PcustomDistributionUrl=$wdir/OpenSearch/distribution/archives/linux-ppc64le-tar/build/distributions/opensearch-min-$OPENSEARCH_VERSION-SNAPSHOT-linux-ppc64le.tar.gz -Dbuild.snapshot=false || ret=$? |
| 151 | +if [ $ret -ne 0 ]; then |
| 152 | + set +ex |
| 153 | + echo "------------------ ${PACKAGE_NAME}: Integration Test Failed ------------------" |
| 154 | + exit 2 |
| 155 | +fi |
| 156 | + |
| 157 | +set +ex |
| 158 | +echo "Complete: Build and Tests successful!" |
0 commit comments