Posts From Category: tools

JMeter performance testing

We’re going to use a test app. Supposedly, this app has passed a first development iteration, and has passed unit and functional testing. With JMeter we measure its performance.
Performance testing should start early and continue through the whole dev process.

JMeter is not a browser. It doesn’t execute JavaScript!

Performance Testing

Performance is related to how fast an app executes an operation. Performance testing is about how an app or resource performs under a given load, to see its impact. It should be done after the app has passed all functional tests and we’re sure it works correctly.

Performance testing is measured in terms of:

  • response time: request time + processing time + network latency.
  • throughput: number of transactions (request/response) / unit of time (ms / seconds).
  • reliability: how well the app detects and handles errors. number of errors / number of requests.
  • scalability: tells how well the system expands its capacity in terms of response time, throughput and reliability when additional resources are added.

    • vertical scalability: adding more memory or additional CPUs.
    • horizontal scalability: adding servers to a cluster.

Performance requirements

They’re are usually set up in contracts, such as:

  • average / maximum response time.
  • pages per second the system should be able to support.
  • users per hour the system should be able to support.

Process to follow

  • Design and build tests: We have to know the app and its usage patterns.
  • Prepare test environment: configure a test env similar to prod.
  • Run the test: validate the script and test data. Monitor server logs!
  • Analyze the results
  • Optimize
  • Retest

Types of Performance Tests

  • Increase the number of users.
  • Increase the number of requests.

Almost always you should execute a smoke test first. This is a test with light load to verify the test works correctly.

A load test is a test that’s performed at a specific load level. Usually you’ll perform them at many load levels to monitor the app’s behavior.

A stress test tests the app with loads past its normal working range, to see up to which point it stays stable and responsive.

At a spike test the app is subjected to brief periods of sudden increments in the load beyond its maximum capacity, to see if the app is robust enough to work during and after the spike.

Endurance tests, where the app is subjected to load within its limits for a long duration (hours or even days) to search for memory leaks.

Read More

JMeter

JMeter is a testing tool to simulate thousands of users. It uses Java Threads for this.

Configure a Test Plan

In JMeter the components of a test are organized in a tree, where each component has a scope that determines to what other components it has access to.

Test Plan

Test Plan is the root element of a test, where all overall settings are specified and all the other elements are contained.

It allows us to:

  • Define variables to the entire test.
  • There we can set to run Thread Groups consecutively, instead of parallel.
  • We may run tearDown Thread Groups. They run at the end of the test, after a graceful shutdown of the main Threads. They won’t be run if the test is forcibly stopped.
  • If we select Functional Test Mode, JMeter will save information from the server responses to result files. Beware, as this files grow quickly and they impact performance. Only for small tests.
  • We may add jar files or directories to classpath, so they will load just for the test script.

Thread Groups

They’re the entry point of a test and controls the number of threads (users) JMeter will use to execute a test. We also have setUp and tearDown Thread Groups.

We may:

  • Set the number of users and the time it will take to create them. This creation can be delayed until they’re needed.

Configuration Elements

They’re used to set up default configurations and variables for later use by other components. They can be placed under any other component.

They are classified into:

  • elements that allows us to set variables: CSV Data Set Config, Counter or Random Variable.
  • elements that allows us to define a Configuration: JDBC Connection Configuration, KeyStore Configuration, Login Config Element.
  • managers that allow us to manage configuration params: HTTP Header Manager, HTTP Cookie Manager, HTTP Cache Manager.
  • default configuration elements: HTTP Request Defaults, FTP Request Defaults, Java Request Defaults.

The most common used are:

  • CSV Data Set Config used to read the content of a CSV file and turn it into variables.
  • HTTP Header Manager allows us to add or override HTTP Request Headers.
  • HTTP Cookie Manager For each user, it stores and sends a cookie like a browser; Allows to manually add a cookie that will be shared by all users.
  • HTTP Cache Manager Adds caching functionality to HTTP Request. Each user has its own cache.
  • User defined variables allows you to define a set of variables. They’re processed once at the start of the test and are shared between old thread groups.

He created an HTTP Request Defaults and added the IP and port number, so he doesn’t need to repeate this at every component.

Read More

Splunk

Splunk take any type of data of millions of entries and allows you to process it into reports, dashboards and alerts.

It’s great at parsing machine data. We can train Splunk to look for certain patterns in data and label those patterns as fields.

Planning Splunk Deployments

A note on config files

Everything Splunk does is governed by configuration files. They’re stored in /etc and they’ve .conf extension.

They’re layered. You can have files with the same name in several directories. You might have a global level conf file and an app specific conf file. Splunk check which one to use based on the current app.

Read More

Docker best practices

List of things to do, to improve your Docker experience

Never map the public port on a DockerFile

If you map it, you’ll only be able to have one instance of this container running. If the user wants to map the port, he’ll be able to do it in a compose script or with -p option.

# public and private mapping
EXPOSE 80:8080 # don't do this

# private mapping
EXPOSE 80

Read More

Docker, DockerFiles and docker-compose

Working docker-compose and DockerFile examples to complement this information
Interesting tool to analyze custom Image layers size

Basic Definitions

Image Executable package that includes everything needed to run an application. It consists of read-only layers, each of which represent a DockerFile instruction. The layers are stacked and each one is a delta of changes from the previous layer.
Container Instance of an image.

Stack Defines the interaction of all the services
Services Image for a microservice which defines how containers behave in production

DockerFile File with instructions that allows us to build upon an already existing image. It defines:

  • the base image to build from
  • our own files to use or append
  • the commands to run

At the end, a DockerFile will form a service, which we may call from docker-compose or standalone with docker build.

DockerFiles vs docker-compose A DockerFile is used when managing a single individual container. docker-compose is used to manage an application, which may be formed by one or more DockerFiles. Docker-compose may also be used as support to input large customization options, which otherwise would be parameters in a really long command.

You can do everything docker-compose does with just docker commands and a lot of shell scripting

Read More

Git advanced

Config

  • see config git config -l
  • modify username git config --global user.name "newName"
  • modify email git config --global user.mail "new@mail.com"

Git bisect

Is a tool to find the exact commit where a bug was introduced.

Usage

I have a file with the following content and an obvious bug

Row row row your car at the river

Read More

MySQL user privileges

How to grant privileges for a database to a user, when both already exist.

In this case the database name will be project_node1, the user project_user and the password project_pass. All the following commands have to be executed as root or with a user with enough privileges.

-- list system users
SELECT user, host FROM mysql.user;

-- see current privileges
SHOW GRANTS FOR 'project_user'@'%';

-- delete all previous privileges (if needed)
-- REVOKE ALL PRIVILEGES ON `project_node1`.* FROM 'project_user'@'%';

-- grant new privileges and flush
GRANT ALL PRIVILEGES ON `project_node1`.* TO 'project_user'@'%';
FLUSH PRIVILEGES;

Reference(s)

https://serverfault.com/questions/115950/how-do-i-change-the-privileges-for-mysql-user-that-is-already-created

Read More

MongoDB

Config

Config. to run MongoDB

  1. Set PATH as system variable (~/.bashrc)
  2. Create folders /data/db and set rw- permissions to correct user.
  3. start mongod

Queries

Find

by element

db.getCollection('documentX').find({ _id : ObjectId("5b7e99a9149559198c5024a4") })

Read More

SQL administration

(All this commands are for MySQL)

Connection

Connect to DB from CLI

mysql -u {$user} -p    

User

  • SELECT CURRENT_USER(); See current logged user
Change password when we know the old one
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('myNewPassword');

Read More

Maven

Checkstyle

To check all the errors in checkstyle and where they’re located:

  1. go to the project’s folder where the error triggers
  2. open target/checkstyle-result.xml
  3. search for ="error"
  4. there the classes’ name and the error line # can be seen

PMD

To find where the error is located. Search for the String priority="1". If nothing is found, search for prio 2, 3…

Read More

Liquibase

Restart liquibase / database status

  1. mvn liquibase:clearCheckSums
  2. mvn liquibase:dropAll This will delete the whole DB
  3. delete correct change entry from DATABASECHANGELOCK
  4. update again

Read More