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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
if (oldPort != null) {
PluginSettings.instance().overrideProperty(PerformanceAnalyzerWebServer.WEBSERVICE_PORT_CONF_NAME, oldPort);
} else {
PluginSettings.instance().overrideProperty(PerformanceAnalyzerWebServer.WEBSERVICE_PORT_CONF_NAME, "9600");
}
if (oldCertificateFilePath != null) {
PluginSettings.instance().overrideProperty(CertificateUtils.CERTIFICATE_FILE_PATH, oldCertificateFilePath);
Expand All @@ -82,6 +86,8 @@ public void tearDown() {
}
if (oldTrustedCasFilePath != null) {
PluginSettings.instance().overrideProperty(CertificateUtils.TRUSTED_CAS_FILE_PATH, oldTrustedCasFilePath);
} else {
PluginSettings.instance().overrideProperty(CertificateUtils.TRUSTED_CAS_FILE_PATH, "");
}
if (oldClientCertificateFilePath != null) {
PluginSettings.instance().overrideProperty(CertificateUtils.CLIENT_CERTIFICATE_FILE_PATH, oldClientCertificateFilePath);
Expand All @@ -91,6 +97,8 @@ public void tearDown() {
}
if (oldClientTrustedCasFilePath != null) {
PluginSettings.instance().overrideProperty(CertificateUtils.CLIENT_TRUSTED_CAS_FILE_PATH, oldClientTrustedCasFilePath);
} else {
PluginSettings.instance().overrideProperty(CertificateUtils.CLIENT_TRUSTED_CAS_FILE_PATH, "");
}
PluginSettings.instance().setHttpsEnabled(oldHttpsEnabled);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

public class ResourceHeatMapGraphTest {
Expand Down Expand Up @@ -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?

} catch (InterruptedException ie) {
ie.printStackTrace();
}
}

private static class AnalysisGraphX extends ElasticSearchAnalysisGraph {
Expand Down