Commit e64d05bb authored by Alexandra Rogova's avatar Alexandra Rogova

content and index import scripts

parent 42cbb881
const puppeteer = require('puppeteer');
const Server = require('ws').Server;
const randomstring = require("randomstring");
const tmp = require('tmp');
const fs = require('fs');
......@@ -10,6 +11,29 @@ const args = require("yargs")
.nargs("prom", 1)
.argv;
var start, browser;
function init_server (){
var port = 9030;
var ws = new Server({port: port});
ws.on('connection', function(w){
w.on('message', function(msg){
if (msg.includes("Start")){
start = Date.now();
} else if (msg.includes("Done")){
var time_spent = Date.now() - start;
console.log(msg + " in " + time_spent/1000 + "s");
} else {
console.log("Error : " + msg);
browser.close();
}
});
w.on('close', function() {
ws.close();
});
});
}
function gen_rdm_string (length){
return randomstring.generate({
length: length,
......@@ -44,8 +68,9 @@ function gen_random_content (){
}
(async () => {
init_server();
var file_path = gen_random_content();
var browser = await puppeteer.launch({headless: false});
browser = await puppeteer.launch({headless: false});
var page = await browser.newPage();
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/download_content.html');
const [fileChooser] = await Promise.all([
......
const puppeteer = require('puppeteer');
const Server = require('ws').Server;
const args = require("yargs")
.usage("Usage : import_content.js -file file_path -u if uncompressed file")
.demandOption(['file'])
.alias("f", "file")
.alias("u", "uncompressed")
.describe("file", "file containing the index")
.describe("uncompressed", "to add if file is uncompressed ! For testing only !")
.nargs("file", 1)
.nargs("u", 0)
.argv;
var browser,
start;
function init_server (){
var port = 9030;
var ws = new Server({port: port});
ws.on('connection', function(w){
w.on('message', function(msg){
if (msg.includes("Done : ")){
var time_spent = Date.now() - start;
console.log(msg + " in " + time_spent/1000 + "s");
browser.close();
} else {
console.log("Error : " + msg);
browser.close();
}
});
w.on('close', function() {
ws.close();
});
});
}
(async () => {
init_server();
browser = await puppeteer.launch();
var page = await browser.newPage();
if (args.uncompressed) await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/import_content_uncompressed.html');
else await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/import_content.html');
start = Date.now();
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
]);
await fileChooser.accept([args.file]);
})();
const puppeteer = require('puppeteer');
const Server = require('ws').Server;
const args = require("yargs")
.usage("Usage : import_index.js -file file_path -u if uncompressed file")
.demandOption(['file'])
.alias("f", "file")
.alias("u", "uncompressed")
.describe("file", "file containing the index")
.describe("uncompressed", "to add if file is uncompressed ! For testing only !")
.nargs("file", 1)
.nargs("u", 0)
.argv;
var browser,
start;
function init_server (){
var port = 9030;
var ws = new Server({port: port});
ws.on('connection', function(w){
w.on('message', function(msg){
if (msg.includes("Done : ")){
var time_spent = Date.now() - start;
console.log(msg + " in " + time_spent/1000 + "s");
browser.close();
} else {
console.log("Error : " + msg);
browser.close();
}
});
w.on('close', function() {
ws.close();
});
});
}
(async () => {
init_server();
browser = await puppeteer.launch();
var page = await browser.newPage();
if (args.uncompressed) await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/import_index_uncompressed.html');
else await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/import_index.html');
start = Date.now();
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
]);
await fileChooser.accept([args.file]);
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment