summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoryanhuanwang <martin.c.yan@est.tech>2019-03-15 07:57:38 +0000
committeryanhuanwang <martin.c.yan@est.tech>2019-03-15 07:57:38 +0000
commitdb4bd69a91545c22580f3c9c57237df82cf1b80e (patch)
tree3773e09dc6521b546a51c992215328565c293a3b /test
parent3c57f672700f8550370cc7a3f1b431e775907489 (diff)
Add simulator for dmaapbuscontroller
Change-Id: I5bd0ab24e5b2d647c0b47212e1f5f728cdc1bb32 Issue-ID: DCAEGEN2-1225 Signed-off-by: yanhuanwang <martin.c.yan@est.tech>
Diffstat (limited to 'test')
-rw-r--r--test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js b/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js
new file mode 100644
index 000000000..cca85f98b
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js
@@ -0,0 +1,76 @@
+var http = require('http');
+var https = require('https');
+var ArgumentParser = require('argparse').ArgumentParser;
+var express = require('express');
+const stream = require('stream');
+var app = express();
+var fs = require("fs");
+var path = require('path');
+var privateKey = fs.readFileSync('cert/private.key', 'utf8');
+var certificate = fs.readFileSync('cert/certificate.crt', 'utf8');
+var credentials = {key: privateKey, cert: certificate};
+
+
+var parser = new ArgumentParser({
+ version: '0.0.1',
+ addHelp:true,
+ description: 'Datarouter simulator'
+ });
+
+parser.addArgument('--tc' , { help: 'TC $NoOfTc' } );
+parser.addArgument('--printtc' ,
+ {
+ help: 'Print complete usage help',
+ action: 'storeTrue'
+ }
+ );
+
+var args = parser.parseArgs();
+
+if (args.tc=="100") {
+ console.log("TC: 100")
+}
+if (args.tc=="101") {
+ console.log("TC: 101")
+ //preparations
+}
+if (args.tc=="102") {
+ console.log("TC: 102")
+ //preparations
+}
+
+if (args.printtc) {
+ console.log("TC 100: receive all incoming files");
+ console.log("TC 101: drop/deny first 10 publishing attempt, then receive all");
+ console.log("TC 102: drop/deny/every second publisging attempt");
+ process.exit(0);
+}
+
+var bodyParser = require('body-parser')
+app.use(bodyParser.urlencoded({ extended: false }))
+
+// parse application/json
+app.use(bodyParser.json())
+
+// parse application/vnd.api+json as json
+app.use(bodyParser.json({ type: 'application/vnd.api+json' }))
+
+// parse some custom thing into a Buffer
+app.use(bodyParser.raw({limit:1024*1024*20, type: 'application/octet-stream' }))
+// parse an HTML body into a string
+app.use(bodyParser.text({ type: 'text/html' }))
+app.get("/",function(req, res){
+ res.send("ok");
+})
+app.post('/webapi/feeds/', function (req, res) {
+ res.send("ok");
+})
+var httpServer = http.createServer(app);
+var httpsServer = https.createServer(credentials, app);
+
+var httpPort=6665
+var httpsPort=6666
+httpServer.listen(httpPort);
+console.log("DR-simulator listening (http) at "+httpPort)
+httpsServer.listen(httpsPort);
+console.log("DR-simulator listening (https) at "+httpsPort) \ No newline at end of file