Skip to content

Antnch/marucy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marucy manual

N|Solid

Marucy is a tool for postgres testing from Miro

Author: Necheukhin Anton

0. Install ansible and terraform (last versions)

  • Ansible
  • Terraform
  • Generate  ssh-key if you do not have it: ssh-keygen
    The key will be placed in the directory: ~/.ssh
    The file with the private key must be limited in access: chmod 400 ~/.ssh/id_rsa

1. Scenario creating

1.Create dumpall of database, which will be used to record scenario:

su postgres
cd ~
pg_dumpall > backup_dball.sql

2.Remove postgres role creating from dump:

sed --in-place '/CREATE ROLE postgres;/d' backup_dball.sql

3.Put logging settings to postgres.conf:

log_destination = 'csvlog'
log_directory = '/logs/pg_log'
logging_collector = on
log_min_duration_statement = 0
log_min_messages = error 
log_min_error_statement = log
log_connections = on
log_disconnections = on
log_statement = 'all'

*path /logs/pg_log can be placed on a separate disc if it’s necessary

3.Restart postgres:

systemctl restart postgres

4.Do load testing to record queries. Queries will be recorded in csv file in directory /logs/pg_log. While load testing is doing check that logs are recording.

5.Convert logs to binary pgreplay format. Pgreplay is needed for the following:

cat *.csv > ./test.replay.csv

apt install pgreplay

pgreplay -f -c -o /logs/pg_log/test.replay.csv /logs/pg_log/test.replay

-> test.replay is a scenario

2. Instances creating

1.Download marucy: git clone https://github.com/Antnch/marucy.git
2.Move to marucy/terraform directory
3.Add keys to marucy/terraform/variables.tf: aws_access_key, aws_secret_key, ssh_key
4.Initialize a working directory containing Terraform configuration files: terraform init
5.Check terraform plan: terraform plan
6.Create instances and setup network: terraform apply

3. Instances configuring

Copy public IP of created instances to marucy/ansible/hosts.tpl

You can install all by single command: ansible-playbook all.yml -i hosts.tpl
Total duration ~ 9m

Or parts:
1.Move to marucy/ansible directory
2.Install postgres: ansible-playbook postgresql.yml -i hosts.tpl
authentication data: marucy/ansible/group_vars/all.yml
duration ~ 3m 48s
3.Install tool for launch test: ansible-playbook base.yml -i hosts.tpl
duration ~ 1m 24 s
4.Restore database for test: ansible-playbook restore.yml -i hosts.tpl
duration ~ 10s
5.Install exporters to collect metrics: ansible-playbook exporters.yml -i hosts.tpl
duration ~ 1m 16s
6.Install prometheus and grafana: ansible-playbook monitoring.yml -i hosts.tpl
duration ~ 2m 5s

4. Launch scenario

1.Move to db_instance by ssh: ssh root@"{{ db_instance_IP }}"
2.Move to /tmp directory
3.Extract test.replay.gz: tar -xvf test.replay.gz
4.Open Grafana dashboards: http://{{ monitoring_IP }}:3000/
login:admin
password: admin
5.Launch scenario: pgreplay -r -h {{ db_data_IP }} -W changeme -s 2 test.replay
*changeme - password from marucy/ansible/group_vars/all.yml

About

Marucy is a tool for postgres testing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages