Skip to content

test(cloud): add projectId, serviceEmail cloud tests#214

Draft
brianquinlan wants to merge 10 commits intogoogleapis:mainfrom
brianquinlan:google_cloud_e2e
Draft

test(cloud): add projectId, serviceEmail cloud tests#214
brianquinlan wants to merge 10 commits intogoogleapis:mainfrom
brianquinlan:google_cloud_e2e

Conversation

@brianquinlan
Copy link
Copy Markdown
Contributor

@brianquinlan brianquinlan commented Mar 23, 2026

Adds integration tests (run on Google Cloud Build) for:

  • computeProjectId
  • serviceAccountEmailFromMetadataServer

@brianquinlan brianquinlan marked this pull request as draft March 23, 2026 23:24
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 introduces end-to-end tests for the google_cloud package, including a dart_test.yaml configuration file and the test implementation in e2e_test.dart. The tests cover project ID retrieval, service account information, logging, and error handling. My review identified a potential resource leak in the test code where an HttpClient instance is not being closed after use, and I've provided a suggestion to fix it.

Comment thread pkgs/google_cloud/test/e2e_test.dart Outdated
Comment on lines +51 to +55
final client = HttpClient();
final req = await client.getUrl(gceMetadataUrl(''));
final res = await req.close();
await res.drain<void>();
return Response.ok('Metadata OK');
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

The HttpClient instance created here is not closed, which can lead to resource leaks. You should ensure client.close() is called to properly release system resources. Using a try...finally block is a good pattern to ensure the client is closed even if errors occur.

                final client = HttpClient();
                try {
                  final req = await client.getUrl(gceMetadataUrl(''));
                  final res = await req.close();
                  await res.drain<void>();
                  return Response.ok('Metadata OK');
                } finally {
                  client.close();
                }

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 introduces end-to-end tests for the google_cloud package, including a new dart_test.yaml configuration file. The tests validate key functionalities such as project ID retrieval, service account access, logging, and metadata server connectivity. While the additions are valuable, I've identified a potential resource leak in the test server implementation where an HttpClient is not properly closed. I've provided a specific suggestion to address this. For future contributions, it would be helpful to include a more descriptive pull request title and body to provide better context for reviewers.

Comment thread pkgs/google_cloud/test/e2e_test.dart Outdated
Comment on lines +50 to +60
try {
final client = HttpClient();
final req = await client.getUrl(gceMetadataUrl(''));
final res = await req.close();
await res.drain<void>();
return Response.ok('Metadata OK');
} catch (e) {
return Response.internalServerError(
body: 'Metadata failed: $e',
);
}
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.

high

The HttpClient instance created here is not being closed, which can lead to resource leaks. An HttpClient should always be closed after use to release system resources. The recommended way to ensure this is to use a try...finally block, calling client.close() in the finally part.

              final client = HttpClient();
              try {
                final req = await client.getUrl(gceMetadataUrl(''));
                final res = await req.close();
                await res.drain<void>();
                return Response.ok('Metadata OK');
              } catch (e) {
                return Response.internalServerError(
                  body: 'Metadata failed: $e',
                );
              } finally {
                client.close();
              }

@brianquinlan brianquinlan changed the title Fixes test(cloud): add projectId, serviceEmail cloud tests Mar 24, 2026
@brianquinlan brianquinlan marked this pull request as ready for review March 25, 2026 14:49
@brianquinlan brianquinlan requested a review from natebosch March 25, 2026 14:49
@brianquinlan brianquinlan assigned natebosch and unassigned natebosch Mar 25, 2026
@brianquinlan brianquinlan removed the request for review from natebosch March 25, 2026 14:49
@brianquinlan brianquinlan marked this pull request as draft March 25, 2026 14:51
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