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

E2E Tests version 1.0 #731

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
30809a7
E2E Tests version 1.0 (#2)
iwphonedo Jan 7, 2025
a3f892a
Refactor test scripts and improve documentation comments
iwphonedo Jan 8, 2025
ed3c033
Refactor service configurations and update container dependencies
iwphonedo Jan 8, 2025
59b3404
Add end-to-end tests to GitHub Actions workflow
iwphonedo Jan 8, 2025
58ada4a
Refactor log waiting mechanism to use threading for improved performa…
ariWeinberg Jan 9, 2025
2c978f6
Refactor PostgresBroadcastContainer usage in tests for improved clari…
ariWeinberg Jan 9, 2025
d8a8edf
Fix sleep duration in GitHub Actions and adjust context path in Docke…
ariWeinberg Jan 10, 2025
7da2b5f
Update e2e_tests workflow to change directory command and add listing…
ariWeinberg Jan 10, 2025
a52803d
Refactor e2e_tests workflow to streamline directory navigation and im…
ariWeinberg Jan 10, 2025
c247d85
Update e2e_tests workflow to trigger on master branch for improved te…
ariWeinberg Jan 10, 2025
f7c4b62
Remove redundant e2e tests step in workflow for cleaner execution
ariWeinberg Jan 10, 2025
d3b782f
Add newline at end of run.sh execution in tests workflow for consistency
ariWeinberg Jan 10, 2025
81f6a5d
Remove trailing newline at end of run.sh execution in tests workflow
ariWeinberg Jan 10, 2025
862f857
Remove unused debugpy import from api.py
iwphonedo Jan 10, 2025
8d90371
Rename workflow to 'E2E Tests' and add trigger for completed 'Tests' …
iwphonedo Jan 10, 2025
6694f51
Refactor start.sh to remove sleep and debugpy execution, streamline g…
ariWeinberg Jan 10, 2025
8d3b000
Fix Dockerfile paths to use relative references for consistency
ariWeinberg Jan 10, 2025
71f2b35
Update Dockerfile to use relative path for wait-for.sh and remove unu…
ariWeinberg Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/fixtures/policy_stores.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from images import cedar_image, opa_image
from testcontainers.core.network import Network

from tests.containers.cedar_container import CedarContainer
from tests.containers.opa_container import OpaContainer, OpaSettings
from tests.containers.settings.cedar_settings import CedarSettings
from tests.fixtures.images import cedar_image, opa_image


@pytest.fixture(scope="session")
Expand Down
2 changes: 2 additions & 0 deletions tests/genopalkeys.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This is utility script to generate OPAL keys - Use it for your needs

# This function generates a pair of RSA keys using ssh-keygen, extracts the public key into OPAL_AUTH_PUBLIC_KEY,
# formats the private key by replacing newlines with underscores and stores it in OPAL_AUTH_PRIVATE_KEY,
# and then removes the key files. It outputs messages indicating the start and completion of key generation.
Expand Down
7 changes: 4 additions & 3 deletions tests/install_opal.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This is a helper script to install opal-server and opal-client

# Installs opal-server and opal-client using pip.
# If the installation fails or the commands are not available,
# it exits with an error message.
# Installs opal-server and opal-client using pip.
# If the installation fails or the commands are not available,
# it exits with an error message.

function install_opal_server_and_client {
echo "- Installing opal-server and opal-client from pip..."
Expand Down
26 changes: 0 additions & 26 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,8 @@ if [[ -f ".env" ]]; then
source .env
fi


# Deletes pytest-generated .env files so they don't interfere with other tests.
function cleanup {

PATTERN="pytest_[a-f,0-9]*.env"
echo "Looking for auto-generated .env files matching pattern '$PATTERN'..."

for file in $PATTERN; do
if [[ -f "$file" ]]; then
echo "Deleting file: $file"
rm "$file"
else
echo "No matching files found for pattern '$PATTERN'."
break
fi
done

echo "Cleanup complete!\n"
}

function main {

# Cleanup before starting, maybe some leftovers from previous runs
cleanup

echo "Running tests..."

# Check if a specific test is provided
Expand All @@ -43,9 +20,6 @@ function main {
fi

echo "Done!"

# Cleanup at the end
cleanup
}

main "$@"
9 changes: 7 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ def build_docker_image(docker_file: str, image_name: str, session_matrix: dict):
image = docker_client.images.get(image_name)

if not image:
# context_path=os.path.join(os.path.dirname(__file__), ".."), # Expands the context
context_path = ".."
if "tests" in os.path.abspath(__file__):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to use pathlib instead, as its clearer and more modern

logger.info(f"Right now the file is {os.path.abspath(__file__)}")
context_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..", "opal")
)
else:
context_path = ".."
dockerfile_path = os.path.join(os.path.dirname(__file__), "docker", docker_file)
logger.info(f"Context path: {context_path}, Dockerfile path: {dockerfile_path}")

Expand Down