Is there a way to get the number of registered nodes by Selenium Grid other than with http://localhost:4444/grid/console - selenium

In order to run multiple tests in parallel, I would like to know how many nodes are already running at some point.
I have looked into many posts on this subject, but all of them include using http://localhost:4444/grid/console : I don't want to check this page.
I was thinking about sending a message to the hub each time a node is created. so the hub increments its count. But I can't find a way to do that.
Does anyone have a different solution ? Maybe using seleniumgrid parameters or command, I'm surprised this number is not stored somewhere?

The selenium grid has an API. You can do this:
http://hub_ip_address:4444/grid/api/hub
and parse the json it returns for "slotCounts"
{
"success":true,
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"newSessionWaitTimeout":-1,
"throwOnCapabilityNotPresent":true,
"registry":"org.openqa.grid.internal.DefaultGridRegistry",
"cleanUpCycle":5000,
"custom":{
},
"host":"XX.XXX.XX.XXX",
"maxSession":10,
"servlets":[
"ConsoleServlet"
],
"withoutServlets":[
],
"browserTimeout":0,
"debug":false,
"port":4444,
"role":"hub",
"timeout":300000,
"enablePassThrough":true,
"newSessionRequestCount":0,
"slotCounts":{
"free":9,
"total":12
}
}

Related

How to measure test execution duration with NewRelic Syntethics Scripts?

I'm using the newrelic synthetics scripted browser to check some user transaction flows for reliability and performance.
However the tracked duration is only about 8-10s which matches initial page load time, but not the async lazy loading of a large dataset (which is approx. 40s).
How can I make new relic synthetics scripted browser tests to show actual test execution duration and not only the duration of inital request?
How can I track actual synthetics scripted browser test execution time and plot on a diagram with new relic?
The following I already tried and seems not to fix the issue:
Using a custom insight
See new relic docs for custom insights.
In script use:
var timeStart = Date.now();
var timeEnd = Date.now();
$util.insights.set('testDuration', (timeEnd - timeStart) );
with NRQL:
FROM SyntheticCheck SELECT numeric(custom.testDurration) WHERE numeric(custom.testDurration) > 0 SINCE 1 day ago
However in newrelic browser this data is shown as strings and thus cannot be plot on a chart as measurement.
What do I need to do to be able to make this a numeric measurement to be drawable as chart?
Timetracking with $har
New relic docs recommend using $har
const testTimer = $har.addResource('Test Timer');
testTimer.startTimer();
await sleep(100);
testTimer.endTimer();
However $har is resulting in error: Check failed with reference error. $har is not defined;
How do I use $har correctly?
** Checking KeySet, the custom properties show us stings**
As proposed on new relic forum I checked the field type and it appears to be registered as string
NRQL FROM SyntheticCheck SELECT keyset() returns
[
{
"results": [
{
"stringKeys": [
"custom.duration"
"custom.testDuration",
Any other ideas how to achieve this?
Thx in advance, I really appreciate your expertise!
You can log values with
$util.insights.set('testDuration', (timeEnd - timeStart) )
And when convert them within the query with
SELECT average(numeric(custom.testDuration)) FROM SyntheticCheck WHERE monitorName ='myMonitor' SINCE 7 days AGO TIMESERIES AUTO
However you cannot report this within the synthetics monitor and always need the query builder or a custom dashboard for analysis.
Would rather prefer a solution which properly reports within the synthetics monitor.

How to run a TestCafe test with CLI that contains a metadata array

I have a test with the following metadata:
test.meta({ type: 'smoke', testcase: ['tc01', 'tc02'] });
The testcase metadata contains an array of id's that I would like to use them as filter for running the test using any of the values using the command line interface:
testcafe --test-meta testcase=tc01
testcafe --test-meta testcase=tc02
These two command lines should run the same test, however they don't work. Is there another way to approach to this solution?
Reading this discussion on TestCafe's github page, it seems that metadata has to be only single value strings: https://github.com/DevExpress/testcafe/issues/3267 The issue is then closed and the last explanation was that such a feature request is not very clear because:
In addition, the particular case you are addressing is a bit tricky, what will be the user expected behaviour?, To match only when the array has all the passed values? or when the array is equal to that values (ie: don't have any extra one)?.
Such an option is not mentioned in the official documentation either: https://devexpress.github.io/testcafe/documentation/guides/basic-guides/organize-tests.html#specify-test-metadata
That leads me to believe you can't really achive what you're asking for as of June 2020.

How to get html report when the test-cases run in parallel?

I am using karma-html-reporter to generate the report which works fine.
But when i execute the test-cases with karma-parallel i observe that it is generating the report of only one instance not for the other one.
Is there a way to get/generate report for both of the instances.
Currently i am running 2 instances of Chrome.
What all i have to do to get the integrated report of both instances ?
I have tried karma-multibrowser-reporter link
But it is removing the karma-parallel feature.
report generation happens with below configuration:-
htmlReporter: {
outputDir: 'path/results'
},
karma-parallel has the option aggregatedReporterTest. If you add html to the regex it only uses one reporter for all browsers:
parallelOptions: {
aggregatedReporterTest: /coverage|istanbul|html|junit/i
},

Cloudera Manager API to fetch the list of Flume agents

I am trying to fetch the number of Flume agents are running on My CDH5.8 cluster using Cloudera Manager API .
https://cloudera.github.io/cm_api/
Till now i could not figure out which RESTful Model I should consider or the related Java class. If any one can help or to inform the the referenced Java class to look into that will be great
Regards
If you use the following API:
https://cloudera.github.io/cm_api/apidocs/v13/path__clusters_-clusterName-services-serviceName-_roles.html
The size of the items array in the JSON object returned will be the number of Flume agents. To find the number of running agents, for each item, check that roleState equals STARTED.
The Java class ApiRole is probably what you need. This code snippet from the whirr-cm example is close to what you want.
https://github.com/cloudera/whirr-cm/blob/edb38ca7faa3e4bb2c23450ff0183c2dd631dcf4/src/main/java/com/cloudera/whirr/cm/server/impl/CmServerImpl.java#L486
for (ApiService apiService : apiResourceRootV3.getClustersResource().getServicesResource(getName(cluster))
.readServices(DataView.SUMMARY)) {
for (ApiRole apiRole : apiResourceRootV3.getClustersResource().getServicesResource(getName(cluster))
.getRolesResource(apiService.getName()).readRoles()) {
if (apiRole.getRoleState().equals(ApiRoleState.STARTED)) {
servicesNotStarted.remove(apiRole.getName());
}
}
}
You would just need to limit this to the Flume service.
https://cloudera.github.io/cm_api/javadoc/5.11.0/index.html

Leadfoot + sauce: mapping a collection of elements using getAttr fails in mobile only

My use case varies for this, but in general i'm trying to collect a bunch of elements and then apply _.map() to each. The problem is that this series of .getAttribute() calls can cause a test that works locally to fail against a remote server like sauce/android.
One example: collecting all <div class='article'><a href='articles/{id}'> on a page and then getting the hrefs. it might look something like this, and this approach will work until i test on a mobile (android) sauce environment. then I get a timeout.
Is it possible this is an issue related to my android environment capabilities? To piling up so many requests? I've tried scaling my test down from using 75 articles to only 45 and i've upped the timeout to 60s and still the mobile test fails. locally with chromedriver is fine, chrome desktop + sauce is fine.
Not my actual test but an approximation of the code i'm talking about:
/// ... return this.remote
.findAllByTagName('div.article a')
.then(function (articles) {
var promises = articles.map(function(article) {
return article.getAttribute('href');
});
Promise.all(promises)
.then(function (hrefs) {
uniques = _.uniq(hrefs);
assert(hrefs.length === uniques.length);
});
});
Since you're seeing a timeout error, I'd suggest continuing to increase the test timeout until the test passes. The mobile testing environments on Sauce are both slower to initialize and slower to operate than the desktop environments, so it's quite possible that a test with many requests is simply very slow.
One way to speed things up would be to use an execute block to gather the references, like:
.then(function (articles) {
return this.parent.execute(function (articles) {
return articles.map(function (node) {
return node.getAttribute('href');
});
}, [ articles ]);
})
In the above snippet, the articles element array is passed as an argument to the execute block. The remote WebDriver will deserialize the element references into actual DOM elements that can be operated on in the execute code. This is significantly more efficient than using individual getAttribute requests for each element since only a single request will be made to the remote browser.