Artillery.io - Printing variables that you capture from JSON response - artillery

I can't get Artillery IO to pass. Is there a way to print the values of the variables I'm capturing? I couldn't find this in the docs.
I return an array:
capture:
json: "$[0]"
as: "body"
how could I print body to debug why Artillery is failing?

config:
target: "http://localhost:8080"
http:
timeout: 20
scenarios:
name:
flow:
get:
url: /api/docs/swagger.json
capture:
- json: "$"
as: body
log: "{{body}}"

Related

How to pass JSON to SwaggerUIBundle?

Is there a way to pass OpenAPI JSON contents directly to Swagger UI's SwaggerUIBundle instead of passing an URL?
I need to use Swagger UI in a React 16 app, but swagger-ui doesn't support React 16 so I'm using SwaggerUIBundle instead. Does anyone know how to use swagger-ui in React version 16+ or pass JSON into SwaggerUIBundle?
To pass the spec as JSON, use the spec parameter:
const ui = SwaggerUIBundle({
// BEGIN SPEC
spec: {
swagger: '2.0',
info: {
title: "test",
version: '1.0.0'
},
paths: {
'/foo': {
get: {
responses: {
'200': {
description: 'OK'
}
}
}
}
}
},
// END SPEC
dom_id: '#swagger-ui',
...
Please anyone know either how to use swagger-ui in react version 16+
Use swagger-ui-react.

Google appengine cloud tasks alpha handler http 404 error

When I send a task to a task queue it keeps failing and shows a http 404 (not found) error in the logs.
The project has been whitelisted for cloud tasks alpha on flexible.
I can send HTTP post requests to /endpointpath & /tasks/worker locally without any errors.
The endpoint works fine and adds the task to the task queue.
13:37:41.300 POST 200 0 B 422 ms curl/7.54.0 /endpointspath?key=keyremoved 0.0.0.0 - "POST endpointspath?key=keyremoved" 200 undefined "-" "curl/7.54.0"
The app is running as the default service.
app.go main func:
func main() {
r := mux.NewRouter()
r.HandleFunc("/", handler)
r.HandleFunc("/_ah/health", healthCheckHandler)
// Task handlers
r.Path("/tasks/worker").Methods("POST", "GET", "PUT").HandlerFunc(workerTaskHandler)
// Endpoints
r.Path("/endpointpath").Methods("POST").HandlerFunc(searchHandler)
http.Handle("/", r)
port := 8080
if portStr := os.Getenv("PORT"); portStr != "" {
port, _ = strconv.Atoi(portStr)
}
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
}
abbreviated app.yaml:
runtime: go
env: flex
handlers:
- url: /tasks/.*
script: _go_app
- url: /.*
script: _go_app
Logs HTTP 404 response when queue dispatches request to worker:
10.0.0.1 - "POST /tasks/worker" 404 200 "-" "AppEngine-Google; (+http://code.google.com/appengine)"
Expand all | Collapse all {
httpRequest: {
latency: "0s"
referer: "-"
remoteIp: "10.0.0.1"
requestMethod: "POST"
requestUrl: "/tasks/worker"
responseSize: "200"
status: 404
userAgent: "AppEngine-Google; (+http://code.google.com/appengine)"
}
insertId: "......."
jsonPayload: {
appLatencySeconds: "-"
latencySeconds: "0.000"
time: null
trace: "......."
}
labels: {
appengine.googleapis.com/instance_name: "......"
appengine.googleapis.com/trace_id: "......."
compute.googleapis.com/resource_id: "......."
compute.googleapis.com/resource_name: "......"
compute.googleapis.com/zone: "us-central1-b"
}
logName: "projects/projectname/logs/appengine.googleapis.com%2Fnginx.request"
receiveTimestamp: "2017-12-09T10:56:14.794726383Z"
resource: {
labels: {
module_id: "default"
project_id: "projectname"
version_id: "....."
}
type: "gae_app"
}
timestamp: "2017-12-09T10:56:10.301Z"
}
The closest I can get GAE to find the tasks/worker url is by setting login:admin in app.yaml (even tho flex doesn't use this for authentication). This returns a 403 unauthorised error.
handlers:
- url: /tasks/.*
script: _go_app
login: admin
Here is the 403 response in the logs
{
httpRequest: {
latency: "0s"
referer: "-"
remoteIp: "10.0.0.1"
requestMethod: "POST"
requestUrl: "/tasks/worker"
responseSize: "162"
status: 403
userAgent: "AppEngine-Google; (+http://code.google.com/appengine)"
}
insertId: "....."
jsonPayload: {
appLatencySeconds: "-"
latencySeconds: "0.000"
time: null
trace: "....."
}
labels: {
appengine.googleapis.com/instance_name: "...."
appengine.googleapis.com/trace_id: "...."
compute.googleapis.com/resource_id: "...."
compute.googleapis.com/resource_name: "....."
compute.googleapis.com/zone: "us-central1-b"
}
logName: "projects/projectname/logs/appengine.googleapis.com%2Fnginx.request"
receiveTimestamp: "2017-12-09T13:35:59.986118082Z"
resource: {
labels: {
module_id: "default"
project_id: "projectname"
version_id: "....."
}
type: "gae_app"
}
timestamp: "2017-12-09T13:35:54.764Z"
}
Not sure if it's related but projectname.appspot.com/_ah/health returns this error:
{
"code": 5,
"message": "Method does not exist.",
"details": [
{
"#type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
It turns out endpoints can't run on the same service as task handlers. Task handler url requests are blocked by the ESP proxy if they run on the same service in the flexible environment, and the service has the endpoints service enabled.
Run task handlers on a separate service and do not set "endpoints_api_service:" in the task handler service app.yaml file.
Doing so will prevent the queue from being able to dispatch to workers in the flexible environment.
This isn't mentioned in the app engine documentation which is kinda bizarre.
The "/_ah/health" issue was caused by this path not being set in the open api file. If this path isn't set the url isn't recognised by the proxy.

i18next always returning missing key

Every time I try to translate I get i18next::translator: missingKey es-AR
This is my pug
component.pug
.headersGroup
h2(ng-i18next="{{$ctrl.getFilterTitle()}}")
h3(ng-i18next="landing.name")
I tried to translate in two ways. From the pug file and from the controller.
component.js
getFilterTitle () {
return this.$i18next.t('landing.title')
}
I not even interpolating or anything. Just a basic translation.
es-AR.json
{
"landing": {
"title" : "Filtros",
"name" : "Principales"
}
}
This is my init
window.i18next
.use(window.i18nextXHRBackend);
window.i18next.use(window.i18nextLocalStorageCache);
window.i18next.init({
debug: '!{env}' !== 'production',
lng: config.locale, // If not given, i18n will detect the browser language.
fallbackLng: false,
backend: {
loadPath: '/
myApp/build/i18n/{{lng}}/{{ns}}.json'
},
cache: {
enabled: true,
prefix: 'i18next_experts_',
expirationTime: 7 * 24 * 60 * 60 * 1000,
versions: {}
},
useCookie: false,
useLocalStorage: false
}, function (err, t) {
console.log(err, t);
});
Rather sure you render (call t function) before i18next loaded the translations.
Check the console output...do you get those missing log entries before there is the backend loaded message?

angular-csv-import not working on ionic

I am trying to use angular-csv-import on ionic. all works greate on chrome but when I am trying to run it on android nothing is happens...file manager to upload the file isnt working....what can be done?
my code is:
template:
<ng-csv-import content="csv.content"
header="csv.header"
separator="csv.separator"
result="csv.result"
accept="csv.accept">
</ng-csv-import>
controller:
$scope.csv = {
content: null,
header: true,
headerVisible: true,
separator: ',',
separatorVisible: true,
result: null,
encoding: 'ISO-8859-1',
encodingVisible: true,
accept: ".csv"
};
I find 2 ways to do it.
One way to save the document from google shits and get plugin to parse it to json, then use ng to download parsed json. Or the other way to use xlsx parser

Support additional mime types in hapi

I am working on a graphql + relay app served on top of hapi and would like to support requests to the graphql endpoint with the application/graphql mime type.
Here you can see me sending POST requests to the graphql endpoint.
~> curl -X POST --header "Content-Type:application/json" -d '{"query":"{content(id:\"13381672\"){title,id}}"}' http://127.0.0.1:8000/graphql
{"data":{"content":{"title":"Example Title","id":"13381672"}}}
~> curl -X POST --header "Content-Type:application/graphql" -d '{"query":"{content(id:\"13381672\"){title,id}}"}' http://127.0.0.1:8000/graphql
{"statusCode":415,"error":"Unsupported Media Type"}
I do not see any place in my hapi server options where there is any explicit configuration for mime types and other than some terse documentation here.
I have set up an options mime configuration as per the below, passing options into the server instantiation, but I am still seeing the "Unsupported Media Type" error.
options.mime = {
override: {
'application/graphql': {
charset: 'UTF-8',
compressible: true,
type: 'application/graphql'
}
}
};
Does anybody else here have this kind of experience with hapi?
Each route has a payload config option which takes an allow property that lets hapi know which mimetypes to allow for that route. If you set it to application/graphql, and the parse option to false, your requests will work.
Unfortunately, you'll have to parse the payload yourself.
Here's an example route:
server.route({
method: ['POST', 'PUT'],
path: '/graphql',
config: {
payload: {
parse: false,
allow: 'application/graphql'
}
},
handler: function(request, reply) {
reply(request.payload)
}
})

Resources