Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix failures in ResourceHeatMapGraphTest #321

Merged
merged 2 commits into from
Jul 30, 2020
Merged

Fix failures in ResourceHeatMapGraphTest #321

merged 2 commits into from
Jul 30, 2020

Conversation

sidheart
Copy link
Contributor

@sidheart sidheart commented Jul 30, 2020

Issue #: #322

Description of changes:
When ResourceHeatMapGraphTest was run after
PerformanceAnalyzerWebServerTest, we noticed connection refused
exceptions that didn't happen when the tests were run in isolation.

This commit makes sure that PerformanceAnalyzerWebServerTest cleans up
after itself so that subsequent tests will run as expected.

Tests:

  • PerformanceAnalyzerWebServerTest
  • ResourceHeatMapGraphTest

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When ResourceHeatMapGraphTest was run after
PerformanceAnalyzerWebServerTest, we noticed connection refused
exceptions that didn't happen when the tests were run in isolation.

This commit makes sure that PerformanceAnalyzerWebServerTest cleans up
after itself so that subsequent tests will run as expected.
@sidheart sidheart requested review from vigyasharma and yojs July 30, 2020 16:53
@sidheart sidheart linked an issue Jul 30, 2020 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jul 30, 2020

Codecov Report

Merging #321 into master will increase coverage by 0.10%.
The diff coverage is 84.96%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #321      +/-   ##
============================================
+ Coverage     67.18%   67.29%   +0.10%     
- Complexity     1971     2004      +33     
============================================
  Files           288      291       +3     
  Lines         12804    12924     +120     
  Branches       1044     1057      +13     
============================================
+ Hits           8603     8697      +94     
- Misses         3838     3853      +15     
- Partials        363      374      +11     
Impacted Files Coverage Δ Complexity Δ
...manceanalyzer/decisionmaker/deciders/Decision.java 58.82% <ø> (ø) 5.00 <0.00> (ø)
...analyzer/decisionmaker/deciders/EmptyFlowUnit.java 66.66% <ø> (ø) 1.00 <0.00> (ø)
...r/rca/framework/api/flow_units/MetricFlowUnit.java 90.90% <ø> (ø) 4.00 <0.00> (ø)
...a/framework/api/flow_units/NodeConfigFlowUnit.java 36.36% <0.00%> (ø) 6.00 <0.00> (ø)
...rca/framework/api/flow_units/ResourceFlowUnit.java 57.89% <0.00%> (ø) 14.00 <0.00> (ø)
..._units/temperature/ClusterTemperatureFlowUnit.java 75.00% <ø> (ø) 1.00 <0.00> (ø)
...ts/temperature/CompactNodeTemperatureFlowUnit.java 23.52% <0.00%> (ø) 2.00 <0.00> (ø)
...ts/temperature/DimensionalTemperatureFlowUnit.java 50.00% <ø> (ø) 2.00 <0.00> (ø)
...ceanalyzer/rca/framework/core/GenericFlowUnit.java 100.00% <ø> (ø) 3.00 <0.00> (ø)
...analyzer/rca/store/ElasticSearchAnalysisGraph.java 100.00% <ø> (ø) 7.00 <0.00> (ø)
... and 48 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1c0f03...d5182ca. Read the comment docs.

@@ -70,9 +70,13 @@ public void tearDown() {
// Unset all SSL settings
if (oldBindHost != null) {
PluginSettings.instance().overrideProperty(PerformanceAnalyzerWebServer.WEBSERVICE_BIND_HOST_NAME, oldBindHost);
} else {
PluginSettings.instance().overrideProperty(PerformanceAnalyzerWebServer.WEBSERVICE_BIND_HOST_NAME, "localhost");
Copy link
Contributor

@vigyasharma vigyasharma Jul 30, 2020

Choose a reason for hiding this comment

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

Are we trying to restore oldBindHost to some default value here? If so, should it be done in setUp() ?
Same for others.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah wait, this is for across tests. Got it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's take oldBindHost as an example. If oldBindHost is null then after this test class ran, we would previously keep the value that PerformanceAnalyzerWebServer changed WEBSERVICE_BIND_HOST_NAME to. This could lead to other tests failing.

The reason this runs as part of a tearDown is to make sure that everything is reset after the test class finishes running.

Copy link
Contributor

@vigyasharma vigyasharma left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this @sidheart . Minor qn for my understanding.

@@ -151,6 +150,12 @@ public static void shutdown() {
clientServers.getHttpServer().stop(0);
clientServers.getNetServer().stop();
clientServers.getNetClient().stop();

try {
Thread.sleep(1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this sleep needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It isn't strictly necessary, I'm mimicking similar logic from RcaControllerTest which does this sleep after stopping its clients and servers.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe it’s a good idea to abstract the shutdown logic with sleep into its own method so that we don’t have to carry the sleep change wherever we use shutdown?

Calls to Assert.fail() obscure the actual Exception in our testing logs.

This commit removes the fail() calls and simply throws instead.
@yojs yojs merged commit b603245 into master Jul 30, 2020
@yojs yojs deleted the rca-test-fixes branch July 30, 2020 20:24
@yojs yojs added the bug Something isn't working label Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceHeatMapGraphTest has failures on the master build
4 participants