How do you perform functional testing with artillery when you have multiple scemarios? - artillery

https://docs-nine-inky.vercel.app/blog/using-artillery-for-your-functional-testing talks about functional testing with artillery, but it is limitted to a single scenario. I'd like to test different scenarios, but the choice of scenario is randomized.
vusers.completed: .............................................................. 6
vusers.created: ................................................................ 6
vusers.created_by_name.Login request resource and logout: ...................... 1
vusers.created_by_name.Login request resource and logout with refresh: ......... 1
vusers.created_by_name.No login unauthorized: .................................. 2
vusers.created_by_name.No login unauthorized invalid bearer token: ............. 2

Related

how can i build the authentication using symfony 6 and raeact js?

In my App i don t need a registration feature so i added a user in the database manually ,Actually I tried with the LexiJWTAuthenticationBundle i followed the documentation but unfortunately when I use the cURL to send a request i get the following error
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/8.1.4 Server at localhost Port 443</address>
</body></html>```
**the cURL request is
curl -X POST -H "Content-Type: application/json" https://localhost/api/check_login --data '{"email":"johndoe#gmail.fr","password":"test"}' -k
Moreover frankly i m confused about the logic of the bundle so im worried if i need a controller or not .
However in the frontENd i m using reactJS i just sent a post request using axios
but when i hit submit in the network when i inspect i get
{
"code": 401,
"message": "JWT Token not found"
}
I think documentation is only showing an example. Not sure if that works out of the box because after installing it, I haven't seen a new Controller to handle the login_check route. In fact, ask to add the route manually, without referring a resource.
To generate a Token from a user, in a controller you will need to instantiate Jwt.
// src/Controller/AuthController.PHP
use App\Entity\User;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
class AuthController
{
private JWTTokenManagerInterface $jwt;
public function __construct(JWTTokenManagerInterface $jwt)
{
$this->jwt = $jwt;
}
#[Route(path: '/token', name: 'api_auth_token')]
public function login(Request $request): Response
{
// Code to retrieve your user
// [...]
// User must extends UserInterface for Lexik to work properly
$token = $this->jwt->create($user);
// return the token
}
This code will show you how to create the token, but not to login. You will have to check your authentication flow.
Side note: DonĀ“t confuse hashing the password with generating a token. You will need to do both things separately
I recommend you to look for the service you need by exploring autowirng:
php bin/console debug:autowiring jwt

Kong/Scylladb intermittent timeout issue when writing routes "received only 0 responses 2" - K8

When trying to register routes via Kong /routes, we are seeing intermittent timeout issues.
Kong and Scylladb are setup in docker/k8
[error] 41#0: *119054033 [kong] api_helpers.lua:310 could not execute insertion query: [Write timeout] Operation timed out for kong.routes - received only 0 responses from 2 CL=SERIAL., client: 10.xxx.xxx.xxx, server: kong_admin, request: \"POST /routes HTTP/1.1\"
Only happens on /routes registration call, and write_request_timeout_in_ms is set to 2000ms.
Anyone seen this issue before?

Artillery: How can I mark a test scenario as failed using artillery load test and show the same in some report?

I am working on some test requirement where I have to fail a load test scenario when p95>100ms. I have written below test snippet:
config:
target: "https://news.google.com"
# Responses have to be sent within 10 seconds or the request will be aborted
timeout: 10
ensure:
p95: 800
phases:
- duration: 10
arrivalRate: 1
scenarios:
- name: "Hit news google"
flow:
- get:
url: "/dssw.js_data?_reqid=34556&rt=j"
expect:
- statusCode: 300
- contentType: json
I want this test scenario to be visible in some kind of reports as how many test case has been failed and pass. Artillery generates the report only showing the performance stats but how to show the report as per the test performance assertion failed in some kind of report.
One option is to implement a hook in javascript that looks at the status code and if deems the status as failed returns an error trough the next function.
Example js hook function:
function exitOnFail(requestParams, response, context, ee, next) {
const statusCode = parseInt(response.statusCode);
if (statusCode > 399) {
next(new Error(`${requestParams.url} StatusCode: ${statusCode}`));
} else {
next();
}
}
and connecting the hook to the request:
config:
...
processor: './scriptfile.js'
...
scenarios:
- flow:
- get:
url: some/url
...
afterResponse: 'exitOnFail'

Symfony 4 - api platform - jwt - Custom Operations and Controllers

I am working on a project using Symfony 4.1 - api platform -jwt
I created a custom operation in the Entity
// App\Entity
/**
* #ApiResource(
* itemOperations={
* "get",
* "put",
* "delete",
* "request"={
* "method"="POST",
* "path"="/event/request",
* "controller"=ReservationController::class
* }
* }
* )
* #ORM\Entity(repositoryClass="App\Repository\EventRepository")
*/
I created my method in the approprite controller
public function __invoke(Event $data): ?Event
{
$eventType = $this->getDoctrine()->getRepository(EventType::class)->findRequestType();
$user = $this->getDoctrine()->getRepository(User::class)->find(1);
$data->setEventType($eventType);
$data->setUser($user);
return $data;
}
Before integrating JWT It was working perfekly but now when i try to acces the ressource i get this
2018-07-03T11:19:44+00:00 [info] Matched route "api_events_request_item".
2018-07-03T11:19:44+00:00 [debug] Checking for guard authentication credentials.
2018-07-03T11:19:44+00:00 [debug] Calling getCredentials() on guard configurator.
2018-07-03T11:19:44+00:00 [debug] Passing guard token information to the GuardAuthenticationProvider
2018-07-03T11:19:44+00:00 [debug] SELECT t0.id AS id_1, t0.email AS email_2, t0.password AS password_3, t0.is_active AS is_active_4, t0.role_id AS role_id_5 FROM user t0 WHERE t0.email = ? LIMIT 1
2018-07-03T11:19:44+00:00 [info] User Deprecated: Calling Symfony\Component\Security\Core\User\UserChecker::checkPreAuth with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.
2018-07-03T11:19:44+00:00 [info] User Deprecated: Calling Symfony\Component\Security\Core\User\UserChecker::checkPostAuth with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.
2018-07-03T11:19:44+00:00 [info] Guard authentication successful!
2018-07-03T11:19:44+00:00 [debug] Guard authenticator set no success response: request continues.
2018-07-03T11:19:44+00:00 [debug] Remember me skipped: it is not configured for the firewall.
2018-07-03T11:19:44+00:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Not Found" at /Users/simonackermann/Sites/courses/symfony/champeryNb/vendor/api-platform/core/src/EventListener/ReadListener.php line 103
[Tue Jul 3 13:19:44 2018] 127.0.0.1:56389 [404]: /api/event/request
Here is what i get with the debug:router command
default ANY ANY ANY /
test ANY ANY ANY /test
images ANY ANY ANY /images/{name}
api_entrypoint ANY ANY ANY /api/{index}.{_format}
api_doc ANY ANY ANY /api/docs.{_format}
api_jsonld_context ANY ANY ANY /api/contexts/{shortName}.{_format}
api_events_get_collection GET ANY ANY /api/events.{_format}
api_events_post_collection POST ANY ANY /api/events.{_format}
api_events_get_item GET ANY ANY /api/events/{id}.{_format}
api_events_put_item PUT ANY ANY /api/events/{id}.{_format}
api_events_delete_item DELETE ANY ANY /api/events/{id}.{_format}
api_events_request_item POST ANY ANY /api/event/request
api_event_types_get_collection GET ANY ANY /api/event_types.{_format}
api_event_types_get_item GET ANY ANY /api/event_types/{id}.{_format}
api_places_get_collection GET ANY ANY /api/places.{_format}
api_places_post_collection POST ANY ANY /api/places.{_format}
api_places_get_item GET ANY ANY /api/places/{id}.{_format}
api_places_delete_item DELETE ANY ANY /api/places/{id}.{_format}
api_places_put_item PUT ANY ANY /api/places/{id}.{_format}
api_users_get_collection GET ANY ANY /api/users.{_format}
api_users_post_collection POST ANY ANY /api/users.{_format}
api_users_get_item GET ANY ANY /api/users/{id}.{_format}
api_users_delete_item DELETE ANY ANY /api/users/{id}.{_format}
api_users_put_item PUT ANY ANY /api/users/{id}.{_format}
api_users_name_item GET ANY ANY /api/user/{email}
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
api_login_check ANY ANY ANY /api/login_check
Any ideas ?
Thank in advance

ServiceMix NMR + Camel Route

I use a ServiceMix + Camel combo for integration purposes.
Two of my camel routes uses the NMR component to exchange messages.
At startup I got the following exception if message were waiting to be processed:
ServiceMixException: Could not dispatch exchange. No matching endpoints.
I seems to be looking for a endpoint called xyz:enpoint_name which is created a few seconds later
18:48:44,266 | INFO | xtenderThread-10 | ManagementEndpointRegistry | ement.ManagementEndpointRegistry 129 | 88 - org.apache.servicemix.nmr.management - 1.3.0.fuse-02-00 | Registering endpoint: org.apache.servicemix.nmr.core.InternalEndpointWrapper#e6810f84 with properties {CHANNEL_SYNC_DELIVERY=false, NAME=xyz:enpoint_name}
Is that expected ?
Is there a way to prevent the route to start before all the endpoint have been initialized ?
you can also use a route policy to control the startup/shutdown of routes, perhaps add a policy to check for the dependent route consumer prior to starting, etc...

Resources