Skip to content

Commit a8e8f65

Browse files
authored
Adding Support to run tests with Security (#33)
Signed-off-by: Aditya Jindal <[email protected]>
1 parent 393fdee commit a8e8f65

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

.ci/run-opensearch.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
3737
http_port=9200
3838
for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do
3939
node_name=${opensearch_node_name}$i
40-
node_url=${external_opensearch_url/9200/${http_port}}$i
40+
node_url=${external_opensearch_url/9200/${http_port}}
4141
if [[ "$i" == "0" ]]; then node_name=$opensearch_node_name; fi
4242
environment+=($(cat <<-END
4343
--env node.name=$node_name
@@ -58,12 +58,17 @@ END
5858
echo 'cluster is' $CLUSTER
5959
docker build \
6060
--file=.ci/$CLUSTER/Dockerfile \
61-
--build-arg SECURE_INTEGRATION=false \
62-
--tag=$CLUSTER \
61+
--build-arg SECURE_INTEGRATION=$SECURE_INTEGRATION \
62+
--tag=$CLUSTER-secure-$SECURE_INTEGRATION \
6363
.
6464

6565
echo -e "\033[34;1mINFO:\033[0m Starting container $node_name \033[0m"
6666
set -x
67+
healthcmd="curl -vvv -s --fail http://localhost:9200/_cluster/health || exit 1"
68+
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
69+
healthcmd="curl -vvv -s --insecure -u admin:admin --fail https://localhost:9200/_cluster/health || exit 1"
70+
fi
71+
6772
docker run \
6873
--name "$node_name" \
6974
--network "$network_name" \
@@ -74,13 +79,13 @@ END
7479
--ulimit nofile=65536:65536 \
7580
--ulimit memlock=-1:-1 \
7681
--detach="$local_detach" \
77-
--health-cmd="curl -vvv -s --fail $opensearch_url/_cluster/health || exit 1" \
82+
--health-cmd="$(echo $healthcmd)" \
7883
--health-interval=2s \
7984
--health-retries=20 \
8085
--health-timeout=2s \
8186
--rm \
8287
-d \
83-
$CLUSTER;
88+
$CLUSTER-secure-$SECURE_INTEGRATION;
8489

8590
set +x
8691
if wait_for_container "$opensearch_node_name" "$network_name"; then

.ci/run-tests

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# Version 1.1
44
# - Add `$RUNSCRIPTS` env var for running Elasticsearch dependent products
55

6-
export OPENSEARCH_URL_EXTENSION="${OPENSEARCH_URL_EXTENSION:=http}"
76
export CLUSTER="${1:=opensearch}"
7+
export SECURE_INTEGRATION="${2:-false}"
8+
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
9+
export OPENSEARCH_URL_EXTENSION="https"
10+
else
11+
export OPENSEARCH_URL_EXTENSION="http"
12+
fi
813

914
script_path=$(dirname $(realpath -s $0))
1015
source $script_path/functions/imports.sh
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
name: Integration tests
22

3-
on:
4-
pull_request:
5-
paths-ignore:
6-
- 'README.md'
7-
branches:
8-
- "*"
9-
push:
10-
paths-ignore:
11-
- 'README.md'
12-
branches:
13-
- "*"
3+
on: [push, pull_request]
4+
5+
env:
6+
GITHUB_ACTIONS: true
147

158
jobs:
16-
assemble:
17-
name: Assemble
9+
tests:
10+
name: Test
1811
runs-on: ubuntu-latest
1912
env:
2013
SECURE_INTEGRATION: false
2114
strategy:
22-
fail-fast: false
2315
matrix:
2416
cluster-type: ['opendistro', 'opensearch']
17+
secured: ["true", "false"]
2518

2619
steps:
2720
- name: Checkout
2821
uses: actions/checkout@v2
22+
- name: Increase system limits
23+
run: |
24+
sudo swapoff -a
25+
sudo sysctl -w vm.swappiness=1
26+
sudo sysctl -w fs.file-max=262144
27+
sudo sysctl -w vm.max_map_count=262144
2928
- name: Install latest nightly
3029
uses: actions-rs/toolchain@v1
3130
with:
3231
toolchain: nightly
3332
override: true
3433
components: rustfmt, clippy
35-
- run: "./.ci/run-tests ${{ matrix.cluster-type }} "
36-
name: Integ ${{ matrix.cluster-type }}
34+
- run: "./.ci/run-tests ${{ matrix.cluster-type }} ${{ matrix.secured }}"
35+
name: Integ ${{ matrix.cluster-type }} secured=${{ matrix.secured }}

yaml_test_runner/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn branch_suite_and_version_from_opensearch(
162162

163163
let suite = TestSuite::Free;
164164

165-
let mut response = client.get(url).send()?;
165+
let mut response = client.get(url).basic_auth("admin", Some("admin")).send()?;
166166
let json: Value = response.json()?;
167167
let branch = json["version"]["build_hash"].as_str().unwrap().to_string();
168168

0 commit comments

Comments
 (0)