How to test collabora online performances - performance-testing

I setuped collabora online, and the users complain about performances.
I'd like to be able to graph performances to be able to correlate to other monitoring graphs.
Here is an open document you can access:
https://cloud.pierre-o.fr/s/qnkheXaoBQV97EH
I'd like to be able to time the appearance of the document.
I tried various ways, but it is really tricky.
Here is one attempte with casperjs:
var casper = require('casper').create();
casper.options.waitTimeout = 30000;
casper.start('https://cloud.pierre-o.fr/s/qnkheXaoBQV97EH', function() {
this.waitForSelector('div#StateWordCount', function() {
this.echo('the document is loaded');
}, function _onTimeout(){
this.capture('screenshot.png');
});
})
casper.on("page.error", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
this.echo("file: " + trace[0].file, "WARNING");
this.echo("line: " + trace[0].line, "WARNING");
this.echo("function: " + trace[0]["function"], "WARNING");
errors.push(msg);
});
casper.run()
As you guess, I just get the screenshot without the document.
phantomjs --version
2.1.1
casperjs --version
1.1.3
I use the recent versions. I guess it is related to websocket, but I'm not sure.
Thanks for your help!

Interesting, this also fails even with a huge timeout
casper.options.viewportSize = { width: 1024, height:800};
casper.test.begin('TEST DOC', 2, function (test) {
casper.start("https://cloud.pierre-o.fr/s/qnkheXaoBQV97EH", function () {
test.assertTitle("Nextcloud");
});
casper.waitUntilVisible("div#StateWordCount", function() {
test.assertExists("Test!", "Found test text");
}, function() {
casper.capture("fail.jpg")
}, 150000);
casper.run(function () {
test.done();
});
});
It shows the following screen:
I would try slimerjs as it looks like it might be a web socket issue!

Related

Office.context.mailbox.item.addFileAttachmentAsync often takes a long time to attach and internal format error occurs

An error occurs when trying to attach a file by calling Office.context.mailbox.item.addFileAttachmentAsync from the Office 365 Outlook add-in (on the web).
This happens frequently right after loading the Outlook website. It may not occur after some time after loading.
It occurs in IE, Chrome (on Windows10, on Mac) and Safari (on Mac). There is no problem with Desktop version.
This has not happened before, but it has recently occurred.
There have been no changes to the Outlook add-in in the last few months.
I created and tested the following simple program. The same error occurs in this program.
Office.initialize = function (reason) {
$(document).ready(function () {
$("#send-btn").click(function () {
try {
var url = "https://www.cloudstoragelight.com/proaxiastorage/f/Demo/TestData.xlsx";
var attachemrtFilename = "TestData.xlsx";
debugger;
Office.context.mailbox.item.addFileAttachmentAsync(
url,
attachemrtFilename,
{ asyncContext: null },
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
if (asyncResult.error && asyncResult.error.message) {
console.log("Error(" + asyncResult.error.message + ")");
} else {
console.log("Error");
}
}
else {
console.log("SUCCESS");
}
});
} catch (e) {
if (e.message) {
console.log("Error(" + e.message + ")");
} else {
console.log("Error");
}
}
});
});
};
Is there any workaround?
[additional information]
I tried debugging with outlook-web-16.01.debug.js.
Looking at the contents of the stack when an error occurs, there is a _checkMethodTimeout function. The timeout judgment of this function has become true, and Callback has been called.
In this case, Microsoft.Office.Common.ClientEndPoint.invoke function sends the following message in postMessage.
{"_messageType": 0, "_actionName": "ExecuteMethod", "_conversationId": "7cc28a93_6a3c12a5_1581127643048", "_correlationId": 5, "_origin": "https: // localhost: 44313 / MessageRead.html? et =", "_data": {"ApiParams": {"uri": "https://www.cloudstoragelight.com/proaxiastorage/f/Demo/TestData.xlsx", "name": "TestData.xlsx", "isInline": false, "__ timeout __": 600000}, "MethodData": {"ControlId": "963d4dfe-eaad-8e5b-6fa5-3eaac31b660d", "DispatchId": 16}}, "_ actionType": 0, "_ serializerVersion": 1}

Calling external function from within Phantomjs+node.js

I'm going to be honest. I'm way in over my head here.
I need to scrape data from a dynamic site for my employer. Before the data is visible on the page, there are some clicks and waits necessary. Simple PHP scraping won't do. So I found out about this NodeJS + PhantomJS combo. Quite a pain to set up, but I did manage to load a site, run some code and get a result.
I wrote a piece of jQuery which uses timeout loops to wait for some data to be loaded. Eventually I get a js object that I want to write to a file (JSON).
The issue I'm facing.
I build up the the js object inside the PhantomJS .evaluate scope, which runs in a headerless browser, so not directly in my Node.JS server scope. How do I send the variable I built up inside evaluate back to my server so I can write it to my file?
Some example code (I know it's ugly, but it's for illustrative purposes). I use node-phantom-simple as a bridge between Phantom and Node
var phantom = require('node-phantom-simple'),
fs = require('fs'),
webPage = 'https://www.imagemedia.com/printing/business-card-printing/'
phantom.create(function(err, ph) {
return ph.createPage(function(err, page) {
return page.open(webPage, function(err, status) {
page.onConsoleMessage = function(msg) {
console.log(msg);
};
console.log("opened site? ", status);
page.evaluate(function() {
setTimeout(function() {
$('.price-select-cnt').eq(0).find('select').val('1266').change()
timeOutLoop()
function timeOutLoop() {
console.log('looping')
setTimeout(function() {
if ($('#ajax_price_tool div').length != 6) {
timeOutLoop()
} else {
$('.price-select-cnt').eq(1).find('select').val('25')
$('.price-select-cnt').eq(2).find('select').val('Premium Card Stock')
$('.price-select-cnt').eq(3).find('select').val('Standard').change()
timeOutLoop2()
}
}, 100)
}
function timeOutLoop2() {
console.log('looping2')
setTimeout(function() {
if ($('.pricing-cost-cnt').text() == '$0' || $('.pricing-cost-cnt').text() == '') {
timeOutLoop2()
} else {
var price = $('.pricing-cost-cnt').text()
console.log(price)
}
}, 100)
}
}, 4000)
});
});
});
});
function writeJSON(plsWrite) {
var key = 'file'
fs.writeFile('./results/' + key + '.json', plsWrite, 'utf8', function() {
console.log('The JSON file is saved as');
console.log('results/' + key + '.json');
});
}
So do do I write the price this code takes from the website, get it out of the evaluate scope and write it to a file?

Nativescript timed service or thread for geolocation tracking

I need to create looping thread or timed service for getting latitude and longitude especially if it changes. What way should I proceed with this one. I'm currently using nativescript-geolocation plugin (https://www.npmjs.com/package/nativescript-geolocation).
When you follow the link in the thread you will see the whole example code on github.
You can get the current location by doing this:
var location = geolocation.getCurrentLocation({desiredAccuracy: 3, updateDistance: 10, maximumAge: 20000, timeout: 20000}).
then(function(loc) {
if (loc) {
// Your code here
}
}, function(e){
console.log("Error: " + e.message);
});
When you want to keep updating it, you can use:
var watchId = geolocation.watchLocation(
function (loc) {
if (loc) {
// Your code here
}
},
function(e){
console.log("Error: " + e.message);
},
{desiredAccuracy: 3, updateDistance: 10, updateTime: 1000 * 20}); // should update every 20 sec according to google documentation this is not so sure.

Return a value from phantomjs to nodejs

I'm using phantomjs using jquerygo library and am trying to this.
Visit a url
Click on a link and wait for it to load
Grab a particular tag and return it to nodejs for processing.
I realize that in phantomjs:
The execution is sandboxed, the web page has no access to the phantom object and it can't probe its own setting
But I should be able to return a simple string from the evaluate right?
But that is not working. My code is as follows:
var photogsScrapeCount = function(url, callback){
console.log("LOADED PHOTOGSSCRAPE Count");
url = decodeURIComponent(url);
//$.config.site = 'https://www.magnumphotos.com/';
$.config.addJQuery = false;
$.visit(url, function() {
$.waitForElement(".7n7np102",function() {
$.getPage(function(page) {
var imgCounterMinus = page.evaluate(function(){
$(".7n7np102 a").click(); // open the image enlarge
var temp = setTimeout(function(){
imgCounterMinus1 = $("span[id$='TotalPageCount_Lbl']").html();
imgCounterMinus1 = imgCounterMinus1.split(" ");
imgCounterMinus1 = imgCounterMinus1[2];
imgCounterMinus1 = parseInt(imgCounterMinus1);
console.log("imgCounterMinus1" + imgCounterMinus1);
return (imgCounterMinus1 - 3);
}, 4000);
return temp;
});
//console.log("After evaluate: " + imgCounterMinus)
});
});
});
};
Can this be achieved in any different way? The basic example from website is working so I am assuming that the setTimeout is giving me problems.
Any ideas or suggestions would be very helpful as I have very little experience in writing jquery, Js.
The docs say (emphasis mine):
For one, this library is not a complete API mirror of jQuery. Every API is asynchronous (due to its interaction with Phantom.js), so there are some differences.
There is also an example how page.evaluate() must be used. The result is not returned, but passed into a second callback. There is no way to return something from an asynchronous execution of a function except by using the callback. So the setTimeout syntax is also wrong.
$(".7n7np102 a").click(function(){
setTimeout(function(){
$.getPage(function(page) {
page.evaluate(function(){
var imgCounterMinus1 = $("span[id$='TotalPageCount_Lbl']").html();
imgCounterMinus1 = imgCounterMinus1.split(" ");
imgCounterMinus1 = imgCounterMinus1[2];
imgCounterMinus1 = parseInt(imgCounterMinus1);
console.log("imgCounterMinus1" + imgCounterMinus1);
return (imgCounterMinus1 - 3);
}, function(err, result){
console.log("After evaluate: " + result);
callback();
$.close();
});
});
}, 4000);
});

nodeunit fail to exit from my asynchronous tests

Whenever I run my nodeunit test in IDE or console, it run well but fail to exit. Help me please with it!
var store = require('../lib/db');
var list = require('../source/models/mock_deals');
var logger = require('../lib/logging').logger;
exports.setUp = function(done){
logger.info('start test...');
done();
};
exports.tearDown = function(done){
logger.info('end test...');
done();
};
exports.testInsertDeal = function(test){
var length = list.length;
test.equals(length, 2);
store.mongodb.open(function(err,db){
if(err){
logger.error(err);
return;
}
logger.info("mongodb is connected!");
db.collection('deals',function(err,collection){
for(var i=0; i<length; i++){
var item = list[i];
collection.insert(item, function(err, result){
if(err){
logger.error('Fail to insert document deal [' + item.id + ']');
return;
}
logger.info( 'index ' + i + ' : ' +JSON.stringify(item) );
});
}
});
test.expect(1);
});
test.done();
};
I changed to use mongoose instead of mongodb. test still could not exit automatically.
But when I disconnected mongoose in test.tearDown method in my nodeunit test. the test existed correctly.
Add below in you test:
exports.tearDown = function(done){
mongoose.disconnect(function(err){
if(err) {
logger.error(err);
return;
}
logger.info('mongoose is disconnected');
});
done();
};
And more, If I use log4js for logging in my test and configure log4js with reloadSecs: 500 , test will not exist either. After I set reloadSecs to 0, then test exists well. So we need to configure logging.json with option reloadSecs: 0
To summarize: we need to make sure there are no working parts there after all test methods are done. then test will exist correctly.
If you know when your program should exit, you can simply use the following line of code to exit:
process.exit(0);
where 0 is the return code of the program.
Now that isn't really fixing the problem. There is probably a call back still waiting or a connection that is still active keeping your program up and running that isn't shown in the code you posted here. If you don't care to find it, just use process.exit. If you really care to find it, you will have to dig some more. I've never used nodeunit but I have used other node libraries that leave stuff up in their inner workings that keep the program from exiting. In those cases, I usually don't feel like wading through other peoples source code to find out what is going on so I just do the afore mentioned process.exit call.
This should at least give you an option.

Resources