-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix flaky feature flag test. #6266
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
Conversation
| flags: ['showFlags'], | ||
| }) | ||
| this.showFeatureFlags$ | ||
| .pipe(takeUntil(this.ngUnsubscribe)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff for ngOnInit may look bigger than it is.
This line is new.
| .pipe(takeUntil(this.ngUnsubscribe)) | ||
| .subscribe((showFeatureFlags: boolean) => { | ||
| if (showFeatureFlags) { | ||
| this.featureFlagsDialog = this.dialog.open( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement has changed
| }); | ||
| this.featureFlagsDialog | ||
| .afterClosed() | ||
| .pipe(takeUntil(this.ngUnsubscribe)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is new. Otherwise everything else in ngOnInit should be the same
Feature flag tests have been flaky since the Angular 13/14 upgrade. The problematic change was actually tensorflow#6056, where we started using resetSelectors everywhere. There is one test where a dialog with FeatureFlagDialogContainer is opened. Sometimes FeatureFlagDialogContainer would not complete initialization until after the test was torn down and the selectors reset, meaning NgRx selector calls would fail since state is undefined at that point. To workaround this problem, I allow FeatureFlagDialogContainer to be replaced by a simpler TestableFeatureFlagDialogComponent that has no dependencies on NgRx. This is a strategy we've used elsewhere in the code: https://github.com/tensorflow/tensorboard/blob/dca18190a18ac151437bb6fcd128bc49af617ae5/tensorboard/webapp/metrics/views/card_renderer/scalar_card_container.ts#L206 While I was in this code, I did some other cleanup: * Stop running the feature flag view tests twice. Only run them as part of the feature flag test suite. * When FeatureFlagModalTriggerContainer is destroyed, unsubscribe from some subjects created in ngOnInit. * Remove some unnecessary setup from FeatureFlagModalTriggerContainer tests. Alternative solution: * I thought I could solve the problem by calling dialog.close() in the tests but observed that closing the dialog is not enough to prevent the child component from instantiating after the test.
Feature flag tests have been flaky since the Angular 13/14 upgrade. The problematic change was actually tensorflow#6056, where we started using resetSelectors everywhere. There is one test where a dialog with FeatureFlagDialogContainer is opened. Sometimes FeatureFlagDialogContainer would not complete initialization until after the test was torn down and the selectors reset, meaning NgRx selector calls would fail since state is undefined at that point. To workaround this problem, I allow FeatureFlagDialogContainer to be replaced by a simpler TestableFeatureFlagDialogComponent that has no dependencies on NgRx. This is a strategy we've used elsewhere in the code: https://github.com/tensorflow/tensorboard/blob/dca18190a18ac151437bb6fcd128bc49af617ae5/tensorboard/webapp/metrics/views/card_renderer/scalar_card_container.ts#L206 While I was in this code, I did some other cleanup: * Stop running the feature flag view tests twice. Only run them as part of the feature flag test suite. * When FeatureFlagModalTriggerContainer is destroyed, unsubscribe from some subjects created in ngOnInit. * Remove some unnecessary setup from FeatureFlagModalTriggerContainer tests. Alternative solution: * I thought I could solve the problem by calling dialog.close() in the tests but observed that closing the dialog is not enough to prevent the child component from instantiating after the test.
## Motivation for features / changes In #6458 I fixed a couple of a tests which should have been failing but were sporadically passing. In this PR I believe I have fixed the underlying cause of the flakiness. Thanks #6266 for pointing the way. This broke nightly last night https://github.com/tensorflow/tensorboard/actions/runs/5388986210/jobs/9782358616
Feature flag tests have been flaky since the Angular 13/14 upgrade. The problematic change was actually #6056, where we started using resetSelectors everywhere.
There is one test where a dialog with FeatureFlagDialogContainer is opened. Sometimes FeatureFlagDialogContainer would not complete initialization until after the test was torn down and the selectors reset, meaning NgRx selector calls would fail since state is undefined at that point.
To workaround this problem, I allow FeatureFlagDialogContainer to be replaced by a simpler TestableFeatureFlagDialogComponent that has no dependencies on NgRx. This is a strategy we've used elsewhere in the code:
tensorboard/tensorboard/webapp/metrics/views/card_renderer/scalar_card_container.ts
Line 206 in dca1819
While I was in this code, I did some other cleanup:
Alternative solution: