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

fix: server and test stability #313

Merged
merged 11 commits into from
Nov 2, 2023
Merged

Conversation

stevenh
Copy link
Collaborator

@stevenh stevenh commented Oct 26, 2023

Significant refactor of the server to improve stability particularly to address hang on shutdown which was causing significant test instability.

Switch the logger for logback which adds the ability to do file and console logging and more making it easier to debug issues.

Increase max JVM version which was also contributing to server test instability.

Reduce ping timeout from 20 to 10 seconds now the server is more stable, adding in a retry if we get disconnected.

Enable server build clean up.

Rename dev:kill-server to server:kill to be consistent with other jobs.

To improve test stability:

  • Move server tests to their own file as they have been the flaky ones, so its easier if they are grouped together.
  • Move beforeEachTestCase into each test which needs it as beforeEach only gets run from the CLI meaning UI tests were broken.
  • Remove lambdas so we can use skip
  • Ensure temporary files are cleaned up.

@stevenh stevenh changed the title ci: predictable server builds and port option fix: server stability Oct 26, 2023
@stevenh
Copy link
Collaborator Author

stevenh commented Oct 27, 2023

Sods law, running clean here and total failure in CI, think its the server tests, will look more.

@stevenh
Copy link
Collaborator Author

stevenh commented Oct 27, 2023

Nope looks like I used a feature of Java 11+ so all was exploding

Significant refactor of the server to improve stability
particularly to address hang on shutdown which was causing
significant test instability.

Switch the logger for logback which adds the ability to do
file and console logging and more making it easier to debug
issues.

Increase max JVM version which was also contributing to
server test instability.

Reduce ping timeout from 20 to 10 seconds now the server is
more stable, adding in a retry if we get disconnected.

Enable server build cleanup.

Move server tests to their own file as they have been the
flaky ones, so its easier if they are grouped together.

Move beforeEachTestCase into each test which needs it as
beforeEach only gets run from the CLI meaning UI tests
were broken.
@stevenh stevenh force-pushed the chore/build-server2 branch 4 times, most recently from 2c1ccb8 to 3ddda33 Compare October 27, 2023 08:41
Switch to using a matrix strategy for the test workflow to simplify and
make it obvious what versions we're testing as they are all at the top
of each test.

This increases the minimum Java version we test on to 17 LTS and adds
21 LTS.

This means the current runs will be the following:

Tests:
* os: ubuntu-latest
 * node: 18, java: 21 temurin
 * node: 18, java: 21 adopt
 * node: 18, java: 17 temurin
* os: macos-latest, node: 18, java: 21 temurin
* os: windows-latest, node: 18, java: 21 temurin

Coverage report:
* os: debian-bookworm, node: 18, java: none
To be consistent and its shorter, rename dev:kill-server to server:kill.
As per best practice remove the use of lambdas from tests:
https://mochajs.org/#arrow-functions

Also add retries to server tests as they can be racy due to the
interaction with the server.
Ensure that each test which uses copyFilesInTmpDir always removes
the temporary directory to prevent other tests randomly failing due to
additional files being linted.

Also fix incorrect count in GroovyDisableLineAll test.
@stevenh stevenh changed the title fix: server stability fix: server and test stability Oct 27, 2023
Wait for the server to stop processing when we kill it to avoid the next
request from failing to restart the server due to a port in use.
@nvuillam
Copy link
Owner

nvuillam commented Nov 1, 2023

@stevenh do I wait for this PR to be merged before releasing a new version of npm-groovy-lint ?

@stevenh
Copy link
Collaborator Author

stevenh commented Nov 1, 2023

There are already some good fixes in, can you retry the following to see if we can get those in:

We can then do this one in a separate release

@nvuillam
Copy link
Owner

nvuillam commented Nov 1, 2023

@stevenh please let me know when you feel confident enough so I can release a new version then apply it to VsCode GroovyLint :)

If it's just one random test failure, you might consider disabling it on some contexts/platforms if you think it's really random and won't happen often on user configurations

@nvuillam
Copy link
Owner

nvuillam commented Nov 1, 2023

I think we have to be pragmatic, as current version of npm-grovvy-lint fails almost everywhere, i prefer to release a version with a few bugs that we'll solve later, than a version not working at all like the current one ^^

Do I have your go to release from main branch ? :)

@stevenh
Copy link
Collaborator Author

stevenh commented Nov 1, 2023

Unfortunately, it seems to affect all tests randomly. I believe it's to do with the server starting and stopping while in the middle of the test run; which is why I've been working on ensure the server is doing as intended when kill is requested.

I've managed to get a reproducible scenario locally, but just haven't time to dig in this week.

@stevenh
Copy link
Collaborator Author

stevenh commented Nov 1, 2023

The current, main should be better than we had and it has the IPv4 fix in, which is one of the more important ones, so if you can test with a vscode build along side the current main and it works, then go for it.

@stevenh stevenh force-pushed the chore/build-server2 branch 2 times, most recently from 0522c68 to fe32f27 Compare November 2, 2023 08:56
@stevenh
Copy link
Collaborator Author

stevenh commented Nov 2, 2023

Making some good progress here, this is now a combo of the other PR's which have some dependencies when it comes to the tests.

I've had several clean runs on Java 17 both locally and here, but seeing errors on Java 21.

Will continue to investigate, so if you do want to hold off the release until next week, I may be able to crack it.

@stevenh
Copy link
Collaborator Author

stevenh commented Nov 2, 2023

I think I may have a break through, recommend holding fire.

@nvuillam
Copy link
Owner

nvuillam commented Nov 2, 2023

Ok I hold fire :) ( and order a golden statue with your face for saving npm-groovy-lint :D )

Skip some unstable locals tests, to see if this is the only CI test
failure cases.
Use the Remaining values instead of Found values so that exit status is
correct when processing fixes.

Also output the full summary structure which provides useful information
when we trigger the status 1.
Reset the exit status code between each request so that we correctly
report the state of the request not an old one.
Java 21 can't run groovy due to: Unsupported class file major version
64.

The supported Java version is now just 17 LTS as while 8 LTS compiles
it fails to run with a class not found exception when# running:
private static final Logger LOGGER =
   LoggerFactory.getLogger(CodeNarcServer.name)
@stevenh stevenh marked this pull request as ready for review November 2, 2023 11:11
@stevenh
Copy link
Collaborator Author

stevenh commented Nov 2, 2023

Ok it's not how I would want it, all in one PR, but this solves all but one of the issues I've seen.

Seems Java 8 fails on reflection and Java 21 is not supported due to lack of ASM support.

I've marked the unstable tests as skip, but this should put us in a good place for a release.

Remove old simple logger.
Copy link
Owner

@nvuillam nvuillam left a comment

Choose a reason for hiding this comment

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

Amazing ! ;)

@nvuillam nvuillam merged commit c1e7678 into nvuillam:main Nov 2, 2023
6 checks passed
@stevenh stevenh mentioned this pull request Nov 2, 2023
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.

None yet

2 participants