I want to write the actual test output of NightwatchJS tests (not the browser console) to a file. I can't seem to find any resource regarding about this.
The log_path option is ok, it does log some stuff on the location you specified after the test, but its not the same data vs the actual test output.
below is my nightwatch.json file
{
"src_folders" : [
"tests" ,
"tests/settings/general"
],
"page_objects_path" : [
"page_objects/backend" ,
"page_objects/frontend" ,
"page_objects/backend/settings/general"
],
"globals_path" : "./nightwatch.globals.js",
"webdriver" : {
"start_process" : true,
"log_path" : "./logs"
},
"test_settings" : {
"default" : {
"webdriver": {
"server_path" : "node_modules/.bin/chromedriver",
"port" : 9515,
"cli_args" : [ "--log" , "debug" ]
},
"desiredCapabilities": {
"browserName" : "chrome",
"acceptInsecureCerts" : true,
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"firefox" : {
"webdriver": {
"server_path" : "node_modules/.bin/geckodriver",
"port" : 4444,
"cli_args" : [ "--log" , "debug" ]
},
"desiredCapabilities": {
"browserName" : "firefox",
"acceptInsecureCerts" : true,
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
}
Hope you can help me on this.
Thanks in advance.
You could add '> tests_output/Test_filename.txt' after the command to run the test. So, I have my package.json file set up with the script 'test' for running Nightwatch. My terminal input to save the output as a file would look like this:
npm test > /tests_output/testRun100720.txt
This will place the output file I name testRun100720.txt into the tests_output folder.
Can you provide a little more detail of what you mean by 'output'?
In the meantime, try adding "output_folder": "reports/", to your json file, this should generate XML output from the Nightwatch logger which may provide more details.
Related
I would like to implement CI/CD with UI tests I've written to automatically run my Nightwatch.js test on a nightly basis. I've tried copying my files to a workspace in jenkins and running them. I've tried using TFS as a version control system to see if we could get it to run that way. The problem I keep running into (see attached) is that when I run locally the chrome browser opens and runs the tests just fine. In Jenkins, however, It says that it can't find the element. I've researched how to run chrome headlessly but I still get the same error when I add the --headless tag to my nightwatch.json config file. Bottom line, How can I get Nightwatch.js tests to run on a nightly schedule? (preferably in jenkins)
Tried running tests from tfs source control
tried running tests from local tests copied to jenkins workspace.
tried running headless tests (locally works, Jenkins does not)https://developers.google.com/web/updates/2017/04/headless-chrome
Here is my nightwatch.json file.
{
"src_folders" : ["tests"],
"output_folder" : "reports/XMLReports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "dealer",
"globals_path" : "",
"test_workers": false,
"selenium": {
"cli_args": {
"webdriver.chrome.driver" : "node_modules/.bin/chromedriver.cmd",
"webdriver.gecko.driver" : "node_modules/.bin/geckodriver.cmd",
"webdriver.edge.driver" : "node_modules/.bin/edgedriver.cmd"
},
"log_path": "",
"port": 4460,
"server_path": "lib/drivers/selenium-server-standalone-3.141.59.jar",
"start_process": true
},
"test_settings" : {
"chrome" : {
"launch_url" : "http://localhost",
"selenium_port" : 4460,
"selenium_host" : "127.0.0.1",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : "screenshots/Chrome/"
},
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions":{
"args": [
"disable-web-security",
"ignore-certificate-errors",
"--test-type",
"--disable-gpu",
"--headless",
"--remote-debugging-port=9222"
]
}
}
},
"edge" : {
"desiredCapabilities": {
"browserName": "MicrosoftEdge"
}
}
}
}
I would expect my tests to run in jenkins normally and give me a detailed report if it passed or failed in the ui.
It looks like the .windowMaximize() was causing my tests to hang and fail in Jenkins.
Maybe I'm missing something, but according to the documentation and all the posts online, setting
cursor.maxTimeMS(1000).toArray(...)
should time out after 1000ms, and MongoDB should kill the operation after timeout.
But none of this is happening.
First, there is no timeout. It keeps going.
Second, I check db.currentOp() and the operation is still there, eating up all the memory. This later adds up and crashes the database with OOM.
Anyway running db.currentOp() after several minutes of no response prints:
{
"inprog" : [
{
"host" : "db2:27017",
"desc" : "conn20",
"connectionId" : 20,
"client" : "127.0.0.1:59214",
"clientMetadata" : {
"driver" : {
"name" : "nodejs",
"version" : "3.1.4"
},
"os" : {
"type" : "Linux",
"name" : "linux",
"architecture" : "x64",
"version" : "4.15.0-30-generic"
},
"platform" : "Node.js v8.10.0, LE, mongodb-core: 3.1.3"
},
"active" : true,
"currentOpTime" : "2018-09-14T00:10:29.903+0000",
"opid" : 11056,
"lsid" : {
"id" : UUID("78a2d853-30bf-4d6d-a208-0a150d9bf8be"),
"uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
},
"secs_running" : NumberLong(649),
"microsecs_running" : NumberLong(649968360),
"op" : "command",
As you can see, this has been running for 649 seconds, even though I explicitly specified 1000ms.
What is going on here? I've been pulling my hair out for two days and can't figure this out.
I had the same issue and had to update the mongodb driver from 3.1.1 to 3.3.5 and it worked like a charm!
i am new in mongodb and i am facing an issue, i have around millions of documents in my collectionand i am trying to find single entry using findOne({}) command and when i am trying to find recent entries then response comes in miliseconds but when i am trying to fetch older entries around 600 millionth document then it takes around 2 minutes on mongo shell and my node server gives
{ MongoErro : connection 1 to 127.0.0.1:27017 timed out }
and my nodejs server sends an empty response. can any one tell me what should i do to resolve this issueThanks in advance
explain gives me
db.contacts.find({"phoneNumber":"9165900137"}).explain("executionStats")
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "meanApp.contacts",
"indexFilterSet" : false,
"parsedQuery" : {
"phoneNumber" : {
"$eq" : "9165900137"
}
},
"winningPlan" : {
"stage" : "COLLSCAN",
"filter" : {
"phoneNumber" : {
"$eq" : "9165900137"
}
},
"direction" : "forward"
},
"rejectedPlans" : [ ]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 1,
"executionTimeMillis" : 321188,
"totalKeysExamined" : 0,
"totalDocsExamined" : 495587806,
"executionStages" : {
"stage" : "COLLSCAN",
"filter" : {
"phoneNumber" : {
"$eq" : "9165900137"
}
},
"nReturned" : 1,
"executionTimeMillisEstimate" : 295230,
"works" : 495587808,
"advanced" : 1,
"needTime" : 495587806,
"needYield" : 0,
"saveState" : 3871779,
"restoreState" : 3871779,
"isEOF" : 1,
"invalidates" : 0,
"direction" : "forward",
"docsExamined" : 495587806
}
},
"serverInfo" : {
"host" : "li1025-15.members.linode.com",
"port" : 27017,
"version" : "3.2.16",
"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
},
"ok" : 1
}
As indicated in the explain plan results, the current query is doing Collection Scan. This means it has to scan every document in collection to produce the match and you have got about half a billion documents.
Try adding this index and it might take a bit to create it.
db.contacts.createIndex( { phoneNumber: 1 }, { background: true } )
Run the query once the index creation is successful, you must see a dramatic improvement in performance. To be certain whether index got picked up, try explain again and it should no longer say COLLSCAN.
I am using the ELK Stack to analyze logs and I need to analyze and detect anomalies of apache access logs. What can I analyze with apache access logs and how should I give the conditions with curl -XPUT to Watcher?
If you haven't found it already, there's a decent tutorial at https://www.elastic.co/guide/en/watcher/watcher-1.0/watch-log-data.html. It provides a basic example of creating a log watch.
You can analyze/watch anything that you can query in Elasticsearch. It's just a matter of formatting the query with the correct JSON syntax. The guide for crafting the conditions is at https://www.elastic.co/guide/en/watcher/watcher-1.0/condition.html.
You'll also want to look at https://www.elastic.co/guide/en/watcher/watcher-1.0/actions.html to get an idea of the possible actions Watcher can take when a query meets a condition.
As far as the post to Watcher, each watch is essentially a JSON object. Because they can get pretty elaborate, I have found that it's best to create a file for each watch you want to create, and post them like this:
curl -XPUT http://my_elasticsearch:9200/_watcher/watch/my_watch_name -d #/path/to/my_watch_name.json
my_watch_name.json should have these basic elements (as described in the first link above):
{
"trigger" : { ... },
"input" : { ... },
"condition" : { ... },
"actions" : { ... }
}
The actions section is going to be specific to your use case, but here's a basic example of the other sections that I'm using successfully:
{
"trigger" : {
"schedule" : { "interval" : "5m" }
},
"input" : {
"search" : {
"request" : {
"indices" : [ "logstash" ],
"body" : {
"query" : {
"filtered" : {
"query" : {
"match" : { "message" : "error" }
},
"filter" : {
"range" : { "#timestamp" : { "gte" : "now-5m" } }
}
}
}
}
}
}
},
"condition" : {
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 } }
},
"actions" : {
...
}
}
I'm trying to create an EC2 instance, that will use autoscaling, attached to a load balancer.
Unfortunately, I'm getting the error
The availability zones of the specified subnets and the AutoScalingGroup do not match
However, this is my current Cloudformation script:
"ApiAutoScaling" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"VPCZoneIdentifier" : [ "subnet-5ff05206", "subnet-b1109fc6", "subnet-948ce5f1" ],
"InstanceId" : {
"Ref" : "ApiEC2"
},
"MaxSize" : 3,
"MinSize" : 1,
"LoadBalancerNames" : [ "Api" ]
}
},
"ApiLoadBalancer" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"LoadBalancerName" : "Api",
"Listeners" : [
{
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "80",
"Protocol" : "HTTP"
},
{
"InstancePort" : "80",
"InstanceProtocol" : "HTTP",
"LoadBalancerPort" : "443",
"Protocol" : "HTTPS",
"SSLCertificateId" : "arn:aws:iam::xxx"
}
],
"SecurityGroups" : [ "sg-a88444cc" ],
"Subnets" : [ "subnet-5ff05206", "subnet-b1109fc6", "subnet-948ce5f1" ]
}
}
As you can see, my subnet list is the same for both my autoscaling group and my load balancer. Clearly I've misunderstood how this is supposed to work, but I can't work it out.
Try specifying the AvailabilityZones property for the auto scaling group. The default is for it to use all of them, so if your subnets only use a subnet of the zones, you would get this error message.
(As pointed out in the comments, "AvailabilityZones" : { "Fn::GetAZs" : "" } should do the trick.)