Skip to content
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

test: Fix logger for export import test #1144

Merged

Conversation

danieljbruce
Copy link
Contributor

The change involves the following:

  • Adding a change to the delay function to use a variable on the mocha test context instead of the currentRetry function which currently does not correspond to a function that lives on the context
  • Adding a setup function which sets up this variable each time any test is run that uses the delay function
  • Adding a test for these two functions to document and ensure they behave in such a way that console.info is actually called and the test is retried the appropriate number of times.

Fixes #1143

The console.info logs will further help diagnose flakey tests in #1122

Console logs should report how far the program made it.
The current test fails silently on test.currentRetry(). What we should do instead is store the current attempt on the mocha test.
The setup for delay function creates a setup for the mocha test to use the delay function. A test is added to make sure that the delay function works properly.
Some logging is in place that does not need to be there which was useful when debugging the problem. This logging should be removed and the only function should be removed.
The console logs from the import/export test should be removed so that the test doesn’t emit any logs as before.
@danieljbruce danieljbruce requested review from a team as code owners August 30, 2023 19:11
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: datastore Issues related to the googleapis/nodejs-datastore API. labels Aug 30, 2023
Remove a log that was leftover from doing testing
any should not be used if we can avoid it. string type needs to be used for the argument of the function.
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: m Pull request size is medium. labels Aug 30, 2023

it('should be sure that the delay function emits console info messages', async function () {
// Override console.info to track the number of times it is called.
console.info = consoleInfoFunction;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this required if the next line is overriding this assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was a typo which needs to be removed.

console log does not need to be assigned twice in a row. This is a typo from what was there before.
only should not be used in the system tests
danieljbruce and others added 8 commits September 29, 2023 15:26
…into fix-logger-for-export-import-test

# Conflicts:
#	system-test/datastore.ts
This test shouldn’t be flakey. It should always pass. We want to correct the race condition in this test.
Reset the log count to account for parameterized tests so that the log count is always set to 0 when it starts a new set of tests.
Now that the less than or equal to sign has been introduced, the assertion check must be modified accordingly to account for the actual number of times the test runs.
The shared context variable on mocha tests is being shared between tests and causing unexpected results. We should use a local variable instead as it seems to work the same way, but is much simpler to understand.
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Oct 2, 2023
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 16, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 16, 2023
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 9, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 9, 2024
@danieljbruce danieljbruce merged commit 6ce47e5 into googleapis:main Jan 9, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/nodejs-datastore API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The import/export test should delay before retrying and should emit info logs
2 participants