-
Notifications
You must be signed in to change notification settings - Fork 4
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
Integration Testing Implementation for AppResources #311
base: feature/task_cwms_support
Are you sure you want to change the base?
Integration Testing Implementation for AppResources #311
Conversation
Currently there exists a failing test case due to an unknown |
opendcs-rest-api/src/main/java/org/opendcs/odcsapi/res/AppResources.java
Outdated
Show resolved
Hide resolved
else if (!cli.isPresent()) | ||
{ | ||
Integer port = appStat.getEventPort(); | ||
if (port == null) | ||
return ApiHttpUtil.createResponse(new ArrayList<ApiAppEvent>()); | ||
{ | ||
return Response.status(HttpServletResponse.SC_OK) | ||
.entity(new ArrayList<ApiAppEvent>()).build(); | ||
} | ||
apiEventClient = new ApiEventClient(appId, appStat.getHostname(), port, appStat.getAppName(), appStat.getPid()); | ||
apiEventClient.connect(); | ||
LOGGER.debug("Connected to {}:{}", appStat.getHostname(), port); | ||
clientConnectionCache.addApiEventClient(apiEventClient, session.getId()); | ||
} | ||
else if (appStat.getPid() != null && appStat.getPid() != cli.get().getPid()) | ||
{ | ||
// This means that the app was stopped and restarted since we last checked for events. | ||
// Close the old client and open a new one with the correct PID. | ||
cli.ifPresent(c -> clientConnectionCache.removeApiEventClient(c, session.getId())); | ||
|
||
|
||
Integer port = appStat.getEventPort(); | ||
if (port == null) | ||
return ApiHttpUtil.createResponse(new ArrayList<ApiAppEvent>()); // app not running | ||
{ | ||
return Response.status(HttpServletResponse.SC_OK) | ||
.entity(new ArrayList<ApiAppEvent>()).build(); | ||
} | ||
apiEventClient = new ApiEventClient(appId, appStat.getHostname(), port, appStat.getAppName(), appStat.getPid()); | ||
apiEventClient.connect(); |
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.
This logic is being duplicated. Its unclear to me why the first branch doesn't need to check appStat.getPid() != null but the second branch does. In the second branch you don't need to check cli.ifPresent it has to be present or you would be in the first branch. I think these two could be combined and the code would be clearer.
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.
Cleaned up duplicated logic
Not sure if it affects much of the current work but fyi we are planning on
removing that event system in favor of standard monitoring tools, likely
opentelemtry.
Which is not to say you dont have to deal with it just maybe dont put
excessive energy in beyond making sure things start. Might be easier to
make sure it's more optional at the OpenDCS core level.
…On Tue, Dec 31, 2024, 7:42 AM Ryan Ripken ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
opendcs-rest-api/src/main/java/org/opendcs/odcsapi/res/AppResources.java
<#311 (comment)>:
> else if (!cli.isPresent())
{
Integer port = appStat.getEventPort();
if (port == null)
- return ApiHttpUtil.createResponse(new ArrayList<ApiAppEvent>());
+ {
+ return Response.status(HttpServletResponse.SC_OK)
+ .entity(new ArrayList<ApiAppEvent>()).build();
+ }
apiEventClient = new ApiEventClient(appId, appStat.getHostname(), port, appStat.getAppName(), appStat.getPid());
apiEventClient.connect();
- LOGGER.debug("Connected to {}:{}", appStat.getHostname(), port);
clientConnectionCache.addApiEventClient(apiEventClient, session.getId());
}
else if (appStat.getPid() != null && appStat.getPid() != cli.get().getPid())
{
// This means that the app was stopped and restarted since we last checked for events.
// Close the old client and open a new one with the correct PID.
cli.ifPresent(c -> clientConnectionCache.removeApiEventClient(c, session.getId()));
-
+
Integer port = appStat.getEventPort();
if (port == null)
- return ApiHttpUtil.createResponse(new ArrayList<ApiAppEvent>()); // app not running
+ {
+ return Response.status(HttpServletResponse.SC_OK)
+ .entity(new ArrayList<ApiAppEvent>()).build();
+ }
apiEventClient = new ApiEventClient(appId, appStat.getHostname(), port, appStat.getAppName(), appStat.getPid());
apiEventClient.connect();
This logic is being duplicated. Its unclear to me why the first branch
doesn't need to check appStat.getPid() != null but the second branch does.
In the second branch you don't need to check cli.ifPresent it has to be
present or you would be in the first branch. I think these two could be
combined and the code would be clearer.
—
Reply to this email directly, view it on GitHub
<#311 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB44KCHYRAIJ4Q6TWDGJINT2IK3QFAVCNFSM6AAAAABUMWWKKKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMRWGU3DCMZYGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
opendcs-rest-api/src/main/java/org/opendcs/odcsapi/res/AppResources.java
Outdated
Show resolved
Hide resolved
opendcs-rest-api/src/main/java/org/opendcs/odcsapi/res/AppResources.java
Outdated
Show resolved
Hide resolved
opendcs-rest-api/src/main/java/org/opendcs/odcsapi/res/AppResources.java
Outdated
Show resolved
Hide resolved
opendcs-rest-api/src/main/java/org/opendcs/odcsapi/res/OpenDcsResource.java
Outdated
Show resolved
Hide resolved
opendcs-rest-api/src/test/java/org/opendcs/odcsapi/res/AppResourcesTest.java
Outdated
Show resolved
Hide resolved
opendcs-rest-api/src/test/java/org/opendcs/odcsapi/res/AppResourcesTest.java
Outdated
Show resolved
Hide resolved
opendcs-rest-api/src/test/java/org/opendcs/odcsapi/res/it/AppResourcesIT.java
Outdated
Show resolved
Hide resolved
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.
Resolve my other comments
…est, cleaned up event tests
Problem Description
Fixes #220.
Solution
Implements integration testing against OpenTSDB.
Builds upon changes in #274
how you tested the change
Includes integration tests.
Where the following done:
(Formerly called regression tests.)
If you aren't sure leave unchecked and we will help guide you to want needs changing where.