Further updates to the auto-test environment
Aligned python to python 3
Added test script of ric re-sync
Preparing for secure port of simulator and agent
Integrated SNDC ONAP adapter to the test environment
MR-stub now support long poll and message limits
Change-Id: I280f173f811a9fd859c4cc5234084a5a20f77a90
Issue-ID: NONRTRIC-154
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js
index da71a9e..76739f3 100644
--- a/test/simulator-group/sim-monitor.js
+++ b/test/simulator-group/sim-monitor.js
@@ -21,10 +21,14 @@
// Presents a web page on localhost:9999/mon
var LOCALHOST="http://127.0.0.1:"
+var LOCALHOSTSECURE="https://127.0.0.1:"
+//This var may switch between LOCALHOST and LOCALHOSTSECURE
+var SIM_LOCALHOST=LOCALHOST
var MRSTUB_PORT="3905"
var AGENT_PORT="8081"
var CR_PORT="8090"
var http = require('http');
+var https = require('https');
var express = require('express');
var app = express();
@@ -38,28 +42,37 @@
})
//Get parameter valuue from other server
-function getSimCtr(url, index, cb) {
+function getSimCtr(httpx, url, index, cb) {
var data = '';
- http.get(url, (resp) => {
- // A chunk of data has been recieved.
- resp.on('data', (chunk) => {
- data += chunk;
- });
+ var http_type=http
+ if (httpx=="https") {
+ http_type=https
+ }
+ console.log("URL: "+ url + " - " + httpx)
+ try {
+ http_type.get(url, (resp) => {
+ // A chunk of data has been recieved.
+ resp.on('data', (chunk) => {
+ data += chunk;
+ });
- // The whole response has been received.
- resp.on('end', () => {
- var code=resp.statusCode
- if (code > 199 && code < 300) {
- cb(data, index);
- } else {
- cb("not found", index);
- }
- });
+ // The whole response has been received.
+ resp.on('end', () => {
+ var code=resp.statusCode
+ if (code > 199 && code < 300) {
+ cb(data, index);
+ } else {
+ cb("not found", index);
+ }
+ });
- }).on("error", (err) => {
- console.log("Error: " + err.message);
- cb("no response", index);
- });
+ }).on("error", (err) => {
+ console.log("Error: " + err.message);
+ cb("no response", index);
+ });
+ } catch(err) {
+ cb("no response", index);
+ }
};
@@ -144,11 +157,17 @@
var simvar2=[]
var simvar3=[]
var simvar4=[]
+var simvar5=[]
//Counts the number of get request for the html page
var getCtr=0
-var refreshInterval=2000
+var refreshInterval=4000
+
+//Ignore self signed cert
+process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
+
+var sim_http_type="http"
function fetchAllMetrics() {
setTimeout(() => {
@@ -178,60 +197,84 @@
//Get metric values from the simulators
for(var index=0;index<simnames.length;index++) {
- getSimCtr(LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
+ try {
+ if (index == 0) {
+ // Check is simulator are running on http or https - no response assumes http
+ getSimCtr("https",LOCALHOSTSECURE+simports[index]+"/", index, function(data, index) {
+ if (data=="OK") {
+ console.log("Found https simulator - assuming all simulators using https" )
+ sim_http_type="https"
+ SIM_LOCALHOST=LOCALHOSTSECURE
+ } else {
+ console.log("No https simulator found - assuming all simulators using http" )
+ sim_http_type="http"
+ SIM_LOCALHOST=LOCALHOST
+ }
+ });
+
+ }
+ } catch(err) {
+ console.log("No https simulator found - assuming all simulators using http" )
+ sim_http_type="http"
+ SIM_LOCALHOST=LOCALHOST
+ }
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
simvar1[index] = data;
});
- getSimCtr(LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
simvar2[index] = data;
});
- getSimCtr(LOCALHOST+simports[index]+"/policytypes", index, function(data,index) {
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/policytypes", index, function(data,index) {
data=data.replace(/\[/g,'');
data=data.replace(/\]/g,'');
data=data.replace(/ /g,'');
data=data.replace(/\"/g,'');
simvar3[index] = data;
});
- getSimCtr(LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
simvar4[index] = data;
});
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/remote_hosts", index, function(data,index) {
+ simvar5[index] = data;
+ });
}
//MR - get metrics values from the MR stub
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
mr1 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
mr2 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
mr3 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
mr4 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
mr5 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
mr6 = data;
});
//CR - get metrics values from the callbackreceiver
- getSimCtr(LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
cr1 = data;
});
- getSimCtr(LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
cr2 = data;
});
- getSimCtr(LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
cr3 = data;
});
//Agent - get metrics from the agent
- getSimCtr(LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
ag1 = data;
});
- getSimCtr(LOCALHOST+AGENT_PORT+"/services", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/services", 0, function(data, index) {
ag2="";
try {
var jd=JSON.parse(data);
@@ -246,7 +289,7 @@
ag2=data
}
});
- getSimCtr(LOCALHOST+AGENT_PORT+"/policy_types", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/policy_types", 0, function(data, index) {
ag3="";
try {
var jd=JSON.parse(data);
@@ -261,7 +304,7 @@
ag3=""
}
});
- getSimCtr(LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
ag4=""
try {
var jd=JSON.parse(data);
@@ -324,9 +367,8 @@
htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35," ")
htmlStr=htmlStr+padding("Types", 10," ")
- htmlStr=htmlStr+padding("Instances", 10," ")
- htmlStr=htmlStr+"<br>"+padding("",55,"=")+"<br>"
-
+ htmlStr=htmlStr+padding("Instances", 10," ")+"<br>"
+ htmlStr=htmlStr+padding("",55,"=")+"<br>"
for(var simIndex=0;simIndex<simnames.length;simIndex++) {
htmlStr=htmlStr+padding(simnames[simIndex]+ " ("+simports[simIndex]+")",35," ");
htmlStr=htmlStr+padding(simvar2[simIndex],10," ")
@@ -346,6 +388,16 @@
htmlStr=htmlStr+"<br>";
}
+ htmlStr=htmlStr+"<br>";
+ htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35," ")
+ htmlStr=htmlStr+padding("Remote hosts", 50," ")+"<br>"
+ htmlStr=htmlStr+padding("",90,"=")+"<br>"
+ for(simIndex=0;simIndex<simnames.length;simIndex++) {
+ htmlStr=htmlStr+padding(simnames[simIndex]+ " ("+simports[simIndex]+")",35," ");
+ htmlStr=htmlStr+padding(simvar5[simIndex],50," ")
+ htmlStr=htmlStr+"<br>";
+ }
+
htmlStr=htmlStr+
"</body>" +
"</html>";