Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into linkCheckWorkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
okhasawn committed Oct 7, 2023
2 parents 68c5f46 + 276235b commit 8097aee
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/e2eTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: E2E Testing

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Start Docker Solution
run: |
cd TrafficCapture
chmod +x ./gradlew
./gradlew dockerSolution:ComposeUp
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install dependencies
run: |
cd test
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run E2E test script
run: |
cd test
chmod +x ./tests.py
pytest -n 3 tests.py
1 change: 1 addition & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ iniconfig==2.0.0
packaging==23.1
pluggy==1.0.0
pytest==7.3.1
pytest-xdist==3.3.1
requests==2.31.0
urllib3==2.0.6
12 changes: 7 additions & 5 deletions test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import time
import requests
import uuid
from requests.exceptions import ConnectionError, SSLError

logger = logging.getLogger(__name__)
Expand All @@ -16,7 +17,7 @@
# times every "delay" seconds IF the requests returned a status code other than what's expected.
# So this "retry_request" function's arguments are a request function's name and whatever arguments that function
# expects, and the status code the request function is expecting to get.
def retry_request(request: Callable, args: Tuple = (), max_attempts: int = 10, delay: float = 0.5,
def retry_request(request: Callable, args: Tuple = (), max_attempts: int = 15, delay: float = 1.5,
expected_status_code: HTTPStatus = None):
for attempt in range(1, max_attempts + 1):
try:
Expand Down Expand Up @@ -48,20 +49,20 @@ def retry_request(request: Callable, args: Tuple = (), max_attempts: int = 10, d
class E2ETests(unittest.TestCase):
def set_common_values(self):
self.proxy_endpoint = os.getenv('PROXY_ENDPOINT', 'https://localhost:9200')
self.source_endpoint = os.getenv('SOURCE_ENDPOINT', 'http://localhost:19200')
self.source_endpoint = os.getenv('SOURCE_ENDPOINT', 'https://localhost:19200')
self.target_endpoint = os.getenv('TARGET_ENDPOINT', 'https://localhost:29200')
self.jupyter_endpoint = os.getenv('JUPYTER_NOTEBOOK', 'http://localhost:8888/api')
self.username = os.getenv('username', 'admin')
self.password = os.getenv('password', 'admin')
self.auth = (self.username, self.password)
self.index = "my_index"
self.index = f"my_index_{uuid.uuid4()}"
self.doc_id = '7'

def setUp(self):
self.set_common_values()
retry_request(delete_index, args=(self.proxy_endpoint, self.index, self.auth),
expected_status_code=HTTPStatus.NOT_FOUND)
retry_request(delete_document, args=(self.proxy_endpoint, self.index, self.auth),
retry_request(delete_document, args=(self.proxy_endpoint, self.index, self.doc_id, self.auth),
expected_status_code=HTTPStatus.NOT_FOUND)

def tearDown(self):
Expand Down Expand Up @@ -122,7 +123,8 @@ def test_002_document(self):
source_response = get_document(self.source_endpoint, self.index, self.doc_id, self.auth)
self.assertEqual(source_response.status_code, HTTPStatus.OK)

target_response = get_document(self.target_endpoint, self.index, self.doc_id, self.auth)
target_response = retry_request(get_document, args=(self.target_endpoint, self.index, self.doc_id, self.auth),
expected_status_code=HTTPStatus.OK)
self.assertEqual(target_response.status_code, HTTPStatus.OK)

# Comparing the document's content on both endpoints, asserting that they match.
Expand Down

0 comments on commit 8097aee

Please sign in to comment.