Jmeter script for switching user lists - jmeter

I have two data sets which contains teacher list and a student list,
Lets say total 30 students and two teachers and 15 assigned to one teacher and other 15 assigned to second teacher,
And I want to write a Jmeter script to below scenario,
login with first 15 students
Then login as the first teacher
Then again login with the second 15 students
Then login with the second teacher,
What is the best approach for this

Normally you should put the threads representing different groups of business or logical users under separate Thread Groups
So you will need 1 Thread Group with 15 threads for students and another Thread Group with 1 thread for teacher. The credentials can be provided using CSV Data Set Config.
If you want first login with 15 users and only after that login with 1 teacher you can use Inter-Thread Communication Plugin for implementing such synchronization.

Related

How can I create groups of users in a waiting room automatically?

We are trying to enable collaborative chats in an educational application. The general idea is that the users (students) will start an exercise, this will make them join an specific waiting room. And somehow the system should be able to decide it has enough students to create a group of n students (depending on the exercise) according to a given strategy and will send a message to those students to join a chatroom with a generated ID so that they can collaborate.
Right now we are totally blank and cannot decide on how to make the server decide wether to try and create groups or to wait for more students. Our stack is in Spring Boot, Redis and Postgress. Our initial idea was to add the students into a waiting room in Redis and launch a Spring event every time a student joined the waitlist. However, we understand that approach might generate many race conditions, which should be avoided.
Create an exercise_students table which has a SERIAL column on it, call it arrival_order or something. Another column for group_id. As students sign in for the exercise, insert them into this table. By nature SERIAL is atomically auto-incremented, so you avoid race conditions. Regularly query the table for students with no group_id (I assume you have a exercise_group table of some sort that defines how many students are part of a group). When the count reaches n, update them with the group_id and create a new group in the exercise_group table for the next group.
Relational databases are pretty good at this sort of thing. Atomic updating of state is pretty straightforward stuff.

Jmeter - How to execute two scripts together

I have two scenarios which need to be executed together:
Scenario 1: Launch ---> Login..........---> Logout. Basically it creates something. There is a unique id received.
Scenario 2: Launch ---> Login..........---> Logout. This updates the unique id received from the previous scenario.
Scenario 1 needs to be run with 70 users and 2 with another 70 users. Totally 140 users for one hour.
Scenario 2 has a dependency on 1. The unique id generated from 1 needs to be passed into 2.
How do I proceed with this execution? Thanks in Advance.
Regards,
Ajith
Normally you should be using different Thread Groups for simulating different groups of business users so you need to configure the Thread Groups like:
In order to run both Thread Groups at the same time make sure that Run Thread Groups consecutively is not checked at Test Plan level
For passing the unique ID from the 1st Thread Group to 2nd Thread Group there are 2 approaches:
Use __setProperty() function (maybe in combination with __threadNum() function if each user need to have its own ID) to store the unique ID into a JMeter Property in the 1st Thread Group. The property can be read via __P() function in the 2nd Thread Group
Use Inter-Thread Communication Plugin

Running Thread Groups for Different Actions

I want to create test plan for 100 users with different action as:
Thread group 1 with 40 users as a. launch website b. search
Thread group 1 with 30 users as a. launch website b. login c. logout
Thread group 1 with 30 users as a. launch website b. Search c. add to cart
How can I create this test plan?
You can create this test plan in many ways by using different elements. The simplest way to do this:
Add three thread group elements in your test plan and then define them accordingly.
Under each thread group, you can add your user-specific requests/sampler (login, search, logout)
Your test plan should be like:
If you want to run those thread groups one at a time, check the "Run Thread Groups consecutively" settings in the Test Plan element.

Laravel - Store and Resume data for ALL the sessions

I use the laravel session with the database. I would like to know how to resume the informations are stored for ALL the sessions, that it means between all the row in the session table.
I am developing a booking room system. I use the session in this way:
First step:
A user searches all the available room for a certain date. A list appears with all the available rooms.
Second step:
After the user selects the room, it is redirected to the pay form.
In the first step when the user selects the room, the room id is stored in the session.
The things I would like to do is this:
The session is used to store all the room are chosen by the users, in case two or more users are looking for a same room in the same period. So that the rooms are not available in the search of other users until the first user pays.
Laravel has a payload column where it stores all the key and value but it is only a sequence of letter and number.
Laravel has a payload column where it stores all the key and value but it is only a sequence of letter and number
When you call \Session::put('foo', 'bar') the value es added into an associative array that keeps all data. If you are using database driver, then laravel serialize the array to store it as a string. That is why you only can see a lot of text. So, working with session will be so complicated because you has to serialize/unserialize over again.
How to block the room? Well, there are many ways to do that, all depends from your architecture. For example, you can store selected rooms in other table for 5 minutes (enough time to pay). Lets say you can work with two tables:
selected_rooms
------------------
number | expire_at
and...
rooms
number | beds | busy
The user search for a cool room. The system must ignores all the rooms that have references to selected_rooms table that has not been expired.
When the user select a room, you store it at selected_rooms room table with a expire_at value of now + 5 minutes.
When the user pay the room, you can remove it from selected_rooms. If the user just logout or just leave the pc, it does not matter, because after 5 minutes the room is available again

How can I get a record who has two exact relation records in Laravel?

I am building a messaging system in Laravel.
Right now I have Threads, Participants and Messages tables.
Relation between threads and participants is many-to-many (one thread can have 2 participants, participants can have many threads).
I need a way to display last messages between two participants.
So the question is - how can I query a database, to find if there is a Thread which has a two exact participants?

Resources