Functional and scale performance tests using zopkio
Functional and scale performance tests
using zopkio
{‘Event’: ‘PyCON HK 2015’,
‘Name’: ‘Marcelo Araujo’,
‘Email’: ‘marcelo@gandi.net’
Agenda
● About me.
● Why we test software?
● Zopkio test framework.
● Q&A.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
About me
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● Name: Marcelo Araujo.
● Bachelor in Computer System Networking and Telecommunications.
● Post-Degree in Quality on Software Engineering.
● Python consumer since 2007.
● FreeBSD Developer since 2007 (ports and *kernel).
● DevOps at Gandi since 2015.
From To
Why we test software?
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● Assure what we created does what it supposed to do.
● The behavior with one user could be different with thousand users.
● Users could do something unexpected or not planned.
● Many different devices, browsers, operating systems and so forth.
● We want assure a good software quality.
● Validation: Are we doing the right job?
● Verification: Are we doing the job right?
A typical application infra.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
App Server Database
Your application starts like this!
Then, becomes like this.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
App Server Master DB
Slave DB
Cache
Storage
Balancer/Proxy
API Servers
Storage Replication
VMs
Services
A question!
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
As a DevOps, It is not only about test software anymore!
How can I test the infrastructure?
Zopkio test framework.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● Made by Linkedin.
● It is a test framework built to support at scale performance and functional
testing.
● It can be installed via pip.
● Latest code at: https://github.com/linkedin/Zopkio
● There is documentation.
● Enough pydoc for every each class.
● They have some examples of code.
● Under Apache 2.0 License.
● They are open for pull requests.
● Active development.
Zopkio test framework.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● Zopkio provides the ability to write tests that combine performance and
functional testing across a distributed system.
● Writing tests using Zopkio should be nearly as simple as writing tests in xUnit
or Nose.
● Zopkio strongly depends on:
○ Naarad: A system analysis tool that parses and plots time series data.
○ Paramiko: Python implementation of SSHv2 protocol.
Zopkio test framework.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● What kind of tests can we perform with zopkio?
○ Functional.
■ Ensure every function produces its expected outcome.
○ Load.
■ Understand the behaviour under a specific and expected load.
○ Stress.
■ What is the behaviour beyond the normal expected load.
○ Performance.
■ Determine the speed or effectiveness of an software or service.
Zopkio test framework.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● What we need from a functional and performance test framework?
○ ASSERT: Must be able to test a condition!
○ Get data vs time and compare with what we expected.
○ Plot graphs!
○ Provisioning before run any test.
○ Parallelize tests.
○ Control the sequence of tests.
○ Collect logs.
○ Parse logs.
○ Cleanup environment after tests.
○ An interface with test result.
○ Be able to debug! Our test is a software too.
My PYHK test lab.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
bare-metal machine
FreeBSD OS
Hypervisor Type 2 (bhyve)
VM1 (BSD) VM2 (BSD) VM3 (Linux) VM4 (BSD)
Zopkio
Switch
Server
What tests I will perform in this lab?
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● VM1 and VM2: Check how many files inside /etc/ and apply an ASSERT.
● VM1 and VM2: ICMP to example.com and check the lantency.
● VM3 and VM4: TCP Server/Client and make a connection between them.
The basic of Zopkio.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
.
|-- deployment.py
|-- naarad.cfg
|-- perf.py
|-- run.py
|-- test_suites
| |-- connection.py
| |-- machine1_etc.py
| |-- machine1_ping.py
| |-- machine2_etc.py
| `-- machine2_ping.py
|-- configs
| `-- pyhk.json
|-- scripts
| |-- ping-csv.sh
| |-- run.sh
| |-- server.py
| |-- client.py
| `-- scripts.tar
● A test suite consists of:
○ A deployment file.
○ A dynamic configuration file.
○ One or more test files.
○ A config directory.
The Zopkio framework.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● Zopkio has a main script that takes several optional arguments:
○ Run only named tests to help debug broken tests.
○ Configs overrides at execution time.
○ Log level.
○ Console log level.
● To run my test suite:
araujo@coxinha:/z/hk# zopkio run.py --nopassword --log-level DEBUG
The deployment file.
PyCON HK 2015 Marcelo Araujo <marcelo@gandi.net>
● It is in charge of provisioning machines.
● A deployment file can contain four functions:
○ setup_suite() - Will run before any of tests.
○ setup() - Will run before each test.
○ teardown() - Will run if setup() ran successfully.
○ teardown_suite() - Will run if setup_suite() ran successfully.