Skip to content

fix: logging for flaky MySQLSchema E2E test#3198

Merged
csviri merged 4 commits intooperator-framework:nextfrom
csviri:mysql-test-fix
Mar 2, 2026
Merged

fix: logging for flaky MySQLSchema E2E test#3198
csviri merged 4 commits intooperator-framework:nextfrom
csviri:mysql-test-fix

Conversation

@csviri
Copy link
Collaborator

@csviri csviri commented Mar 2, 2026

Signed-off-by: Attila Mészáros a_meszaros@apple.com

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 2, 2026
@csviri csviri marked this pull request as ready for review March 2, 2026 13:32
Copilot AI review requested due to automatic review settings March 2, 2026 13:32
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 2, 2026
@openshift-ci openshift-ci bot requested review from metacosm and xstefank March 2, 2026 13:32
@csviri
Copy link
Collaborator Author

csviri commented Mar 2, 2026

@xstefank @metacosm this mainly adds proper logging to tests, was retrying few times but it did not fails, so we will see it in case it fails in subsequent PR after this is merged.

@csviri csviri changed the title fix: flaky MySQLSchema E2E test fix: logging for flaky MySQLSchema E2E test Mar 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the MySQL schema sample operator’s E2E test and related runtime/test logging to improve stability and diagnostics.

Changes:

  • Switch E2E assertions from Hamcrest to AssertJ.
  • Adjust Log4j2 configuration (root level and targeted logger).
  • Add a debug log line when deleting schemas and add AssertJ as a test dependency.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sample-operators/mysql-schema/src/test/java/io/javaoperatorsdk/operator/sample/MySQLSchemaOperatorE2E.java Replaces Hamcrest assertions with AssertJ assertions in the E2E test.
sample-operators/mysql-schema/src/main/resources/log4j2.xml Changes logging configuration (adds a named configuration, introduces a package logger, reduces root log level).
sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/dependent/SchemaDependentResource.java Adds a debug log statement during schema deletion.
sample-operators/mysql-schema/pom.xml Adds AssertJ as an explicit test dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 19 to 30
<Configuration name="TestConfig" status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %threadId %-30c{1.} [%-5level] %msg p:[%X{resource.name}:%X{resource.namespace}:%X{resource.resourceVersion}] e:[%X{eventsource.name}:%X{eventsource.event.action}:%X{eventsource.event.resource.name}:%X{eventsource.event.resource.namespace}:%X{eventsource.event.resource.resourceVersion}] %n%throwable"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<Logger level="debug" name="io.javaoperatorsdk.operator" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="info">
<AppenderRef ref="Console"/>
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

sample-operators/mysql-schema/src/main/resources/log4j2.xml is a runtime (main) resource, but the configuration is now named TestConfig and changes the global logging behavior (root debug -> info). This diverges from the other sample operators’ main Log4j2 configs (e.g. sample-operators/leader-election/src/main/resources/log4j2.xml:19-27 uses an unnamed <Configuration> with root debug) and may make debugging the sample harder. If this change is intended only for stabilizing tests, consider moving it to src/test/resources/log4j2.xml (so it only affects tests), or keep main logging consistent and add targeted logger overrides instead.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@csviri this might be valid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ahh, yes forgot to push the change for this, thank you, now should look better, actually might update the leader election sample, since root logger should not be on debug.

csviri added 3 commits March 2, 2026 15:52
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Comment on lines 19 to 30
<Configuration name="TestConfig" status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %threadId %-30c{1.} [%-5level] %msg p:[%X{resource.name}:%X{resource.namespace}:%X{resource.resourceVersion}] e:[%X{eventsource.name}:%X{eventsource.event.action}:%X{eventsource.event.resource.name}:%X{eventsource.event.resource.namespace}:%X{eventsource.event.resource.resourceVersion}] %n%throwable"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<Logger level="debug" name="io.javaoperatorsdk.operator" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="info">
<AppenderRef ref="Console"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@csviri this might be valid

Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@csviri csviri requested a review from Copilot March 2, 2026 16:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


@Override
public void delete(MySQLSchema primary, Context<MySQLSchema> context) {
log.debug("Deleting schema");
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The new debug log line is quite generic and may not help diagnose which resource is being deleted during flaky runs. Consider including identifying details (e.g., schema name/namespace and possibly username/secret when available) so the log can be correlated to a specific reconciliation/deletion event.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that those are already included from MDC

@csviri csviri merged commit 76ec20a into operator-framework:next Mar 2, 2026
29 checks passed
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.

4 participants