fix(test): fix flaky test related to ec2.updateStatus #5758
+85
−35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Follow up to: #5698
Error: #5750
First Problem Identified
The current tests in https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/awsService/ec2/explorer/ec2ParentNode.ts do not clear the
PollingSet
in between tests, therefore the timer continues to run. This not only results in inconsistent state between the items in thePollingSet
and the items stored on the parent node itself, but also allows thePollingSet
action to trigger unexpectedly in the middle of another test. When this happens, and the states don't match, theinstanceId
from thePollingSet
could potentially not be found on the parent node, resulting in an undefined node. Then, callingupdateStatus
on this node could explain the error.For this error to happen, the
PollingSet
timer must trigger at a very specific point (in the middle of another test), making it difficult to debug and reproduce, and causing occasional flaky test failures.Second Problem Identified
The tests in https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/awsService/ec2/explorer/ec2InstanceNode.ts setup an unnatural state. The
testNode
sets its parent to thetestParentNode
, buttestParentNode
is unaware this child exists. This is problematic because when the child reports its status as pending to the parent, the parent will throw an error since it can't find the child. (example: https://d1ihu6zq92vp9p.cloudfront.net/7b1e96c7-f2b7-4a8e-927c-b7aa84437960/report.html) This type of state should not be allowed.Solution
Solution to first problem
Solution to second problem
Tangential Work included in PR:
instanceId
is not in map on the parentNode. This will make it easier to catch if something goes wrong.src/test/awsService/ec2/explorer/ec2ParentNode.test.ts
.License: I confirm that my contribution is made under the terms of the Apache 2.0 license.