Skip to content

Commit f766714

Browse files
authored
Build updates and fix for docker mount issue in v1.9 (#643)
Signed-off-by: Govind Kamat <govkamat@amazon.com>
1 parent ed2b7ac commit f766714

File tree

9 files changed

+157
-290
lines changed

9 files changed

+157
-290
lines changed

.ci/build.sh

Lines changed: 18 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,36 @@
11
#!/usr/bin/env bash
22

3-
# Licensed to Elasticsearch B.V. under one or more contributor
4-
# license agreements. See the NOTICE file distributed with
5-
# this work for additional information regarding copyright
6-
# ownership. Elasticsearch B.V. licenses this file to you under
7-
# the Apache License, Version 2.0 (the "License"); you may
8-
# not use this file except in compliance with the License.
9-
# You may obtain a copy of the License at
10-
#
11-
# http://www.apache.org/licenses/LICENSE-2.0
12-
#
13-
# Unless required by applicable law or agreed to in writing,
14-
# software distributed under the License is distributed on an
15-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
# KIND, either express or implied. See the License for the
17-
# specific language governing permissions and limitations
18-
# under the License.
3+
function setup {
4+
export BENCHMARK_HOME=$GITHUB_WORKSPACE
195

20-
# fail this script immediately if any command fails with a non-zero exit code
21-
set -e
22-
# fail on pipeline errors, e.g. when grepping
23-
set -o pipefail
24-
# fail on any unset environment variables
25-
set -u
6+
export THESPLOG_FILE=$BENCHMARK_HOME/.benchmark/logs/actor-system-internal.log
7+
export THESPLOG_FILE_MAXSIZE=204800 # default is 50 KiB
8+
export THESPLOG_THRESHOLD=INFO # default log level is WARNING
269

27-
function update_pyenv {
28-
# need to have the latest pyenv version to ensure latest patch releases are installable
29-
cd $HOME/.pyenv/plugins/python-build/../.. && git pull origin master --rebase && cd -
30-
}
31-
32-
function build {
33-
export THESPLOG_FILE="${THESPLOG_FILE:-${BENCHMARK_HOME}/.benchmark/logs/actor-system-internal.log}"
34-
# this value is in bytes, the default is 50kB. We increase it to 200kiB.
35-
export THESPLOG_FILE_MAXSIZE=${THESPLOG_FILE_MAXSIZE:-204800}
36-
# adjust the default log level from WARNING
37-
export THESPLOG_THRESHOLD="INFO"
38-
39-
# turn nounset off because some of the following commands fail if nounset is turned on
40-
set +u
41-
42-
export PATH="$HOME/.pyenv/bin:$PATH"
4310
export TERM=dumb
4411
export LC_ALL=en_US.UTF-8
45-
update_pyenv
46-
eval "$(pyenv init -)"
47-
# ensure pyenv shims are added to PATH, see https://github.com/pyenv/pyenv/issues/1906
48-
eval "$(pyenv init --path)"
49-
eval "$(pyenv virtualenv-init -)"
5012

51-
make prereq
52-
make install
53-
make precommit
54-
make test
13+
# Init pyenv.
14+
PATH=$HOME/.pyenv/shims:$PATH:$HOME/.pyenv/bin
5515
}
5616

57-
function build_it {
58-
export THESPLOG_FILE="${THESPLOG_FILE:-${BENCHMARK_HOME}/.benchmark/logs/actor-system-internal.log}"
59-
# this value is in bytes, the default is 50kB. We increase it to 200kiB.
60-
export THESPLOG_FILE_MAXSIZE=${THESPLOG_FILE_MAXSIZE:-204800}
61-
# adjust the default log level from WARNING
62-
export THESPLOG_THRESHOLD="INFO"
63-
64-
# turn nounset off because some of the following commands fail if nounset is turned on
65-
set +u
66-
67-
export PATH="$HOME/.pyenv/bin:$PATH"
68-
export TERM=dumb
69-
export LC_ALL=en_US.UTF-8
70-
export BENCHMARK_HOME="$GITHUB_WORKSPACE"
17+
function build_and_unit_test {
18+
setup
7119

72-
update_pyenv
73-
eval "$(pyenv init -)"
74-
# ensure pyenv shims are added to PATH, see https://github.com/pyenv/pyenv/issues/1906
75-
eval "$(pyenv init --path)"
76-
eval "$(pyenv virtualenv-init -)"
20+
set -e
21+
make develop
22+
make lint
23+
make test
24+
}
7725

78-
python3_version=`python3 --version`
79-
echo "Python3 version is ... $python3_version"
26+
function run_it {
27+
setup
8028

81-
python3 -m pip install opensearch-benchmark
8229
docker pull ubuntu/squid:latest
8330

84-
make prereq
85-
make install
86-
make precommit
87-
88-
# make it38, it39, etc.
31+
# make it38, it39, etc. so they run as concurrent GHA jobs
8932
make "it${1//./}"
9033
}
9134

92-
function license-scan {
93-
# turn nounset off because some of the following commands fail if nounset is turned on
94-
set +u
95-
96-
export PATH="$HOME/.pyenv/bin:$PATH"
97-
eval "$(pyenv init -)"
98-
# ensure pyenv shims are added to PATH, see https://github.com/pyenv/pyenv/issues/1906
99-
eval "$(pyenv init --path)"
100-
eval "$(pyenv virtualenv-init -)"
101-
102-
make prereq
103-
# only install depdencies that are needed by end users
104-
make install-user
105-
fossa analyze
106-
}
107-
108-
function archive {
109-
# Treat unset env variables as an error, but only in this function as there are other functions that allow unset variables
110-
set -u
111-
112-
# this will only be done if the build number variable is present
113-
BENCHMARK_DIR=${BENCHMARK_HOME}/.benchmark
114-
if [[ -d ${BENCHMARK_DIR} ]]; then
115-
find ${BENCHMARK_DIR} -name "*.log" -printf "%P\\0" | tar -cvjf ${BENCHMARK_DIR}/${BUILD_NUMBER}.tar.bz2 -C ${BENCHMARK_DIR} --transform "s,^,ci-${BUILD_NUMBER}/," --null -T -
116-
else
117-
echo "Benchmark directory [${BENCHMARK_DIR}] not present. Ensure the BENCHMARK_DIR environment variable is correct"
118-
exit 1
119-
fi
120-
}
35+
$@
12136

122-
if declare -F "$1" > /dev/null; then
123-
"$@"
124-
exit
125-
else
126-
echo "Please specify a function to run"
127-
exit 1
128-
fi
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Build and Test
1+
name: Docker Build
22
on:
33
pull_request:
44
workflow_dispatch:
@@ -28,14 +28,12 @@ jobs:
2828
with:
2929
version: 'v0.9.1'
3030
- uses: actions/checkout@v4
31-
with:
32-
path: 'opensearch-benchmark-git'
31+
3332
- name: Docker Build ${{ matrix.platform }}
3433
run: |
3534
docker buildx version
36-
cp -a opensearch-benchmark-git/* ./
37-
echo "Disable VERSION arg to enter docker build test mode"
38-
PLATFORM=${{ matrix.platform }}
39-
PLATFORM=`echo $PLATFORM | tr '/' '-'`
40-
docker buildx build --platform ${{ matrix.platform }} --build-arg BUILD_ENV=testing --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` -f "docker/Dockerfile" -t "osb/osb-$PLATFORM" -o type=docker .
41-
docker images | grep "osb/osb-$PLATFORM"
35+
tag=osb/osb-`echo ${{ matrix.platform }} | tr '/' '-'`
36+
set -x
37+
docker buildx build --platform ${{ matrix.platform }} --build-arg VERSION=`cat version.txt` --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` -f docker/Dockerfile -t "$tag" -o type=docker .
38+
set +x
39+
docker images | grep "$tag"
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Integ Actions
1+
name: Run Integration Tests
22
on: [workflow_dispatch, pull_request]
33
jobs:
44
Integration-Tests:
@@ -12,11 +12,11 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/setup-python@v4
15-
with:
16-
python-version: ${{ matrix.python-version }}
15+
1716
- uses: KengoTODA/actions-setup-docker-compose@v1
1817
with:
1918
version: '1.29.2'
19+
2020
# - name: Enforce docker-compose v1
2121
# run: |
2222
# echo "GitHub starts to switch runners to include docker-compose v2"
@@ -27,43 +27,19 @@ jobs:
2727
# sudo pip install docker-compose==1.29.2
2828
# docker --version
2929
# docker-compose --version
30+
3031
- name: Check out repository code
3132
uses: actions/checkout@v2
32-
- name: Clone pyenv
33+
34+
- name: Install pyenv
3335
run: git clone https://github.com/pyenv/pyenv.git ~/.pyenv
34-
- name: Clone pyenv-virtualenv
35-
run: git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
36-
- name: Install JDK 8
37-
uses: actions/setup-java@v3
38-
with:
39-
distribution: 'adopt'
40-
java-version: '8'
41-
- run: echo "JAVA8_HOME=$JAVA_HOME" >> $GITHUB_ENV
42-
- name: Install JDK 11
43-
uses: actions/setup-java@v3
44-
with:
45-
distribution: 'adopt'
46-
java-version: '11'
47-
- run: echo "JAVA11_HOME=$JAVA_HOME" >> $GITHUB_ENV
48-
- name: Install JDK 15
49-
uses: actions/setup-java@v3
50-
with:
51-
distribution: 'adopt'
52-
java-version: '15'
53-
- run: echo "JAVA15_HOME=$JAVA_HOME" >> $GITHUB_ENV
54-
- name: Install JDK 16
55-
uses: actions/setup-java@v3
56-
with:
57-
distribution: 'adopt'
58-
java-version: '16'
59-
- run: echo "JAVA16_HOME=$JAVA_HOME" >> $GITHUB_ENV
36+
6037
- name: Install JDK 17
6138
uses: actions/setup-java@v3
6239
with:
6340
distribution: 'adopt'
6441
java-version: '17'
6542
- run: echo "JAVA17_HOME=$JAVA_HOME" >> $GITHUB_ENV
66-
- name: Run the CI build_it script
67-
run: bash .ci/build.sh build_it ${{ matrix.python-version }}
68-
env:
69-
BENCHMARK_HOME: env.GITHUB_WORKSPACE
43+
44+
- name: Run the CI build script
45+
run: bash .ci/build.sh run_it ${{ matrix.python-version }}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Release drafter
1+
name: Publish Release to GitHub
22

33
on:
44
push:
55
tags:
66
- "*"
77

88
jobs:
9-
draft-a-release:
9+
publish-release:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout Repository
@@ -22,21 +22,20 @@ jobs:
2222
issue-title: 'Release opensearch-benchmark'
2323
issue-body: "Please approve or deny the release of opensearch-benchmark. **Tag**: ${{ github.ref_name }} **Commit**: ${{ github.sha }}"
2424
exclude-workflow-initiator-as-approver: true
25+
2526
- name: Set up Python 3
2627
uses: actions/setup-python@v3
2728
with:
2829
python-version: '3.x'
29-
- name: Install build tools
30-
run: |
31-
python -m pip install --upgrade build
30+
3231
- name: Build project for distribution
3332
run: |
34-
python -m build
35-
tar -zvcf artifacts.tar.gz dist
36-
- name: Release
33+
make build
34+
tar zcvf artifacts.tar.gz dist
35+
36+
- name: Publish release
3737
uses: softprops/action-gh-release@v1
3838
with:
3939
draft: true
4040
generate_release_notes: true
41-
files: |
42-
artifacts.tar.gz
41+
files: artifacts.tar.gz
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: CI Actions
2-
on: [pull_request]
1+
name: Run Unit Tests
2+
on: [workflow_dispatch, pull_request]
33
jobs:
44
Unit-Tests:
55
strategy:
@@ -8,12 +8,13 @@ jobs:
88
- ubuntu-latest
99
- macos-latest
1010
runs-on: ${{ matrix.os }}
11+
1112
steps:
1213
- name: Check out repository code
1314
uses: actions/checkout@v2
15+
1416
- name: Clone pyenv
1517
run: git clone https://github.com/pyenv/pyenv.git ~/.pyenv
18+
1619
- name: Run the CI build script
17-
run: bash .ci/build.sh build
18-
env:
19-
BENCHMARK_HOME: env.GITHUB_WORKSPACE
20+
run: bash .ci/build.sh build_and_unit_test

DEVELOPER_GUIDE.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,29 @@ This document will walk you through on what's needed to start contributing code
2323

2424
### Prerequisites
2525

26-
- **Pyenv** : Install `pyenv` and follow the instructions in the output of `pyenv init` to set up your shell and restart it before proceeding.
27-
For more details please refer to the [PyEnv installation instructions](https://github.com/pyenv/pyenv#installation).
26+
- **pyenv**: Install `pyenv` and follow the instructions in the output of `pyenv init` to set up your shell and restart it before proceeding.
27+
For more details please refer to the [pyenv installation instructions](https://github.com/pyenv/pyenv#installation).
2828

29-
**Optional Step:** For Debian-based systems, install the following modules to continue with the next steps:
29+
`pyenv` requires that the C compiler and development libraries be installed, so that the specified Python versions can be build from source. The installation instructions vary from platform to platform.
30+
31+
For Debian-based systems, install the following modules to continue with the next steps:
3032
```
3133
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
3234
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
3335
xz-utils tk-dev libffi-dev liblzma-dev git
3436
```
3537
38+
For Amazon Linux 2023, run the following command:
39+
```
40+
sudo yum -y install gcc openssl-devel bzip2-devel libffi-devel ncurses-devel sqlite-devel readline-devel zlib-devel xz-devel
41+
```
42+
43+
On the Mac platform, XCode needs to be installed as well as some additional required libraries:
44+
```
45+
xcode-select --install
46+
brew install pyenv jq zlib xz
47+
```
48+
3649
- **JDK**: Although OSB is a Python application, it optionally builds and provisions OpenSearch clusters. JDK version 17 is used to build the current version of OpenSearch. Please refer to the [build setup requirements](https://github.com/opensearch-project/OpenSearch/blob/ca564fd04f5059cf9e3ce8aba442575afb3d99f1/DEVELOPER_GUIDE.md#install-prerequisites).
3750
Note that the `javadoc` executable should be available in the JDK installation. An earlier version of the JDK can be used, but not all the integration tests will pass.
3851
@@ -54,15 +67,8 @@ For those working on WSL2, it is recommended to clone the repository and set up
5467
After you git cloned the forked copy of OpenSearch Benchmark, use the following command-line instructions to set up OpenSearch Benchmark for development:
5568
```
5669
cd opensearch-benchmark
57-
make prereq
58-
make install
59-
```
60-
61-
NOTE: `make prereq` produces the following message.
62-
```
63-
IMPORTANT: please add `eval "$(pyenv init -)"` to your bash profile and restart your terminal before proceeding any further.
70+
make develop
6471
```
65-
This line is commonly thought of as an error message but rather it's just a warning. Unless you haven't already added `eval "$(pyenv init -)"` to your bash profile and restarted your terminal, then feel free to proceed forward. This eval statement is necessary in the startup configuration as it allows Pyenv to manage python versions by adding python shims to your path. If you experience any issues, please see https://github.com/pyenv/pyenv.
6672
6773
Depending on the platform and shell you have, use the following command to activate the virtual environment:
6874

0 commit comments

Comments
 (0)