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 DESIGN_PRINCIPLES #420

Merged
merged 3 commits into from
Feb 10, 2023
Merged

Add DESIGN_PRINCIPLES #420

merged 3 commits into from
Feb 10, 2023

Conversation

thomaseizinger
Copy link
Collaborator

No description provided.

This documents aims to capture the design principles that went into this library.
It should serve as a reference point when making decisions on what features to include or exclude.

## Simple
Copy link
Member

Choose a reason for hiding this comment

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

Loved this section, thanks for adding it!

DESIGN_PRINCIPLES.md Outdated Show resolved Hide resolved
DESIGN_PRINCIPLES.md Outdated Show resolved Hide resolved

One of most important goals that we want to adhere to is creating a _simple_ API.
Overall, this means keeping the API as small as possible to get the task done.
When in doubt, we'd rather not add flags or configuration options for certain use cases.
Copy link
Member

Choose a reason for hiding this comment

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

This is a pretty big point, we like to emphasize for the Testcontainers project as a whole. Testcontainers does not intend to be a generic Docker client or a replacement for the Docker CLI. Instead, we follow an opinionated approach of providing APIs that make using best practices for integration testing easier.

While it is technically possible to map to fixed ports, or specify fixed container names, we believe that this feature is actually not necessary for the intended use cases of Testcontainers, hence we would hesitate to just add all Docker capabilities to the Testcontainers API, without a good reason for the integration testing context.

When in doubt, we'd rather not add flags or configuration options for certain use cases.

Tests should be easier to write, easy to understand and easy to maintain.
`testcontainers` aims to support this as much as possible.
Copy link
Member

Choose a reason for hiding this comment

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

The umbrella project is called Testcontainers. The implementation for the individual languages is called Testcontainers for {$lang} and the repository is called testcontainers-${rust}.

In think in this instance, it is indeed referring to Testcontainers in general and to Testcontainers for Rust in particular 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I intended to refer to the crate name here :D

Would you like it to be rewritten?

Comment on lines +24 to +26
One consequence of this decision is that the container _tag_ is typically not configurable for images that ship with `testcontainers`.
Whilst an image behind a tag can also change, image authors tend to preserve compatibility there.
If we were to allow users to change the `tag` of an image, we wouldn't be able to guarantee that it works because we cannot test all combinations.
Copy link
Member

Choose a reason for hiding this comment

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

For this, we added the compatible substitute mechanism to Testcontainers for Java: https://www.testcontainers.org/features/image_name_substitution/#manual-substitution

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure if it is entirely the same. From these docs, I'd say the difference is that testcontainers for Rust doesn't even allow the following line:

DockerImageName.parse("mysql:8.0.24")

Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>

The library should be easy to use.
For example, users should be able to make their own implementation of `Image` without much boilerplate.
In fact, the path forward may very well be that we stop shipping a lot of images in the crate and instead require users to create their own images.

Choose a reason for hiding this comment

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

I highly support this path forward. While yes, there's a lot of often-used containers, the fact anyone can use any container is really the key for me. I use oddball containers and would not expect to upstream them into this crate.

@thomaseizinger thomaseizinger changed the title Add DESIGN_PRINCIPLES.md draft Add DESIGN_PRINCIPLES Feb 10, 2023
@thomaseizinger thomaseizinger merged commit 466f503 into dev Feb 10, 2023
@thomaseizinger
Copy link
Collaborator Author

Sorry for the long delay, let's make use of this!

I am merging this as a signal that we agree on what is in these principles. Help would be much appreciated in the form of:

  • reviewing PRs with these principles in mind
  • writing issues that address / discuss misalignments of the current design with these principles
  • contributing code to fix the above

@DDtKey DDtKey deleted the chore/design-principles branch April 22, 2024 10:08
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.

5 participants