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

[JShellAPI][Testing] Setting up First Integration Test - Simple code snippet evaluation scenario #50

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

firasrg
Copy link
Member

@firasrg firasrg commented Aug 10, 2024

Pull-request

Changes

  • Some changes in gradle files to
  • New integration test

Description

This PR is about setting up a first working integration test for JShellAPI only, it contains the following :

  • New global property in root project'd gradle.build file to share JShellWrapper's image name across subprojects gradle.build files and Java files as well.
  • [JShellAPI] New custom tasks in gradle.build file for docker image : build + remove;
  • [JShellAPI] New Integration tests class with a 1st working test on WS POST/jshel/eval .

Note: this PR is about setting the roadmap for testing strategy for JShellAPI only. It doesn't close the relevant issue.

Note: this includes adding a 1st class for tests;
@firasrg firasrg requested review from a team as code owners August 10, 2024 16:48
Note: this includes changes and improvements in gradle.build files;
@firasrg firasrg force-pushed the testing/30-add-integration-tests branch from 3502cb7 to c8747e1 Compare August 10, 2024 16:59
@firasrg firasrg changed the title [JShellAPI][Testing] Setting up First Integration Test - Simple code snippet evaluation [JShellAPI][Testing] Setting up First Integration Test - Simple code snippet evaluation scenario Aug 11, 2024
@Alathreon
Copy link
Contributor

I don't have time to do a review, so I'll just write here.
There are two problems :

  • Your test is too complicated to test something too simple, you need to simplify it, create methods or classes for this so your test can be as simple as for example assertEquals(sendEval("2+2"), new JShellResult(...))
  • Also include a test to test state. For example, you can send an eval "var list = List.of(1, 2, 3)" and then send a separate eval like "println(list)"

@firasrg
Copy link
Member Author

firasrg commented Sep 12, 2024

Hello @Alathreon !

Your test is too complicated to test something too simple

I think that my test code is pretty simple, it uses WebTestClient API to establish test in a smooth way (ig it's a good practice as mentioned in spring docs) :

create methods or classes for this so your test can be as simple as for example assertEquals(sendEval("2+2"), new JShellResult(...))

I'm not certain i understand this sorry, can u elaborate ?

@firasrg firasrg force-pushed the testing/30-add-integration-tests branch from e7c2450 to cccd5f1 Compare September 13, 2024 20:29
JShellAPI/README.MD Outdated Show resolved Hide resolved
JShellAPI/README.MD Outdated Show resolved Hide resolved
JShellAPI/README.MD Outdated Show resolved Hide resolved
JShellAPI/README.MD Outdated Show resolved Hide resolved
JShellAPI/README.MD Outdated Show resolved Hide resolved
@firasrg firasrg force-pushed the testing/30-add-integration-tests branch from ae5fb7c to 4f4ec50 Compare September 20, 2024 19:51
JShellAPI/src/main/resources/application.yaml Outdated Show resolved Hide resolved
JShellAPI/README.MD Outdated Show resolved Hide resolved
JShellAPI/README.MD Outdated Show resolved Hide resolved
@firasrg firasrg force-pushed the testing/30-add-integration-tests branch 3 times, most recently from 362653c to 89a7c65 Compare September 24, 2024 19:23
Comment on lines 103 to 104
The rate at which the session killer will check and delete session, in seconds, see [Session timeout](#Session-timeout). No newline at end of file
The rate at which the session killer will check and delete session, in seconds, see [Session timeout](#Session-timeout).
Copy link
Contributor

Choose a reason for hiding this comment

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

What ?

Copy link
Member Author

Choose a reason for hiding this comment

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

huh i dunno what's this, i'll revert

Comment on lines 5 to 18
public final class Utils {
private Utils() {}

public static boolean validateJShellWrapperImageName(String imageName) {
if (!StringUtils.hasText(imageName)
|| !imageName.endsWith(Config.JSHELL_WRAPPER_IMAGE_NAME_TAG)) {
return false;
}

final String imageNameFirstPart = imageName.split(Config.JSHELL_WRAPPER_IMAGE_NAME_TAG)[0];

return StringUtils.hasText(imageNameFirstPart);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this to a static private method in Config, since it's only used once and should only be handled by Config.

Comment on lines 66 to 69
String[] imageNameParts =
this.jshellWrapperImageName.split(Config.JSHELL_WRAPPER_IMAGE_NAME_TAG);

String baseImageName = imageNameParts[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this in the constructor.

JShellAPI/src/main/resources/application.yaml Outdated Show resolved Hide resolved
README.md Outdated
Comment on lines 51 to 57
## Testing
**JShellWrapper** Docker image lifecycle is handled during tests.

The image name is injected from the root [build.gradle](./build.gradle) file, to JShellAPI project's [build.gradle](./JShellAPI/build.gradle) file and also to its [application.yaml](./JShellAPI/src/main/resources/application.yaml).

- JShellWrapper Docker Image is built before the tests run.
- **Container & Cleanup**: After the tests finish, the container and image are removed to ensure a clean environment.
Copy link
Contributor

Choose a reason for hiding this comment

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

How many times I have to repeat this, readme isn't documentation nor user manual, you are supposed to tell the user how to run the tests, not how the project works.

private WebTestClient webTestClient;

@Autowired
private Config appConfig;
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you handle custom config ? Like if for one test, you need to use custom config ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, but I don't think that would be a good idea as it's an integration-test, and it must verify what exactly happens in real scenario (with the real config).

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is that the real world config has timers from the minute to the dozen of minutes, you do not want a test to last for 30 minute because you wanted to check if a session correctly disapear after 30 minutes...

Copy link
Member Author

@firasrg firasrg Sep 25, 2024

Choose a reason for hiding this comment

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

in that case we may create a common config and separate config

@firasrg firasrg force-pushed the testing/30-add-integration-tests branch from 89a7c65 to 1d77dfa Compare September 28, 2024 16:43
The rate at which the session killer will check and delete session, in seconds, see [Session timeout](#Session-timeout).
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI, this change is due to spotlessApply task

@firasrg firasrg force-pushed the testing/30-add-integration-tests branch from 1d77dfa to 8cc1485 Compare September 28, 2024 19:39
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.

Add functionnal tests to JShellAPI ?
3 participants