Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub workflow file. #35

Merged
merged 12 commits into from
Jun 3, 2022
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI
pgtgrly marked this conversation as resolved.
Show resolved Hide resolved

on: [push, pull_request]

jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2

- name: Installing node modules
run: npm install
working-directory: ./test

- name: Installing Dredd
run: sudo npm install dredd --global --unsafe-perm=true --allow-root

- name: Set up Python
uses: actions/setup-python@v2

- name: Install pipenv
run: pip install pipenv

- name: Installing python modules
run: pipenv install --system
working-directory: ./test

- name: Build the stack
run: docker-compose up -d
shell: bash
working-directory: ./test

- name: Waiting for OpenSearch domain to be up.
run: sh ./.github/workflows/domain-check.sh t

- name: Run script file
run: |
# Disabling TLS certificate verfication as hosted on docker.
export NODE_TLS_REJECT_UNAUTHORIZED=0
pgtgrly marked this conversation as resolved.
Show resolved Hide resolved
python driver-code.py
shell: bash
working-directory: ./test/scripts

17 changes: 17 additions & 0 deletions .github/workflows/domain-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
counter=1
for counter in {1..10}
do
if [ $(curl -s -o /dev/null --head -w "%{http_code}" 'https://admin:admin@localhost:9200' -H 'Content-Type:application/json' --insecure -v) -ne 200 ]; then
sleep 30s
else
# Waiting for security plugin to be initialised and become operational.
echo "Waiting for addtional 30 seconds.. for Opensearch domain to be up."
sleep 30s
break
fi
done
if [ $counter -eq 11 ]; then
echo "Unable to connect with OpenSearch URL https://localhost:9200/"
exit 1
fi

12 changes: 12 additions & 0 deletions test/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
prettytable = "*"

[dev-packages]

[requires]
python_version = "*"
36 changes: 36 additions & 0 deletions test/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: '3'
services:
opensearch-node1:
image: opensearchproject/opensearch:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want a matrix of versions tested here. Can be added later, but consider it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will work on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created an issue to keep track of it #43.

container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
- 9600:9600 # required for Performance Analyzer
networks:
- opensearch-net

opensearch-node2:
image: opensearchproject/opensearch:latest
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node2
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_master_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data
networks:
- opensearch-net

volumes:
opensearch-data1:
opensearch-data2:

networks:
opensearch-net:

55 changes: 55 additions & 0 deletions test/models/_global/ping/OpenSearchModel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
openapi: 3.0.2
info:
title: OpenSearch
version: '2021-11-23'
paths:
/:
get:
description: Returns whether the cluster is running.
operationId: GetPingCluster
responses:
'200':
description: GetPingCluster 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/GetPingClusterResponseContent'
components:
schemas:
GetPingClusterResponseContent:
type: object
properties:
name:
type: string
cluster_name:
type: string
cluster_uuid:
type: string
version:
$ref: '#/components/schemas/intermediateStructure'
tagline:
type: string
intermediateStructure:
type: object
properties:
distribution:
type: string
number:
type: string
build_type:
type: string
build_hash:
type: string
build_date:
type: string
build_snapshot:
type: boolean
nullable: true
lucene_version:
type: string
minimum_wire_compatibility_version:
type: string
minimum_index_compatibility_version:
type: string


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

7 changes: 7 additions & 0 deletions test/models/_global/ping/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const hooks = require('hooks');

hooks.before("/ > GET > 200 > application/json",function(transactions,done){
transactions.expected.headers['Content-Type'] = "application/json; charset=UTF-8";
done();
});

119 changes: 119 additions & 0 deletions test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "test-modules",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"fs": "^0.0.1-security",
"hooks": "^0.3.2",
"https": "^1.0.0",
"node-fetch": "^2.6.7"
}
}
Loading