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

Add endpoints and authentication details (including SigV4) as parameters to E2E test script #461

Merged
merged 12 commits into from
Jan 11, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/e2eTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
run: |
cd test
chmod +x ./tests.py
pytest tests.py
pytest tests.py --unique_id="testindex"
12 changes: 12 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ def pytest_addoption(parser):
parser.addoption("--source_verify_ssl", action="store", default="False", choices=["True", "False"])
parser.addoption("--target_auth_type", action="store", default="basic", choices=["none", "basic", "sigv4"])
parser.addoption("--target_verify_ssl", action="store", default="False", choices=["True", "False"])
parser.addoption("--deployment_type", action="store", default="local", choices=["local", "cloud"])
parser.addoption("--source_username", action="store", default="admin")
parser.addoption("--source_password", action="store", default="admin")
parser.addoption("--target_username", action="store", default="admin")
parser.addoption("--target_password", action="store", default="admin")
parser.addoption("--unique_id", action="store", default="")


@pytest.fixture
Expand Down Expand Up @@ -81,3 +83,13 @@ def target_verify_ssl(pytestconfig):
@pytest.fixture
def source_verify_ssl(pytestconfig):
return pytestconfig.getoption("source_verify_ssl")


@pytest.fixture
def deployment_type(pytestconfig):
return pytestconfig.getoption("deployment_type")


@pytest.fixture
def unique_id(pytestconfig):
return pytestconfig.getoption("unique_id")
29 changes: 18 additions & 11 deletions test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import logging
import time
import requests
import uuid
import string
import secrets
import pytest
Expand Down Expand Up @@ -76,7 +75,7 @@ class E2ETests(unittest.TestCase):
@pytest.fixture(autouse=True)
def init_fixtures(self, proxy_endpoint, source_endpoint, target_endpoint, source_auth_type, source_username,
source_password, target_auth_type, target_username, target_password, target_verify_ssl,
source_verify_ssl):
source_verify_ssl, deployment_type, unique_id):
self.proxy_endpoint = proxy_endpoint
self.source_endpoint = source_endpoint
self.target_endpoint = target_endpoint
Expand All @@ -90,6 +89,8 @@ def init_fixtures(self, proxy_endpoint, source_endpoint, target_endpoint, source
self.target_password = target_password
self.source_verify_ssl = source_verify_ssl.lower() == 'true'
self.target_verify_ssl = target_verify_ssl.lower() == 'true'
self.deployment_type = deployment_type
self.unique_id = unique_id

def setup_authentication(self, auth_type, username, password):
if auth_type == "basic":
Expand All @@ -103,7 +104,7 @@ def setup_authentication(self, auth_type, username, password):
return None

def set_common_values(self):
self.index = f"my_index_{uuid.uuid4()}"
self.index = self.unique_id
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like it would be nice to keep the previous format like: f"test_index_{self.unique_id}" to be able to clearly tell what our test index is

Copy link
Collaborator

Choose a reason for hiding this comment

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

I imagine our unique id for the integ tests may just be the name of the test and the pipeline run number like full_run_21

self.doc_id = '7'
self.ignore_list = []

Expand Down Expand Up @@ -264,16 +265,22 @@ def test_0005_invalidIncorrectUri(self):
self.assertEqual(response.status_code, HTTPStatus.METHOD_NOT_ALLOWED)

def test_0006_OSB(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like it will need to be tweaked to work for AWS as well. For AWS we will already be on the migration console box so we would just need to make the runTestBenchmarks.sh call from the right directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, this specific test won't work on AWS as of this moment. I imagined that this script will end up existing on the migration console and running from there. I can update this test in a future PR to support that.
As for the other tests; per my testing on our deployed AWS solution (w/o SigV4 whatsoever), they will pass.

cmd = ['docker', 'ps', '--format="{{.ID}}"', '--filter', 'name=migration']
container_id = subprocess.run(cmd, stdout=subprocess.PIPE, text=True).stdout.strip().replace('"', '')

if container_id:
cmd_exec = f"docker exec {container_id} ./runTestBenchmarks.sh"
logger.warning(f"Running command: {cmd_exec}")
if self.deployment_type == "cloud":
cmd_exec = f"./runTestBenchmarks --unique-id {self.index}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The path here for runTestBenchmarks will be in a different directory. It's probably easiest to use /root/runTestBenchmarks.sh

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we also use the self.unique_id instead of self.index here? It seems like it may be clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I'll update in the next commit.

logger.warning(f"Running local command: {cmd_exec}")
subprocess.run(cmd_exec, shell=True)
else:
logger.error("Migration-console container was not found, please double check that deployment was a success")
self.assert_(False)
cmd = ['docker', 'ps', '--format="{{.ID}}"', '--filter', 'name=migration']
container_id = subprocess.run(cmd, stdout=subprocess.PIPE, text=True).stdout.strip().replace('"', '')

if container_id:
cmd_exec = f"docker exec {container_id} ./runTestBenchmarks.sh"
logger.warning(f"Running command: {cmd_exec}")
subprocess.run(cmd_exec, shell=True)
else:
logger.error("Migration-console container was not found,"
" please double check that deployment was a success")
self.assert_(False)

source_indices = get_indices(self.source_endpoint, self.source_auth, self.source_verify_ssl)
target_indices = get_indices(self.target_endpoint, self.target_auth, self.target_verify_ssl)
Expand Down
Loading