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

feat: Add support to seed data when using RunBigQueryContainer #2523

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

Conversation

mtellis2
Copy link

What does this PR do?

Updates the RunBigQueryContainer to optionally use the emulator's data-from-yaml option, allowing users to seed the container with data.

Why is it important?

This give the user of the RunBigQueryContainer the option to seed test data on the container creation/startup.

Related issues

@mtellis2 mtellis2 requested a review from a team as a code owner April 30, 2024 23:36
Copy link

netlify bot commented Apr 30, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 97cc547
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/663284109d8e6c0008c2e164
😎 Deploy Preview https://deploy-preview-2523--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

modules/gcloud/bigquery.go Show resolved Hide resolved
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/gcloud"
)

func ExampleRunBigQueryContainer() {
func TestBigQueryContainer(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We would like to keep some testable examples, as they will land in the pkg.go.dev docs. If you have doubts on when creating a real test or a testable example, please use a testable example when you want to show case how to use the module. Else, a regular test is fine.

modules/gcloud/bigquery_test.go Outdated Show resolved Hide resolved
modules/gcloud/bigquery_test.go Outdated Show resolved Hide resolved
Comment on lines 30 to 35
for _, opt := range opts {
if err := opt.Customize(&req); err != nil {
return nil, err
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

@mdelapenya it wasn't working before without this and that appears to be due to needing to update
req.Cmd = []string{"--project", settings.ProjectID} to req.Cmd = append(req.Cmd, "--project", settings.ProjectID) so that the options added to the cmd are not removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me test this locally, from this branch. Will come back to you later

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, with the addition of the YAML data file, now it's possible to have different settings contributing to the CMD. So it's fine if we append.

My only concern is now related to the usage of the gcloud options across all the emulators 🤔 Do you know if all of them would support passing this YAML file? Else, anybody could add this functional option to e.g. Firestore or Pubsub, and expect something else. I'm not an expert in those services, so you probably have more insights.

Copy link
Author

@mtellis2 mtellis2 May 2, 2024

Choose a reason for hiding this comment

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

Good point, I myself have not used the other emulators but would assume this data yaml functionality would and should only apply for the bigquery emulator. I'm currently not sure of a great way to prevent this in the other gcloud emulators. I think the data.yaml option should be ignored though due to how that CMD is being set.
req.Cmd = []string{...}

It looks like the spanner container might be the only one that differs. It does not have req.Cmd = []string{...}

modules/gcloud/go.mod Outdated Show resolved Hide resolved
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.

2 participants