Gatling: Parametrizar

Descubre cómo parametrizar pruebas Gatling desde la línea de comandos con Maven: pasar usuarios y repeticiones a una simulación en Scala, integrarlo en CI/CD y obtener métricas de rendimiento.

18 ago 2025 • 2 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Este artículo explica cómo parametrizar pruebas en Gatling y enviar valores desde la línea de comandos a una simulación escrita en Scala. A continuación se muestra un ejemplo de cómo invocar Maven para ejecutar una prueba Gatling pasando parámetros de usuarios y repeticiones

mvn -ntp -f $retDir/gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=3

En la simulación Scala se pueden leer esos parámetros con Integer.getInteger y java.lang.Long.getLong para fijar el número de usuarios y el número de repeticiones. El siguiente fragmento muestra cómo usar esos parámetros dentro de una clase que extiende Simulation. Se han escapado los símbolos angulares para evitar interpretaciones HTML y las comillas literales se representan con entidades HTML

class LoadTest extends Simulation { val nbUsers = Integer.getInteger("users", 1000) val myRepeat = java.lang.Long.getLong("repeat", 2) val httpProtocol = http.baseUrl("https://localhost:8080") val scn = scenario("hello").repeat(myRepeat.toInt) { exec(http("GetApplicationInfo") .get("/hello") .check(status.is(200)) .check(jsonPath("$.name"))) } setUp( scn.inject( rampUsers(nbUsers) during (5 seconds) ).protocols(httpProtocol) ) }

Con esta configuración la prueba enviará nbUsers peticiones hacia https://localhost:8080/hello repetidas myRepeat veces. Los parámetros users y repeat se pasan desde la línea de comandos mediante las opciones -Dusers y -Drepeat al invocar Maven. Esto permite ejecutar varias combinaciones de carga sin modificar el código fuente, facilitando pruebas automatizadas y pipelines CI CD.

Consejos prácticos para parametrizar y ejecutar pruebas Gatling

1. Validar valores por defecto: siempre proporcione valores por defecto en el código para evitar fallos si no se pasa un parámetro. 2. Tipos y conversiones: Integer.getInteger y java.lang.Long.getLong devuelven valores empaquetados; convierta a Int cuando sea necesario. 3. Integración con CI CD: exporte variables de entorno o pase -D en los scripts de ejecución para automatizar variaciones de carga. 4. Recolección de métricas: configure checks y reportes para medir tiempos de respuesta, errores y throughput y así tomar decisiones basadas en datos.

En Q2BSTUDIO somos especialistas en desarrollo de software a medida y aplicaciones a medida. Además de pruebas de rendimiento y automatización, ofrecemos servicios en inteligencia artificial, ia para empresas, agentes IA y soluciones de inteligencia de negocio incluyendo power bi. También cubrimos ciberseguridad, servicios cloud aws y azure y consultoría para arquitecturas escalables y seguras.

Si necesitas ayuda para integrar pruebas de carga Gatling en pipelines, parametrizar escenarios para pruebas automatizadas, o diseñar aplicaciones a medida con capacidades de inteligencia artificial y análisis con power bi, en Q2BSTUDIO podemos asesorarte y desarrollar la solución adaptada a tus necesidades. Palabras clave para posicionamiento: aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA, power bi.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat