8000 test(source/dgraph): migrate integration tests to testcontainers by emagda97 · Pull Request #4408 · googleapis/mcp-toolbox · GitHub
[go: up one dir, main page]

Skip to content

test(source/dgraph): migrate integration tests to testcontainers - #4408

Draft
emagda97 wants to merge 1 commit into
mainfrom
fix/dgraph-testcontainers
Draft

emagda97 wants to merge 1 commit into
mainfrom
fix/dgraph-testcontainers

Conversation

@emagda97
@emagda97 emagda97 commented Nov 3, 2026 •
Copy link
Copy Markdown
Collaborator

Description

Migrates the Dgraph integration test to testcontainers and re-enables its CI shard.

PR Checklist

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure you have manually reviewed the entire diff before requesting a
    review
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request re-enables the Dgraph integration tests in the Cloud Build CI pipeline and configures them to run conditionally based on file changes. To support this, the Dgraph integration tests are updated to spin up an ephemeral Dgraph container using testcontainers-go when the DGRAPH_URL environment variable is not set. Feedback on the changes suggests improving the robustness of the container health check by decoding the JSON response instead of performing a fragile substring match on the raw response body.

Comment on lines +62 to +65
WithResponseMatcher(func(body io.Reader) bool {
b, err := io.ReadAll(body)
return err == nil && strings.Contains(string(b), `"status":"healthy"`)
}).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using strings.Contains with a hardcoded JSON substring like "status":"healthy" is fragile because it is sensitive to whitespace formatting (e.g., spaces after colons like "status": "healthy"). Additionally, simply checking for the substring "healthy" can be problematic if the status is "unhealthy" (which contains the substring "healthy").

To make this check robust and immune to formatting differences, decode the JSON response and inspect the status field directly.

			WithResponseMatcher(func(body io.Reader) bool {
				var result []struct {
					Status string
				}
				if json.NewDecoder(body).Decode(&result) != nil {
					return false
				}
				for _, info := range result {
					if info.Status == "healthy" {
						return true
					}
				}
				return false
			}).

@emagda97
emagda97 force-pushed the fix/dgraph-testcontainers branch 2 times, most recently from 0e937e9 to 1d00917 Compare November 4, 2026 21:50
Run the tests against an ephemeral dgraph/standalone container instead.
Setting DGRAPH_URL still runs them against an external instance.
@emagda97
emagda97 force-pushed the fix/dgraph-testcontainers branch from 1d00917 to 6979127 Compare November 4, 2026 21:59

This branch has not been deployed

No deployments
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.

1 participant

0