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

[TT-1608] Adds Mockserver #1246

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

[TT-1608] Adds Mockserver #1246

wants to merge 16 commits into from

Conversation

kalverra
Copy link
Collaborator

@kalverra kalverra commented Oct 24, 2024

Adds a basic mockserver to set and mock calls for use in E2E tests. This is the first version, will be doing some more testing and iterating after merge.


Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.

Why

The changes establish the foundation for a mock server with dynamic routing capabilities, emphasizing configuration management, testing, and continuous integration workflows. They introduce the ability to define custom routes for testing, manage server configurations, and automate the server's release and testing process, fostering better testing environments and CI/CD practices.

What

  • .github/workflows/mockserver-release.yaml
    • Added a new GitHub Actions workflow for building and releasing the mock server, specifically when tags matching mockserver/v*.*.* are pushed. This includes steps for checking out the repository, setting up Nix, configuring AWS credentials, logging into Amazon ECR, and building and releasing the image using goreleaser.
  • .github/workflows/mockserver-test.yaml
    • Introduced a workflow for running tests on push to the main branch, tags matching mockserver/v*.*.*, and on pull requests. It checks out the code, uses a path filter to determine if tests should run based on changes in the mockserver directory, sets up Nix, and runs tests if the mockserver directory has changes.
  • .gitignore
    • Updated to ignore mockserver/save.json, preventing potentially sensitive or unnecessary data from being committed to the repository.
  • mockserver/.goreleaser.yaml
    • Created a Goreleaser configuration for the mock server to define build settings, Docker image templates, and disable the changelog for releases, facilitating automated releases and Docker image creation.
  • mockserver/Dockerfile
    • Added a Dockerfile for building the mock server, using a multi-stage build to create a minimal Docker image containing the compiled binary.
  • mockserver/README.md
    • Created a README file providing documentation on how to use, configure, and run the mock server, including examples of registering routes via curl and Go.
  • mockserver/config.go and mockserver/config_test.go
    • Implemented configuration management with environment variables for the mock server, along with tests for the configuration logic, ensuring the server can be easily configured in different environments.
  • mockserver/go.mod and mockserver/go.sum
    • Initialized Go module with dependencies on zerolog and testify, setting the groundwork for logging and testing within the mock server application.
  • mockserver/main.go
    • Developed the main application logic for the mock server, including route registration, dynamic response handling, and server configuration, laying the foundation for a highly configurable and testable mock server.
  • mockserver/router.go and mockserver/router_test.go
    • Crafted routing functionalities allowing dynamic registration of routes and responses, accompanied by tests to verify the routing logic, enhancing the mock server's utility for testing scenarios by simulating various API behaviors.

@kalverra kalverra changed the title Adds Mockserver [TT-1608] Adds Mockserver Oct 24, 2024
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants