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

Integration Testing Implementation for AppResources #311

Open
wants to merge 11 commits into
base: feature/task_cwms_support
Choose a base branch
from

Conversation

zack-rma
Copy link
Collaborator

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:

  • Tests. Check all that apply:
    • Unit tests created or modified that run during ant test.
    • Integration tests created or modified that run during integration testing
      (Formerly called regression tests.)
    • Test procedure descriptions for manual testing
  • Was relevant documentation updated?
  • Were relevant config element (e.g. XML data) updated as appropriate

If you aren't sure leave unchecked and we will help guide you to want needs changing where.

@zack-rma
Copy link
Collaborator Author

Currently there exists a failing test case due to an unknown EventPort value for the compproc app used in testing. This is causing a connection failure, with the specific location of the issue identified by TODO tasks.

Comment on lines 299 to 324
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();
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cleaned up duplicated logic

@MikeNeilson
Copy link
Collaborator

MikeNeilson commented Dec 31, 2024 via email

Copy link
Collaborator

@rma-rripken rma-rripken left a 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

@zack-rma zack-rma marked this pull request as ready for review December 31, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants