|
| 1 | +#!/bin/bash -ex |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +# |
| 4 | +# Package : opensearch-jvector |
| 5 | +# Version : 3.6.0.0 |
| 6 | +# Source repo : https://github.com/opensearch-project/opensearch-jvector.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-jvector |
| 22 | +PACKAGE_URL=https://github.com/opensearch-project/opensearch-jvector.git |
| 23 | +SCRIPT_PACKAGE_VERSION=3.6.0.0 |
| 24 | +PACKAGE_VERSION=${1:-${SCRIPT_PACKAGE_VERSION}} |
| 25 | +OPENSEARCH_URL=https://github.com/opensearch-project/OpenSearch.git |
| 26 | +OPENSEARCH_VERSION=${PACKAGE_VERSION::-2} |
| 27 | +OPENSEARCH_PACKAGE=OpenSearch |
| 28 | +BUILD_HOME=`pwd` |
| 29 | +SCRIPT=$(readlink -f $0) |
| 30 | +SCRIPT_PATH=$(dirname $SCRIPT) |
| 31 | + |
| 32 | +sudo yum install -y git wget |
| 33 | + |
| 34 | +# ---------------------------------------------- |
| 35 | +# Install java25 |
| 36 | +# ---------------------------------------------- |
| 37 | +sudo dnf install -y java-25-openjdk-devel |
| 38 | + |
| 39 | +export JAVA_HOME=/usr/lib/jvm/java-25-openjdk |
| 40 | +export PATH="/usr/local/bin:$HOME/.local/bin:$JAVA_HOME/bin:$PATH" |
| 41 | + |
| 42 | +sudo chown -R test_user:test_user /home/tester |
| 43 | + |
| 44 | +# ------------------------------- |
| 45 | +# Remove existing repositories (if they exist) |
| 46 | +# ------------------------------- |
| 47 | +cd "${BUILD_HOME}" |
| 48 | + |
| 49 | +if [ -d "${OPENSEARCH_PACKAGE}" ]; then |
| 50 | + echo "Removing existing ${OPENSEARCH_PACKAGE} directory..." |
| 51 | + rm -rf "${OPENSEARCH_PACKAGE}" |
| 52 | +fi |
| 53 | + |
| 54 | +if [ -d "${PACKAGE_NAME}" ]; then |
| 55 | + echo "Removing existing ${PACKAGE_NAME} directory..." |
| 56 | + rm -rf "${PACKAGE_NAME}" |
| 57 | +fi |
| 58 | + |
| 59 | +# ---------------------------------------------- |
| 60 | +# Build opensearch tarball for integation tests |
| 61 | +# ---------------------------------------------- |
| 62 | +cd $BUILD_HOME |
| 63 | +git clone ${OPENSEARCH_URL} |
| 64 | +cd ${OPENSEARCH_PACKAGE} && git checkout ${OPENSEARCH_VERSION} |
| 65 | +./gradlew -p distribution/archives/linux-ppc64le-tar assemble |
| 66 | +if [ $? != 0 ] |
| 67 | +then |
| 68 | + echo "Build failed for OpenSearch-$OPENSEARCH_VERSION" |
| 69 | + exit 1 |
| 70 | +fi |
| 71 | + |
| 72 | +# --------------------------- |
| 73 | +# Clone and Prepare Repository |
| 74 | +# --------------------------- |
| 75 | +cd "${BUILD_HOME}" |
| 76 | +git clone "${PACKAGE_URL}" |
| 77 | +cd "${PACKAGE_NAME}" && git checkout "${PACKAGE_VERSION}" |
| 78 | +git apply ${SCRIPT_PATH}/${PACKAGE_NAME}_${SCRIPT_PACKAGE_VERSION}.patch |
| 79 | + |
| 80 | +# -------- |
| 81 | +# Build |
| 82 | +# -------- |
| 83 | +ret=0 |
| 84 | +./gradlew build -x test -x integTest || ret=$? |
| 85 | +if [ $ret -ne 0 ]; then |
| 86 | + set +ex |
| 87 | + echo "------------------ ${PACKAGE_NAME}: Build Failed ------------------" |
| 88 | + exit 1 |
| 89 | +fi |
| 90 | +export OPENSEARCH_JVECTOR_ZIP=${BUILD_HOME}/${PACKAGE_NAME}/build/distributions/${PACKAGE_NAME}-${PACKAGE_VERSION}-SNAPSHOT.zip |
| 91 | + |
| 92 | +# ---------- |
| 93 | +# Unit Test |
| 94 | +# ---------- |
| 95 | +ret=0 |
| 96 | +./gradlew test -x integTest || ret=$? |
| 97 | +if [ $ret -ne 0 ]; then |
| 98 | + ret=0 |
| 99 | + set +ex |
| 100 | + echo "------------------ ${PACKAGE_NAME}: Unit Test Failed ------------------" |
| 101 | + exit 2 |
| 102 | +fi |
| 103 | + |
| 104 | +# ----------------- |
| 105 | +# Integration Test |
| 106 | +# ----------------- |
| 107 | +ret=0 |
| 108 | +./gradlew integTest -Dtests.jvm.argline="-Xms2g -Xmx2g" -PcustomDistributionUrl="${BUILD_HOME}/OpenSearch/distribution/archives/linux-ppc64le-tar/build/distributions/opensearch-min-${OPENSEARCH_VERSION}-SNAPSHOT-linux-ppc64le.tar.gz" || ret=$? |
| 109 | +if [ $ret -ne 0 ]; then |
| 110 | + set +ex |
| 111 | + echo "------------------ ${PACKAGE_NAME}: Integration Test Failed ------------------" |
| 112 | + exit 2 |
| 113 | +fi |
| 114 | + |
| 115 | +# If we reach here, both the build and tests were successful |
| 116 | +set +ex |
| 117 | +echo "------------------ ${PACKAGE_NAME} ${PACKAGE_VERSION} Build and Tests Successful ------------------" |
| 118 | +echo "------------------ Plugin zip available at $OPENSEARCH_JVECTOR_ZIP --------------------------------" |
| 119 | +exit 0 |
0 commit comments