Part I - Setup infrastructure using Machmeter

We will create the infrastructure required to perform a load test. This includes setting up a Cloud Spanner instance, creating a new database with the provided schema inside it and setting up a GKE cluster for load testing (this will be used in Part III).

This guide uses informtion from the following article: JMeter Spanner Performance Test If you are having trouble following this guide and to develop the JMeter template, please refer to the above link for additional information.

Table of contents

  1. Setting up a Fork
  2. Getting started with Machmeter
    1. Pre-Requisites
    2. Installation
  3. Identify the template to modify
  4. Create a new folder and clone the contents
  5. Modify the schema
  6. Run the machmeter setup command
  7. Conclusion

Setting up a Fork

  • Ensure that you are authenticated and have the right permissions configured before getting started. Follow this guide to ensure that all permissions are in place.
  • Create a fork of the Machmeter repository.
  • Clone the project locally.

Getting started with Machmeter

Pre-Requisites

Machmeter uses several tools under the hood. Please ensure the following are installed where Machmeter will run:

Installation

Create a clone of the Github repository of Machmeter and create export your gCloud service account credentials as follows:

$ git clone https://github.com/cloudspannerecosystem/machmeter.git
$ cd machmeter/machmeter

# Building the maven project
$ mvn clean package -P assembly

# You provide the path to service accounts key.
$ export GOOGLE_APPLICATION_CREDENTIALS=~/service-accounts.json

Identify the template to modify

Machmeter has a number of starter templates are present in the usecases directory. Browse through the list of templates to identify a template closest to what you are looking for.

Each template folder contains a README.md file with the description of what the template does. We will use this template as the basis to create our new template.

Create a new folder and clone the contents

Create a new folder in the machmeter usecases directory, and clone the contents of your picked usecase into it:

cd machmeter/usecases
 mkdir -p erp/employees
 cp -r finance/ledger/* erp/employees/
 ls 

A new usecase folder hierarchy erp/employees is created in the usecases directory with the contents of the finance/ledger folder. Verify that that it contains two-subfolders: sample-configs and templates.

Modify the schema

cd erp/employees/sample-configs
ls 

The schema file describes the database DDL. Machmeter reads this file to create the DDL on the Cloud Spanner instance you supply during machmeter setup command execution. For our erp/employees use-case, we will replace the existing file contents from financial/leger use-case with our new schema.

Open the schema.sql file in the editor of your choice, and replace its contents with the following:

CREATE TABLE departments (
  dept_no STRING(4) NOT NULL,
  dept_name STRING(40) NOT NULL,
) PRIMARY KEY(dept_no);

CREATE UNIQUE INDEX dept_name ON departments(dept_name);

CREATE TABLE dept_manager (
  dept_no STRING(4) NOT NULL,
  emp_no INT64 NOT NULL,
  from_date DATE NOT NULL,
  to_date DATE NOT NULL,
) PRIMARY KEY(dept_no, emp_no),
  INTERLEAVE IN PARENT departments ON DELETE NO ACTION;

CREATE INDEX dept_no_17 ON dept_manager(dept_no);

CREATE INDEX emp_no_18 ON dept_manager(emp_no);

CREATE TABLE employees (
  emp_no INT64 NOT NULL,
  birth_date DATE NOT NULL,
  first_name STRING(14) NOT NULL,
  last_name STRING(16) NOT NULL,
  gender STRING(MAX) NOT NULL,
  hire_date DATE NOT NULL,
) PRIMARY KEY(emp_no);

CREATE TABLE dept_emp (
  emp_no INT64 NOT NULL,
  dept_no STRING(4) NOT NULL,
  from_date DATE NOT NULL,
  to_date DATE NOT NULL,
) PRIMARY KEY(emp_no, dept_no),
  INTERLEAVE IN PARENT employees ON DELETE NO ACTION;

CREATE INDEX dept_no ON dept_emp(dept_no);

CREATE INDEX emp_no_13 ON dept_emp(emp_no);

CREATE TABLE salaries (
  emp_no INT64 NOT NULL,
  salary INT64 NOT NULL,
  from_date DATE NOT NULL,
  to_date DATE NOT NULL,
) PRIMARY KEY(emp_no, from_date),
  INTERLEAVE IN PARENT employees ON DELETE NO ACTION;

CREATE INDEX emp_no ON salaries(emp_no);

CREATE TABLE titles (
  emp_no INT64 NOT NULL,
  title STRING(50) NOT NULL,
  from_date DATE NOT NULL,
  to_date DATE,
) PRIMARY KEY(emp_no, title, from_date),
  INTERLEAVE IN PARENT employees ON DELETE NO ACTION;

CREATE INDEX emp_no_6 ON titles(emp_no);

Save the file.

Run the machmeter setup command

We can now execute the machmeter setup commmand to create a Cloud Spanner instance, create the above schema inside and create a GKE cluster inside it.

Update the configuration in the appropriate values in the sample-configs/setup.json file and run the machmeter setup command.

$ java -jar target/machmeter/machmeter.jar setup sample-configs/setup.json

Conclusion

At the end of Part I, you should have all the infrastructure needed to start using Machmeter with your new template. Next, we will discuss how to create and test a Jmeter template locally in Part II