-
Notifications
You must be signed in to change notification settings - Fork 0
chore(TestServer): add multilanguage test server, run in CI #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8abfabb
add test-server and CI for it
kessplas 03ef0cb
install poetry
kessplas af32de4
dont package test server
kessplas c3489d1
fix Makefile
kessplas 65b0ed4
Fix: Include gradle-wrapper.jar files in repository to fix CI build
kessplas 7357fe1
java slowe
kessplas b3fa01e
im slowe
kessplas c03a775
black
kessplas 4fdce1f
ci-fast
kessplas 035dff0
remove print
kessplas abe7114
default to fast ci
kessplas a49a018
fix smithy breaking changes, poetry to uv
kessplas a26d99b
address feedback
kessplas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # Makefile for S3 Encryption Client Testing | ||
|
|
||
| .PHONY: all start-servers start-python-server start-java-server run-tests stop-servers clean ci check-env help | ||
|
|
||
| # Default target | ||
| all: start-servers run-tests | ||
|
|
||
| # CI target for GitHub Actions | ||
| ci: start-servers run-tests stop-servers | ||
|
|
||
|
|
||
| # Start Python server in background | ||
| start-python-server: | ||
| @echo "Starting Python server..." | ||
| cd python-server && \ | ||
| python -m venv .venv && \ | ||
| .venv/bin/python -m ensurepip && \ | ||
| .venv/bin/python -m pip install -e . && \ | ||
| .venv/bin/python -m pip install -e ../.. && \ | ||
| AWS_ACCESS_KEY_ID="$$AWS_ACCESS_KEY_ID" \ | ||
| AWS_SECRET_ACCESS_KEY="$$AWS_SECRET_ACCESS_KEY" \ | ||
| AWS_SESSION_TOKEN="$$AWS_SESSION_TOKEN" \ | ||
| AWS_REGION="us-west-2" \ | ||
| .venv/bin/python src/main.py & echo $$! > ../python-server.pid | ||
| @echo "Python server starting..." | ||
|
|
||
| # Start Java server in background | ||
| start-java-server: | ||
| @echo "Starting Java server..." | ||
| cd java-server && \ | ||
| AWS_ACCESS_KEY_ID="$$AWS_ACCESS_KEY_ID" \ | ||
| AWS_SECRET_ACCESS_KEY="$$AWS_SECRET_ACCESS_KEY" \ | ||
| AWS_SESSION_TOKEN="$$AWS_SESSION_TOKEN" \ | ||
| AWS_REGION="us-west-2" \ | ||
| ./gradlew --build-cache --parallel run & echo $$! > ../java-server.pid | ||
| @echo "Java server starting..." | ||
|
|
||
| # Start both servers in parallel | ||
| start-servers: | ||
| @echo "Starting servers in parallel..." | ||
| @$(MAKE) -j2 start-python-server start-java-server | ||
| @echo "Waiting for servers to be ready..." | ||
| @for i in $$(seq 1 360); do \ | ||
| if nc -z localhost 8080 && nc -z localhost 8081; then \ | ||
| echo "Ports are open, waiting for servers to initialize..."; \ | ||
| sleep 5; \ | ||
| echo "Both servers are ready!"; \ | ||
| break; \ | ||
| fi; \ | ||
| if [ $$i -eq 360 ]; then \ | ||
| echo "Timeout waiting for servers to start"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "Waiting for servers to start ($$i/360)..."; \ | ||
| sleep 1; \ | ||
| done | ||
|
|
||
|
|
||
| # Run the Java tests | ||
| run-tests: | ||
| @echo "Running Java tests..." | ||
| @echo "Exporting environment variables from servers to tests..." | ||
| @# Extract AWS environment variables from the current shell and pass them to the tests | ||
| cd java-tests && \ | ||
| AWS_ACCESS_KEY_ID="$$AWS_ACCESS_KEY_ID" \ | ||
| AWS_SECRET_ACCESS_KEY="$$AWS_SECRET_ACCESS_KEY" \ | ||
| AWS_SESSION_TOKEN="$$AWS_SESSION_TOKEN" \ | ||
| AWS_REGION="us-west-2" \ | ||
| ./gradlew --build-cache --parallel integ | ||
| @echo "Tests completed successfully" | ||
|
|
||
| # Stop the servers | ||
| stop-servers: | ||
| @echo "Stopping servers..." | ||
| @if [ -f python-server.pid ]; then \ | ||
| kill $$(cat python-server.pid) 2>/dev/null || true; \ | ||
| rm python-server.pid; \ | ||
| fi | ||
| @if [ -f java-server.pid ]; then \ | ||
| kill $$(cat java-server.pid) 2>/dev/null || true; \ | ||
| rm java-server.pid; \ | ||
| fi | ||
| @echo "Servers stopped" | ||
|
|
||
| # Clean up logs and pid files | ||
| clean: stop-servers | ||
| @echo "Cleaning up..." | ||
| @rm -f python-server.log java-server.log | ||
| @echo "Cleanup complete" | ||
|
|
||
| # Help target | ||
| help: | ||
| @echo "Available targets:" | ||
| @echo " all : Start servers and run tests (default, output to stdout)" | ||
| @echo " ci : Run in CI mode (start servers, run tests, stop servers)" | ||
| @echo " start-servers : Start Python and Java servers in parallel (output to stdout)" | ||
| @echo " start-python-server: Start only the Python server" | ||
| @echo " start-java-server : Start only the Java server" | ||
| @echo " run-tests : Run Java tests" | ||
| @echo " stop-servers : Stop running servers" | ||
| @echo " clean : Stop servers and clean up logs" | ||
| @echo " check-env : Check if required environment variables are set" | ||
| @echo " help : Show this help message" | ||
|
|
||
| # Check if required environment variables are set | ||
| check-env: | ||
| @echo "Checking required environment variables..." | ||
| @if [ -z "$$AWS_ACCESS_KEY_ID" ]; then echo "AWS_ACCESS_KEY_ID is not set"; else echo "AWS_ACCESS_KEY_ID is set"; fi | ||
| @if [ -z "$$AWS_SECRET_ACCESS_KEY" ]; then echo "AWS_SECRET_ACCESS_KEY is not set"; else echo "AWS_SECRET_ACCESS_KEY is set"; fi | ||
| @if [ -z "$$AWS_SESSION_TOKEN" ]; then echo "AWS_SESSION_TOKEN is not set"; else echo "AWS_SESSION_TOKEN is set"; fi | ||
| @if [ -z "$$AWS_REGION" ]; then echo "AWS_REGION is not set (will use us-west-2 as default)"; else echo "AWS_REGION is set to $$AWS_REGION"; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # S3EC Generalized Robust Test Framework Machine | ||
|
|
||
| Or G-RTFM. Or something. | ||
|
|
||
| ## What? | ||
|
|
||
| This is a write-once, run-multiple test server. | ||
|
|
||
| ## How? | ||
|
|
||
| Use Smithy Java roughly as it is intended. | ||
| That is, generate a client and a server which share a common model. | ||
| Then, write more servers, either using the server codegen or parsing the JSON blobject by "hand". | ||
|
|
||
| ## Running Tests | ||
|
|
||
| A Makefile is provided to simplify running the servers and tests. The Makefile handles starting both the Python and Java servers, running the tests, and cleaning up. | ||
|
|
||
| ### Available Commands | ||
|
|
||
| ```bash | ||
| # Start servers and run tests (default) | ||
| make | ||
|
|
||
| # Run in CI mode (start servers in parallel, run tests, stop servers) | ||
| make ci | ||
|
|
||
| # Start Python and Java servers in parallel | ||
| make start-servers | ||
|
|
||
| # Start only the Python server | ||
| make start-python-server | ||
|
|
||
| # Start only the Java server | ||
| make start-java-server | ||
|
|
||
| # Run Java tests | ||
| make run-tests | ||
|
|
||
| # Stop running servers | ||
| make stop-servers | ||
|
|
||
| # Stop servers and clean up logs | ||
| make clean | ||
|
|
||
| # Show help message | ||
| make help | ||
| ``` | ||
|
|
||
| The `ci` target is specifically designed for GitHub Actions workflows, ensuring that servers are properly started in parallel, tests are run, and resources are cleaned up afterward. | ||
|
|
||
| ## Performance Optimizations | ||
|
|
||
| Performance optimizations have been implemented to speed up the test-server CI process, which was previously taking over 5 minutes to run. These optimizations include: | ||
|
|
||
| - Parallel server startup | ||
| - Gradle build caching and parallel execution | ||
| - Dependency caching in CI | ||
| - JVM optimizations | ||
|
|
||
| For detailed information about the optimizations, see [OPTIMIZATION.md](./OPTIMIZATION.md). | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love