Skip to content

Commit

Permalink
Merge pull request #141 from NitorCreations/perf-test-pr
Browse files Browse the repository at this point in the history
First version of performance test tools
  • Loading branch information
jsyrjala committed Apr 23, 2015
2 parents 415d9b0 + 8e82b15 commit a686fdc
Show file tree
Hide file tree
Showing 25 changed files with 1,655 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ jdk:
- openjdk7
- oraclejdk8
env:
global:
- BUILD_SYSTEM=travis
matrix:
- SPRING_PROFILES_ACTIVE=nflow.db.h2
- SPRING_PROFILES_ACTIVE=nflow.db.postgresql
- SPRING_PROFILES_ACTIVE=nflow.db.mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public enum WorkflowActionType {
recovery
}

/**
* The action id (generated by database).
*/
public int id;

/**
* The workflow instance identifier.
* @deprecated Use @{code workflowInstanceId} instead. This will be removed in 2.0.0.
Expand Down Expand Up @@ -87,6 +92,7 @@ public enum WorkflowActionType {
public final DateTime executionEnd;

WorkflowInstanceAction(Builder builder) {
this.id = builder.id;
this.workflowId = builder.workflowInstanceId;
this.workflowInstanceId = builder.workflowInstanceId;
this.executorId = builder.executorId;
Expand All @@ -104,6 +110,7 @@ public enum WorkflowActionType {
*/
public static class Builder {

int id;
int workflowInstanceId;
int executorId;
WorkflowActionType type;
Expand All @@ -125,6 +132,7 @@ public Builder() {
* @param action The workflow instance action to be copied.
*/
public Builder(WorkflowInstanceAction action) {
this.id = action.id;
this.executionEnd = action.executionEnd;
this.executionStart = action.executionStart;
this.executorId = action.executorId;
Expand All @@ -147,6 +155,16 @@ public Builder(WorkflowInstance instance) {
this.executionStart = now();
}

/**
* Set the action id (generated by database)
* @param id Action id
* @return this.
*/
public Builder setId(int id) {
this.id = id;
return this;
}

/**
* Set the workflow instance identifier.
* @param workflowInstanceId The workflow instance identifier.
Expand Down Expand Up @@ -182,7 +200,7 @@ public Builder setExecutorId(Integer executorId) {
/**
* Set the trigger type of the action.
* @param actionType The action type.
* @return this
* @return this.
*/
public Builder setType(WorkflowActionType actionType) {
this.type = actionType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public String getDescription() {

protected SpringDummyTestWorkflow() {
super("springdummy", SpringDummyTestState.start, SpringDummyTestState.end);
permit(SpringDummyTestState.start, SpringDummyTestState.end);
}

public NextAction start(StateExecution execution) {
Expand Down
6 changes: 6 additions & 0 deletions nflow-perf-test/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
2 changes: 2 additions & 0 deletions nflow-perf-test/.settings/org.eclipse.core.runtime.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
384 changes: 384 additions & 0 deletions nflow-perf-test/.settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions nflow-perf-test/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_nflow-engine
formatter_settings_version=12
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=true
sp_cleanup.insert_inferred_type_arguments=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_redundant_type_arguments=false
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
sp_cleanup.use_type_arguments=false
4 changes: 4 additions & 0 deletions nflow-perf-test/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
63 changes: 63 additions & 0 deletions nflow-perf-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
nFlow performance testing
=========================

- `ansible/` directory contains [Ansible](http://www.ansible.com/) scripts for setting up AWS performance test environment
- `com.nitorcreations.nflow.performance.client and .server` packages contain performance test client and server implementations
- `com.nitorcreations.nflow.performance.testdata` package contains tools for generating data for performance testing
- `com.nitorcreations.nflow.performance.workflow` package contains workflow definitions that are utilized by other packages

**Generate data for performance testing**

Test data is created by `NflowPerfTestServer`, when it is started with `generateTestData` argument. The test data generation process is controlled through the following properties:
- `testdata.target.count` - amount of generated workflow instances (default 100000)
- `testdata.batch.size` - size of batch in which generated workflow instances are inserted into database (default 10000)

`NflowPerfTestServer` will not process workflow instances when started with `generateTestData` argument (nflow.autostart=false).

Example: generate 1000000 workflow instances
```
java -Dnflow.db.user=nflow -Dnflow.db.password=nflownflow
-Dnflow.db.postgresql.url=jdbc:postgresql://<your_rds_database>:5432/nflow?tcpKeepAlive=true
-Dnflow.executor.group=nflow-perf -Dnflow.non_spring_workflows_filename=workflows.txt
-Dspring.profiles.active=nflow.db.postgresql -Dtestdata.target.count=1000000
-jar nflow/nflow-perf-test/target/nflow-perf-tests-*-SNAPSHOT.jar generateTestData
```

**Setup AWS environment using Ansible.**

1. Install Ansible to your workstation
* configure AWS access and secret keys ([see instructions](https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/))
* copy your AWS private key file to nflow-perf-test/ansible directory

2. Configure Ansible with your AWS account details (nflow-perf-test/ansible/vars/perf-test-environment.yml)
* ec2_region (e.g. eu-west-1)
* instances_keypair: name of your AWS private key file
* image_id: AMI for the nFlow performance test servers
* perftest_subnet: your VPC identifier
* perftest_group_ids: security groups for nFlow performance test servers

3. Create 2 nFlow servers, 1 client server, 1 Graphite server and 1 RDS database
* execute "ansible-playbook provision_ec2.yml"
* currently does not configure load balancer in front of nFlow servers, so configure this manually to port 7500

4. Deploy nFlow to AWS
* execute "ansible-playbook -i /etc/ansible/ec2.py --private-key=nbank.pem deploy_nflow.yml"
* installs required services (e.g. git and Maven) and builds nFlow from Github sources

5. Optional: Install Graphite server by following [instructions](https://github.com/dmichel1/ansible-graphite)

**Execute performance tests**

1. Connect to your nFlow servers and start servers using the following command (change parameters to match your environment):
```
java -Dhost=<your_nflow_server> -Dnflow.db.user=nflow -Dnflow.db.password=nflownflow
-Dnflow.db.postgresql.url=jdbc:postgresql://<your_rds_database>:5432/nflow?tcpKeepAlive=true
-Dnflow.executor.group=nflow-perf -Dnflow.non_spring_workflows_filename=workflows.txt
-Dspring.profiles.active=nflow.db.postgresql -Dgraphite.host=<your_graphite_server> -Dgraphite.port=2003
-jar nflow/nflow-perf-test/target/nflow-perf-tests-*-SNAPSHOT.jar
```

2. Connect to your nFlow client server and start performance client threads using the following command (change parameters to match your environment):
```
java -Dnflow.url=http://<your_nflow_server_load_balancer>:7500 -cp nflow-perf-test/target/nflow-perf-tests-*-SNAPSHOT.jar com.nitorcreations.nflow.performance.client.LoadGenerator
```
1 change: 1 addition & 0 deletions nflow-perf-test/ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nbank.pem
32 changes: 32 additions & 0 deletions nflow-perf-test/ansible/deploy_nflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# ansible-playbook -i /etc/ansible/ec2.py --private-key=nbank.pem deploy_nflow.yml
#
# TODO:
# - Start nFlow server automatically, something like:
# java -Dnflow.db.user={{ db_user }} -Dnflow.db.password={{ db_password }} -Dnflow.db.postgresql.url={{ jdbc_url }}
# -Dnflow.executor.group=nflow-perf -Dnflow.non_spring_workflows_filename=workflows.txt
# -Dspring.profiles.active=nflow.db.postgresql -jar nflow/nflow-perf-test/target/nflow-perf-tests-*-SNAPSHOT.jar

- name: Deploy and build nFlow to servers
hosts: tag_Name_nflow-perftest-nflow-*
remote_user: fedora
gather_facts: false

vars_files:
- vars/perf-test-environment.yml

tasks:
- name: Install git
yum: name=git state=present
sudo: yes

- name: Install Maven
yum: name=maven state=present
sudo: yes

- name: Clone nflow repository
git: repo=git://github.com/NitorCreations/nflow.git dest=~/nflow version=perf-test-once-more accept_hostkey=yes

- name: Build nFlow
shell: cd nflow && mvn package -DskipTests -P allModules

92 changes: 92 additions & 0 deletions nflow-perf-test/ansible/provision_ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
# ansible-playbook provision_ec2.yml
#
# Creates following servers/services to EC2
# - nFlow server(s) (server(s) being performance tested)
# - nFlow client(s) (server(s) that run performance test clients)
# - RDS service for nflow database (postgresql)
#
# Prerequisites
# - Setup AWS access key and secret (e.g. env variable or .boto-file)
# - Tune variables in vars/perf-test-environment.yml-file (TODO: automate some of these?)
# + vpc_subnet_id-variables point to correct AWS VPC
# + security groups are correct for your AWS VPC
# + current directory contains pem-file that matches instances_keypair (e.g. nbank.pem)

- name: Provision ec2 instances based on the environment
hosts: localhost
connection: local

vars_files:
- vars/perf-test-environment.yml

tasks:

- name: Launch tested nflow server instances
ec2:
region: "{{ ec2_region }}"
keypair: "{{ item.keypair }}"
group_id: "{{ item.group_id }}"
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
instance_type: "{{ item.instance_type }}"
image: "{{ item.image }}"
instance_tags: "{{ item.instance_tags }}"
exact_count: "{{ item.exact_count }}"
count_tag: "{{ item.count_tag }}"
assign_public_ip: "{{ item.assign_public_ip }}"
wait: true
register: nflow_perftest_nflow_servers
with_items: nflow_server_instances
tags: launch_nflow_server_instances

- name: Launch tested nflow client instances
ec2:
region: "{{ ec2_region }}"
keypair: "{{ item.keypair }}"
group_id: "{{ item.group_id }}"
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
instance_type: "{{ item.instance_type }}"
image: "{{ item.image }}"
instance_tags: "{{ item.instance_tags }}"
exact_count: "{{ item.exact_count }}"
count_tag: "{{ item.count_tag }}"
assign_public_ip: "{{ item.assign_public_ip }}"
wait: true
register: nflow_perftest_nflow_clients
with_items: nflow_client_instances
tags: launch_nflow_client_instances

- name: Launch RDS server
rds:
backup_retention: 0
command: create
db_name: "{{ db_name }}"
instance_name: nflow-perftest
instance_type: db.m1.small
db_engine: postgres
port: 5432
multi_zone: no
size: 5
username: "{{ db_user }}"
password: "{{ db_password }}"
region: "{{ ec2_region }}"
security_groups: public-internet-postgresql
tags: launch_rds_server

- name: Launch Graphite server
ec2:
region: "{{ ec2_region }}"
keypair: "{{ item.keypair }}"
group_id: "{{ item.group_id }}"
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
instance_type: "{{ item.instance_type }}"
image: "{{ item.image }}"
instance_tags: "{{ item.instance_tags }}"
exact_count: "{{ item.exact_count }}"
count_tag: "{{ item.count_tag }}"
assign_public_ip: "{{ item.assign_public_ip }}"
wait: true
register: nflow_perftest_graphite_server
with_items: nflow_graphite_instance
tags: launch_nflow_graphite_instance

Loading

0 comments on commit a686fdc

Please sign in to comment.