Skip to content

Commit 7ffe158

Browse files
authored
Backport/backport 204/208 to 2.0 (#216)
* Fixing header key value issue (#203) (#204) Signed-off-by: Ankit Jain <[email protected]> (cherry picked from commit 778e18a) * Changing integration tests to use pa agent for header validation and e2e testing Signed-off-by: Ankit Jain <[email protected]> (cherry picked from commit b9425f2)
1 parent f7060b0 commit 7ffe158

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

src/main/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerResourceProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
181181
try {
182182
Map<String, List<String>> map = httpURLConnection.getHeaderFields();
183183
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
184-
finalResponse.addHeader(entry.getKey(), entry.getValue().toString());
184+
if (entry.getKey() != null && entry.getKey().length() != 0) {
185+
for (String value : entry.getValue()) {
186+
finalResponse.addHeader(entry.getKey(), value);
187+
}
188+
}
185189
}
186190
// Send Response back to callee
187191
channel.sendResponse(finalResponse);

src/test/java/org/opensearch/performanceanalyzer/ITConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ITConfig {
2020
private String transportEndpoint;
2121

2222
// The port number to use for
23-
private int paPort = 9600;
23+
private int paPort = 9200;
2424

2525
public ITConfig() {
2626
https = Boolean.parseBoolean(System.getProperty("tests.https"));

src/test/java/org/opensearch/performanceanalyzer/integ_test/CpuMetricsIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public void checkLegacyCPUUtilization() throws Exception {
3939
public void checkCPUUtilization(String paBaseUri) throws Exception {
4040
// read metric from local node
4141
List<JsonResponseNode> responseNodeList =
42-
readMetric(paBaseUri + "/metrics?metrics=CPU_Utilization&agg=sum");
42+
readMetric(paBaseUri + "/_agent/metrics?metrics=CPU_Utilization&agg=sum");
4343
Assert.assertEquals(1, responseNodeList.size());
4444
validatePerNodeCPUMetric(responseNodeList.get(0));
4545

4646
// read metric from all nodes in cluster
4747
responseNodeList =
48-
readMetric(paBaseUri + "/metrics?metrics=CPU_Utilization&agg=sum&nodes=all");
48+
readMetric(paBaseUri + "/_agent/metrics?metrics=CPU_Utilization&agg=sum&nodes=all");
4949
int nodeNum = getNodeIDs().size();
5050
Assert.assertEquals(nodeNum, responseNodeList.size());
5151
for (int i = 0; i < nodeNum; i++) {

src/test/java/org/opensearch/performanceanalyzer/integ_test/HeapMetricsIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,16 @@ private void checkHeapMetric(
8888
throws Exception {
8989
// read metric from local node
9090
List<JsonResponseNode> responseNodeList =
91-
readMetric(paBaseUri + "/metrics/?metrics=" + metric.toString() + "&agg=max");
91+
readMetric(
92+
paBaseUri + "/_agent/metrics/?metrics=" + metric.toString() + "&agg=max");
9293
Assert.assertEquals(1, responseNodeList.size());
9394
validateHeapMetric(responseNodeList.get(0), metric, metricValidator);
9495

9596
// read metric from all nodes in cluster
9697
responseNodeList =
9798
readMetric(
9899
paBaseUri
99-
+ "/metrics/?metrics="
100+
+ "/_agent/metrics/?metrics="
100101
+ metric.toString()
101102
+ "&agg=max&nodes=all");
102103
int nodeNum = getNodeIDs().size();

src/test/java/org/opensearch/performanceanalyzer/integ_test/PageFaultMetricsIT.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ public void checkLegacyPaging_MajfltRate() throws Exception {
3939
public void checkPaging_MajfltRate(String paBaseUri) throws Exception {
4040
// read metric from local node
4141
List<JsonResponseNode> responseNodeList =
42-
readMetric(paBaseUri + "/metrics?metrics=Paging_MajfltRate&agg=max");
42+
readMetric(paBaseUri + "/_agent/metrics?metrics=Paging_MajfltRate&agg=max");
4343
Assert.assertEquals(1, responseNodeList.size());
4444
validateMajorPageFaultMetric(responseNodeList.get(0));
4545

4646
// read metric from all nodes in cluster
4747
responseNodeList =
48-
readMetric(paBaseUri + "/metrics?metrics=Paging_MajfltRate&agg=max&nodes=all");
48+
readMetric(
49+
paBaseUri + "/_agent/metrics?metrics=Paging_MajfltRate&agg=max&nodes=all");
4950
int nodeNum = getNodeIDs().size();
5051
Assert.assertEquals(nodeNum, responseNodeList.size());
5152
for (int i = 0; i < nodeNum; i++) {
@@ -66,13 +67,14 @@ public void checkLegacyPaging_MinfltRate() throws Exception {
6667
public void checkPaging_MinfltRate(String paBaseUri) throws Exception {
6768
// read metric from local node
6869
List<JsonResponseNode> responseNodeList =
69-
readMetric(paBaseUri + "/metrics?metrics=Paging_MinfltRate&agg=max");
70+
readMetric(paBaseUri + "/_agent/metrics?metrics=Paging_MinfltRate&agg=max");
7071
Assert.assertEquals(1, responseNodeList.size());
7172
validateMinorPageFaultMetric(responseNodeList.get(0));
7273

7374
// read metric from all nodes in cluster
7475
responseNodeList =
75-
readMetric(paBaseUri + "/metrics?metrics=Paging_MinfltRate&agg=max&nodes=all");
76+
readMetric(
77+
paBaseUri + "/_agent/metrics?metrics=Paging_MinfltRate&agg=max&nodes=all");
7678
int nodeNum = getNodeIDs().size();
7779
Assert.assertEquals(nodeNum, responseNodeList.size());
7880
for (int i = 0; i < nodeNum; i++) {
@@ -93,12 +95,13 @@ public void checkLegacyPaging_RSS() throws Exception {
9395
public void checkPaging_RSS(String paBaseUri) throws Exception {
9496
// read metric from local node
9597
List<JsonResponseNode> responseNodeList =
96-
readMetric(paBaseUri + "/metrics?metrics=Paging_RSS&agg=max");
98+
readMetric(paBaseUri + "/_agent/metrics?metrics=Paging_RSS&agg=max");
9799
Assert.assertEquals(1, responseNodeList.size());
98100
validatePagingRSSMetric(responseNodeList.get(0));
99101

100102
// read metric from all nodes in cluster
101-
responseNodeList = readMetric(paBaseUri + "/metrics?metrics=Paging_RSS&agg=max&nodes=all");
103+
responseNodeList =
104+
readMetric(paBaseUri + "/_agent/metrics?metrics=Paging_RSS&agg=max&nodes=all");
102105
int nodeNum = getNodeIDs().size();
103106
Assert.assertEquals(nodeNum, responseNodeList.size());
104107
for (int i = 0; i < nodeNum; i++) {

0 commit comments

Comments
 (0)