这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@franciscovalentecastro
Copy link
Contributor

@franciscovalentecastro franciscovalentecastro commented Oct 23, 2025

Description

Created RunForEachImageAndFeatureFlag and other test helper functions. The goal is that followup PR "diffs" to convert an existing test to be an Otel Logging test is minimal.

Related issue

b/416048587

How has this been tested?

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

@franciscovalentecastro franciscovalentecastro requested review from a team, avilevy18 and jefferbrecht and removed request for a team October 23, 2025 18:25
}

// RunForEachImageAndLoggingSubagent runs a subtest for each image and logging subagent (fluent-bit, otel).
func RunForEachImageAndLoggingSubagent(t *testing.T, testBody func(t *testing.T, imageSpec string, otel bool)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Change it to be agnostic of what you are testing.
RunForEachImageAndFeatureFlag

func RunForEachImageAndFeatureFlag(t *testing.T, []string features, testBody func(t *testing.T, imageSpec string, feature string)) {
gce.RunForEachImage(t, func(t *testing.T, imageSpec string) {
		t.Parallel()
	// Run base case also
	t.Run("default", func(t *testing.T) {
		testBody(t, "default")
	})
	for _, feature := range featureList {
		t.Run(feature, func(t *testing.T) {
			testBody(t, feature)
		})
	}
	})
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

func TestCustomLogFormat(t *testing.T) {
t.Parallel()
RunForEachLoggingSubagent(t, func(t *testing.T, otel bool) {
RunForEachImageAndLoggingSubagent(t, func(t *testing.T, imageSpec string, otel bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would change to:

RunForEachFeatureFlag(t, []string{"otel"}, func(t *testing.T, feature string) {

you can check for your feature by checking the value of feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

// setExperimentalFeatures sets the EXPERIMENTAL_FEATURES environment variable.
func setExperimentalFeatures(ctx context.Context, logger *log.Logger, vm *gce.VM, feature string) error {
return gce.SetEnvironmentVariables(ctx, logger, vm, map[string]string{"EXPERIMENTAL_FEATURES": feature})
// SetupOpsAgentForLoggingSubagent configures the VM and the config depending on the selected logging subagent (fluent-bit, otel)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also make this generic so other features can be used. Maybe pass in a function instead of coding it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@franciscovalentecastro franciscovalentecastro removed the request for review from avilevy18 October 23, 2025 19:54
Copy link
Contributor

@rafaelwestphal rafaelwestphal left a comment

Choose a reason for hiding this comment

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

Thanks!
I think this looks much better now :)

@franciscovalentecastro franciscovalentecastro changed the title [integration_test] Add RunForEachImageAndLoggingSubagent and improve Otel Logging integration tests. [integration_test] Add RunForEachImageAndFeatureFlag and improve Otel Logging integration tests. Oct 23, 2025
@franciscovalentecastro
Copy link
Contributor Author

All 3P app failures are unrelated. Flake on TestPrometheusUntypedMetricsReset test. Merging.

@franciscovalentecastro franciscovalentecastro merged commit 6b838d9 into master Oct 23, 2025
55 of 62 checks passed
@franciscovalentecastro franciscovalentecastro deleted the fcovalente-for-each-sugagent branch October 23, 2025 21:12
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