Gatling script compilation error saying value 'check' is not a member - gatling

I have a method in a gatling user-script as below.
This script was written in gatling 2.3.
def registerAddress: ChainBuilder = {
exec(ws("WS Register Address").wsName(id)
.sendText(prefetchAddress)
.check(wsAwait.within(30).until(1).regex("success").exists))
.exec(ping)
}
I am converting this in to gatling 3.0 and when I try to run it I get the following error.
value check is not a member of io.gatling.http.action.ws.WsSendTextFrameBuilder
I searched everywhere but I couldn't find a documentation related to WsSendTextFrameBuilder class to change the method call accordingly.
Does anyone know a documentation related to this class or a way to fix this issue?
Thank you.

After going through the documentation of Gatling 2.3 and 3.0 I found the new calls for the above scenario.
Apparently the check method is not available anymore in the WsSendTextFrameBuilder class.
Instead of that should use the await method.
So the code would look something similar to below.
val checkReply = ws.checkTextMessage("request").check(regex("request-complete"))
def registerAddress: ChainBuilder = {
exec(ws("WS Register Address").wsName(id)
.sendText(prefetchAddress)
.await(30 seconds)(checkReply))
.exec(ping)
}

Related

Gatling Required ChainBuilder Found B When ExitOnBlockOrFail. Method Exec Not Recognised

I am wondering why this code shows an error saying that it expects a ChainBuilder but found B, and what B actually is. I'm a few months now wondering about this issue since my code still compiles with it but I would love to remove this error if possible.
Even when I simplify it the most but keeping the exitBlockOnFail piece it will still give me the red warning, so I'd like to know what is the connection between the two of them please.
// Error
object StudentDashboardBranches {
def studentDashboard: ChainBuilder = exitBlockOnFail(
exec {
session =>
println(session("session").as[String])
session
}
)
}
// No error
object StudentDashboardBranches {
def studentDashboard: ChainBuilder = (
exec {
session =>
println(session("session").as[String])
session
}
)
}
And perhaps a different question or maybe related to the same issue, not sure, but the exec method appended after the pause is not recognised, however, this error doesn't leave if I delete the exitBlockOnFail piece as the first one does.
PS: These are my imports
import io.gatling.core.Predef.{exec, _}
import io.gatling.core.structure.ChainBuilder
Any help or clarification is much appreciated.
Many thanks.
UPDATE
As per Stephane's answer, we were missing one of the imports.
import io.gatling.core.Predef._ // required for Gatling core structure DSL
It's working now.
Have you broken the DSL imports? If so, please check the doc.

Sentinel import inside Terraform Cloud confusion: key "find_resources" doesn't support function calls

I'm using a Sentinel policy inside a Terraform Cloud workspace. My policy is rather simple:
import "tfplan/v2" as tfplan
allBDs = tfplan.find_resources("aci_bridge_domain")
violatingBDs = tfplan.filter_attribute_does_not_match_regex(allBDs,
"description", "^demo(.+)", true)
main = rule {
length(violatingBDs["messages"]) is 0
}
Unfortunately, it fails when invoked with this message:
An error occurred: 1 error occurred:
* ./allowed-terraform-version.sentinel:3:10: key "find_resources" doesn't support function calls
The documentation and source for find_resources (doc) expects a string, yet the Sentinel interpreter seems to think I'm invoking a method of tfplan? It's quite unclear why that is, and the documentation doesn't really help.
Any ideas?
OK I found the issue. If I paste the code for find_resources and its dependencies (to_string, evaluate_attribute) then everything works as expected.
So I have a simple import problem and need to figure out how to properly import https://raw.githubusercontent.com/hashicorp/terraform-guides/master/governance/third-generation/common-functions/tfplan-functions/tfplan-functions.sentinel

How do you use Gatling's checkIf method?

Documented here, Gatling's checkIf method is intended for conditional checking. It's not available on ScenarioBuilder's fluent API but I can see it in the CheckSupport class. I have scoured the internet and cannot find a single example.
I'm using Gatling 2.3.1.
I found an example in their unit tests as follows:
http("untypedCheckIf").get("/")
.check(
checkIf("${bool}") {
jsonPath("$..foo")
}
)
Under Gatling 3.7.6, this worked for me:
http("Test Gatling checkIf()")
.get("/")
.check(status().in(200, 404).saveAs("httpStatus"))
.checkIf(session -> "200".equals(session.getString("httpStatus")))
.then(
jmesPath("someField")
.saveAs("fieldName"))
.checkIf(session -> "404".equals(session.getString("httpStatus")))
.then(
jmesPath("someField")
.withDefault("some default value")
.saveAs("fieldName"));

How to use sagemaker java API to invoke a endpoint?

I was trying to run this example: tensorflow_abalone_age_predictor_using_layers
, in which abalone_predictor.predict(tensor_proto) is used to call the endpoint and make the prediction. I was trying to use the java API AmazonSageMakerRuntime to achieve the same effect, but I don't know how to specify the body and contentType for the InvokeEndPointRequest. The document is not in detailed abou the format of the request. Greatly appreciate any piece of help!
I have not tried the specific example but the below snippet should help you to invoke the endpoint for predictions
InvokeEndpointRequest invokeEndpointRequest = new InvokeEndpointRequest();
invokeEndpointRequest.setContentType("application/x-image");
ByteBuffer buf = ByteBuffer.wrap(image);
invokeEndpointRequest.setBody(buf);
invokeEndpointRequest.setEndpointName(endpointName);
invokeEndpointRequest.setAccept("application/json");
AmazonSageMakerRuntime amazonSageMaker = AmazonSageMakerRuntimeClientBuilder.defaultClient();
InvokeEndpointResult invokeEndpointResult = amazonSageMaker.invokeEndpoint(invokeEndpointRequest);
I see the example you are trying creates a TensorProto and passes to the endpoint request. You can try to create a TensorProto of your invoke request and set as the body
Just figured I can override the input_fn to convert the request body string to something can be fed to the model, in this case a TensorProto object.

go-endpoint Invalid date format and method not found

Hy, I have some problems with the Go endpoints and Dart client library.
I use the Go library https://github.com/crhym3/go-endpoints and the dart generator https://github.com/dart-lang/discovery_api_dart_client_generator
The easy examples works fine. But they show never how to use time.Time.
In my project, I have a struct with a field:
Created time.Time `json:"created"`
The output in the explorer looks like this:
"created": "2014-12-08T20:42:54.299127593Z",
When i use it in the dart client library, I get the error
FormatException: Invalid date format 2014-12-08T20:53:56.346129718Z
Should I really format every time fields in the go app (Format Timestamp in outgoing JSON in Golang?)?
My research come to that the dart accept something:
t.Format(time.RFC3339) >> 2014-12-08T20:53:56Z
Second problem, if comment out the Created field or leave it blank. I get a other error:
The null object does not have a method 'map'.
NoSuchMethodError: method not found: 'map' Receiver: null Arguments:
[Closure: (dynamic) => dynamic]
But I can't figure it out which object is null. I'm not sure if I'm using the Dart client correct
import 'package:http/browser_client.dart' as http;
...
var nameValue = querySelector('#name').value;
var json = {'name':nameValue};
LaylistApi api = new LaylistApi(new http.BrowserClient());
api.create(new NewLayListReq.fromJson(json)).then((LayList l) {
print(l);
}).catchError((e) {
querySelector('#err-message').innerHtml=e.toString();
});
Does anyone know of a larger project on github with Go endpoint and Dart?
Thanks for any advice
UPDATE[2014-12-11]:
I fixed the
NoSuchMethodError
with the correct discovery url https://constant-wonder-789.appspot.com/_ah/api/discovery/v1/apis/greeting/v1/rest
The problem with the time FormatExcetion still open, but I'm one step further. If i create a new item, it doesn' work. But if I load the items from the datastore and send it back, this works.
I guess this can be fixed with implementing Marshaler interface, thanks Alex. I will update my source soon.
See my example:
http://constant-wonder-789.appspot.com/
The full source code:
https://github.com/cloosli/greeting-example

Resources