-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: develop
Are you sure you want to change the base?
[JShellAPI][Testing] Setting up First Integration Test - Simple code snippet evaluation scenario #50
Conversation
Note: this includes adding a 1st class for tests;
Note: this includes changes and improvements in gradle.build files;
3502cb7
to
c8747e1
Compare
… and test classes
I don't have time to do a review, so I'll just write here.
|
Hello @Alathreon !
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) :
|
e7c2450
to
cccd5f1
Compare
JShellAPI/src/test/java/org/togetherjava/jshellapi/JShellApiTests.java
Outdated
Show resolved
Hide resolved
JShellAPI/src/test/java/org/togetherjava/jshellapi/JShellApiTests.java
Outdated
Show resolved
Hide resolved
JShellAPI/src/test/java/org/togetherjava/jshellapi/JShellApiTests.java
Outdated
Show resolved
Hide resolved
ae5fb7c
to
4f4ec50
Compare
JShellAPI/src/main/java/org/togetherjava/jshellapi/dto/JShellResult.java
Outdated
Show resolved
Hide resolved
JShellAPI/src/main/java/org/togetherjava/jshellapi/service/DockerService.java
Outdated
Show resolved
Hide resolved
JShellAPI/src/main/java/org/togetherjava/jshellapi/rest/ApiEndpoints.java
Outdated
Show resolved
Hide resolved
362653c
to
89a7c65
Compare
JShellAPI/README.MD
Outdated
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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What ?
There was a problem hiding this comment.
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
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); | ||
} | ||
} |
There was a problem hiding this comment.
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.
String[] imageNameParts = | ||
this.jshellWrapperImageName.split(Config.JSHELL_WRAPPER_IMAGE_NAME_TAG); | ||
|
||
String baseImageName = imageNameParts[0]; |
There was a problem hiding this comment.
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.
README.md
Outdated
## 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. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
89a7c65
to
1d77dfa
Compare
The rate at which the session killer will check and delete session, in seconds, see [Session timeout](#Session-timeout). |
There was a problem hiding this comment.
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
1d77dfa
to
8cc1485
Compare
Pull-request
Changes
Description
This PR is about setting up a first working integration test for JShellAPI only, it contains the following :
POST/jshel/eval
.Note: this PR is about setting the roadmap for testing strategy for JShellAPI only. It doesn't close the relevant issue.