2015-07-29 03:22:14 +03:00
System Integration & Performance Testing
========================================
2016-05-05 05:24:58 +03:00
This directory contains Kafka system integration and performance tests.
2015-07-29 03:22:14 +03:00
[ducktape ](https://github.com/confluentinc/ducktape ) is used to run the tests.
2016-05-05 05:24:58 +03:00
(ducktape is a distributed testing framework which provides test runner,
result reporter and utilities to pull up and tear down services.)
2015-07-29 03:22:14 +03:00
Local Quickstart
----------------
2015-11-10 22:54:18 +03:00
This quickstart will help you run the Kafka system tests on your local machine. Note this requires bringing up a cluster of virtual machines on your local computer, which is memory intensive; it currently requires around 10G RAM.
2016-05-05 05:24:58 +03:00
For a tutorial on how to setup and run the Kafka system tests, see
2015-09-02 21:33:07 +03:00
https://cwiki.apache.org/confluence/display/KAFKA/tutorial+-+set+up+and+run+Kafka+system+tests+with+ducktape
2015-07-29 03:22:14 +03:00
* Install Virtual Box from [https://www.virtualbox.org/ ](https://www.virtualbox.org/ ) (run `$ vboxmanage --version` to check if it's installed).
* Install Vagrant >= 1.6.4 from [http://www.vagrantup.com/ ](http://www.vagrantup.com/ ) (run `vagrant --version` to check if it's installed).
2015-09-15 01:00:04 +03:00
* Install system test dependiences, including ducktape, a command-line tool and library for testing distributed systems.
2015-07-29 03:22:14 +03:00
2015-11-10 22:54:18 +03:00
$ cd kafka/tests
$ python setup.py develop
$ cd .. # back to base kafka directory
2015-07-29 03:22:14 +03:00
2015-09-15 01:00:04 +03:00
* Run the bootstrap script to set up Vagrant for testing
2015-07-29 03:22:14 +03:00
2015-09-15 01:00:04 +03:00
$ tests/bootstrap-test-env.sh
2015-07-29 03:22:14 +03:00
2015-09-15 01:00:04 +03:00
* Bring up the test cluster
2015-07-29 03:22:14 +03:00
2016-03-21 02:46:42 +03:00
$ vagrant/vagrant-up.sh
$ # When using Virtualbox, it also works to run: vagrant up
2015-07-29 03:22:14 +03:00
2015-09-15 01:00:04 +03:00
* Build the desired branch of Kafka
2016-05-05 05:24:58 +03:00
2015-09-15 01:00:04 +03:00
$ git checkout $BRANCH
$ gradle # (only if necessary)
2015-10-29 01:35:13 +03:00
$ ./gradlew systemTestLibs
2016-05-05 05:24:58 +03:00
2015-07-29 03:22:14 +03:00
* Run the system tests using ducktape:
2015-11-10 22:54:18 +03:00
$ ducktape tests/kafkatest/tests
2015-07-29 03:22:14 +03:00
EC2 Quickstart
--------------
This quickstart will help you run the Kafka system tests on EC2. In this setup, all logic is run
2016-05-05 05:24:58 +03:00
on EC2 and none on your local machine.
2015-07-29 03:22:14 +03:00
There are a lot of steps here, but the basic goals are to create one distinguished EC2 instance that
will be our "test driver", and to set up the security groups and iam role so that the test driver
can create, destroy, and run ssh commands on any number of "workers".
2016-05-05 05:24:58 +03:00
As a convention, we'll use "kafkatest" in most names, but you can use whatever name you want.
2015-07-29 03:22:14 +03:00
Preparation
-----------
2016-05-05 05:24:58 +03:00
In these steps, we will create an IAM role which has permission to create and destroy EC2 instances,
2015-07-29 03:22:14 +03:00
set up a keypair used for ssh access to the test driver and worker machines, and create a security group to allow the test driver and workers to all communicate via TCP.
* [Create an IAM role ](http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_SettingUpUser.html#Using_CreateUser_console ). We'll give this role the ability to launch or kill additional EC2 machines.
- Create role "kafkatest-master"
- Role type: Amazon EC2
- Attach policy: AmazonEC2FullAccess (this will allow our test-driver to create and destroy EC2 instances)
2016-05-05 05:24:58 +03:00
2015-07-29 03:22:14 +03:00
* If you haven't already, [set up a keypair to use for SSH access ](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html ). For the purpose
of this quickstart, let's say the keypair name is kafkatest, and you've saved the private key in kafktest.pem
2016-05-05 05:24:58 +03:00
* Next, create a security group called "kafkatest".
2015-07-29 03:22:14 +03:00
- After creating the group, inbound rules: allow SSH on port 22 from anywhere; also, allow access on all ports (0-65535) from other machines in the kafkatest group.
Create the Test Driver
----------------------
2016-05-05 05:24:58 +03:00
* Launch a new test driver machine
2015-07-29 03:22:14 +03:00
- OS: Ubuntu server is recommended
- Instance type: t2.medium is easily enough since this machine is just a driver
- Instance details: Most defaults are fine.
- IAM role -> kafkatest-master
2016-05-05 05:24:58 +03:00
- Tagging the instance with a useful name is recommended.
2015-07-29 03:22:14 +03:00
- Security group -> 'kafkatest'
2016-05-05 05:24:58 +03:00
2015-07-29 03:22:14 +03:00
* Once the machine is started, upload the SSH key to your test driver:
$ scp -i /path/to/kafkatest.pem \
/path/to/kafkatest.pem ubuntu@public.hostname.amazonaws.com:kafkatest.pem
* Grab the public hostname/IP (available for example by navigating to your EC2 dashboard and viewing running instances) of your test driver and SSH into it:
$ ssh -i /path/to/kafkatest.pem ubuntu@public.hostname.amazonaws.com
2016-05-05 05:24:58 +03:00
2015-07-29 03:22:14 +03:00
Set Up the Test Driver
----------------------
The following steps assume you have ssh'd into
the test driver machine.
* Start by making sure you're up to date, and install git and ducktape:
$ sudo apt-get update & & sudo apt-get -y upgrade & & sudo apt-get install -y git
$ pip install ducktape
* Get Kafka:
$ git clone https://git-wip-us.apache.org/repos/asf/kafka.git kafka
2016-05-05 05:24:58 +03:00
2015-07-29 03:22:14 +03:00
* Install some dependencies:
$ cd kafka
2016-05-05 05:24:58 +03:00
$ ./vagrant/aws/aws-init.sh
2015-07-29 03:22:14 +03:00
$ . ~/.bashrc
* An example Vagrantfile.local has been created by aws-init.sh which looks something like:
# Vagrantfile.local
ec2_instance_type = "..." # Pick something appropriate for your
# test. Note that the default m3.medium has
# a small disk.
2016-03-21 02:46:42 +03:00
enable_hostmanager = false
2015-07-29 03:22:14 +03:00
num_zookeepers = 0
num_kafka = 0
num_workers = 9
ec2_keypair_name = 'kafkatest'
ec2_keypair_file = '/home/ubuntu/kafkatest.pem'
ec2_security_groups = ['kafkatest']
ec2_region = 'us-west-2'
ec2_ami = "ami-29ebb519"
2016-03-21 02:46:42 +03:00
* Start up the instances:
2015-07-29 03:22:14 +03:00
2016-03-21 02:46:42 +03:00
# This will brink up worker machines in small parallel batches
$ vagrant/vagrant-up.sh --aws
2015-07-29 03:22:14 +03:00
* Now you should be able to run tests:
$ cd kafka/tests
$ ducktape kafkatest/tests
* To halt your workers without destroying persistent state, run `vagrant halt` . Run `vagrant destroy -f` to destroy all traces of your workers.