Skip to content

Conversation

@bmd3k
Copy link
Contributor

@bmd3k bmd3k commented Mar 23, 2023

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:

@Input() DataDownloadComponent: ComponentType<any> =

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.

@bmd3k bmd3k requested a review from rileyajones March 23, 2023 11:29
flags: ['showFlags'],
})
this.showFeatureFlags$
.pipe(takeUntil(this.ngUnsubscribe))
Copy link
Contributor Author

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(
Copy link
Contributor Author

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))
Copy link
Contributor Author

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

@bmd3k bmd3k merged commit e5d1771 into tensorflow:master Mar 24, 2023
bmd3k added a commit to bmd3k/tensorboard that referenced this pull request Mar 25, 2023
bmd3k added a commit that referenced this pull request Mar 25, 2023
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
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.
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
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.
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
rileyajones added a commit that referenced this pull request Jun 27, 2023
## 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
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