jmeter-ruby 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitattributes +22 -0
- data/.github/workflows/ci.yml +54 -0
- data/.gitignore +24 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/CHANGES.md +77 -0
- data/Gemfile +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +434 -0
- data/Rakefile +18 -0
- data/examples/OS_process_sampler.rb +24 -0
- data/examples/assertion_results.rb +18 -0
- data/examples/basic_auth.rb +11 -0
- data/examples/browser_headers.rb +7 -0
- data/examples/composite_graph.rb +29 -0
- data/examples/constant_throughput_timer.rb +11 -0
- data/examples/csv_data_set.rb +11 -0
- data/examples/dummy_sampler.rb +9 -0
- data/examples/duration_assertion.rb +10 -0
- data/examples/etsy_login_browse.rb +61 -0
- data/examples/extract.rb +12 -0
- data/examples/foreach_controller.rb +29 -0
- data/examples/header_manager.rb +29 -0
- data/examples/http_cache_manager.rb +11 -0
- data/examples/http_cookie_manager.rb +11 -0
- data/examples/http_request_defaults.rb +11 -0
- data/examples/http_request_post.rb +11 -0
- data/examples/http_request_with_files.rb +13 -0
- data/examples/http_request_with_query_params.rb +8 -0
- data/examples/jmeter_plugins_graphs.rb +22 -0
- data/examples/json_path_assertions.rb +11 -0
- data/examples/json_path_extractor.rb +10 -0
- data/examples/json_path_postprocessor.rb +10 -0
- data/examples/jsr223_assertion.rb +13 -0
- data/examples/ldap_sampler.rb +16 -0
- data/examples/loadosophia.rb +18 -0
- data/examples/loop_controller.rb +10 -0
- data/examples/loops_with_counter.rb +15 -0
- data/examples/once_only_controller.rb +15 -0
- data/examples/perfmon.rb +46 -0
- data/examples/real_custom_methods.rb +19 -0
- data/examples/real_page_objects.rb +41 -0
- data/examples/real_redis_data_set_with_setup.rb +123 -0
- data/examples/real_user_objects_github.rb +112 -0
- data/examples/regular_expression_extractor.rb +12 -0
- data/examples/response_assertion.rb +15 -0
- data/examples/response_time_percentiles_graph.rb +11 -0
- data/examples/rsync.rb +16 -0
- data/examples/sample_transaction.rb +18 -0
- data/examples/simple_data_writer_listener.rb +11 -0
- data/examples/stepping_thread_group.rb +30 -0
- data/examples/test_fragment.rb +14 -0
- data/examples/think_time.rb +15 -0
- data/examples/thread_groups.rb +7 -0
- data/examples/throughput_controller.rb +14 -0
- data/examples/throughput_shaping_timer.rb +20 -0
- data/examples/ultimate_thread_group.rb +39 -0
- data/examples/unicode.rb +8 -0
- data/examples/user_defined_variables.rb +10 -0
- data/examples/user_parameters.rb +28 -0
- data/examples/uuid_per_iteration.rb +15 -0
- data/jmeter-ruby.gemspec +28 -0
- data/lib/jmeter-ruby/DSL.md +235 -0
- data/lib/jmeter-ruby/dsl/access_log_sampler.rb +32 -0
- data/lib/jmeter-ruby/dsl/aggregate_graph.rb +55 -0
- data/lib/jmeter-ruby/dsl/aggregate_report.rb +55 -0
- data/lib/jmeter-ruby/dsl/ajp13_sampler.rb +41 -0
- data/lib/jmeter-ruby/dsl/assertion_results.rb +55 -0
- data/lib/jmeter-ruby/dsl/beanshell_assertion.rb +28 -0
- data/lib/jmeter-ruby/dsl/beanshell_listener.rb +28 -0
- data/lib/jmeter-ruby/dsl/beanshell_postprocessor.rb +28 -0
- data/lib/jmeter-ruby/dsl/beanshell_preprocessor.rb +28 -0
- data/lib/jmeter-ruby/dsl/beanshell_sampler.rb +28 -0
- data/lib/jmeter-ruby/dsl/beanshell_timer.rb +28 -0
- data/lib/jmeter-ruby/dsl/bsf_assertion.rb +28 -0
- data/lib/jmeter-ruby/dsl/bsf_listener.rb +28 -0
- data/lib/jmeter-ruby/dsl/bsf_postprocessor.rb +28 -0
- data/lib/jmeter-ruby/dsl/bsf_preprocessor.rb +28 -0
- data/lib/jmeter-ruby/dsl/bsf_sampler.rb +28 -0
- data/lib/jmeter-ruby/dsl/bsf_timer.rb +28 -0
- data/lib/jmeter-ruby/dsl/compare_assertion.rb +27 -0
- data/lib/jmeter-ruby/dsl/comparison_assertion_visualizer.rb +55 -0
- data/lib/jmeter-ruby/dsl/constant_throughput_timer.rb +26 -0
- data/lib/jmeter-ruby/dsl/constant_timer.rb +25 -0
- data/lib/jmeter-ruby/dsl/counter.rb +31 -0
- data/lib/jmeter-ruby/dsl/cssjquery_extractor.rb +31 -0
- data/lib/jmeter-ruby/dsl/csv_data_set_config.rb +33 -0
- data/lib/jmeter-ruby/dsl/debug_postprocessor.rb +28 -0
- data/lib/jmeter-ruby/dsl/debug_sampler.rb +27 -0
- data/lib/jmeter-ruby/dsl/distribution_graphalpha.rb +55 -0
- data/lib/jmeter-ruby/dsl/duration_assertion.rb +25 -0
- data/lib/jmeter-ruby/dsl/foreach_controller.rb +27 -0
- data/lib/jmeter-ruby/dsl/ftp_request.rb +34 -0
- data/lib/jmeter-ruby/dsl/ftp_request_defaults.rb +32 -0
- data/lib/jmeter-ruby/dsl/gaussian_random_timer.rb +26 -0
- data/lib/jmeter-ruby/dsl/generate_summary_results.rb +23 -0
- data/lib/jmeter-ruby/dsl/graph_results.rb +55 -0
- data/lib/jmeter-ruby/dsl/html_assertion.rb +30 -0
- data/lib/jmeter-ruby/dsl/html_link_parser.rb +23 -0
- data/lib/jmeter-ruby/dsl/html_parameter_mask.rb +32 -0
- data/lib/jmeter-ruby/dsl/http_authorization_manager.rb +33 -0
- data/lib/jmeter-ruby/dsl/http_cache_manager.rb +26 -0
- data/lib/jmeter-ruby/dsl/http_cookie_manager.rb +28 -0
- data/lib/jmeter-ruby/dsl/http_header_manager.rb +30 -0
- data/lib/jmeter-ruby/dsl/http_request.rb +41 -0
- data/lib/jmeter-ruby/dsl/http_request_defaults.rb +41 -0
- data/lib/jmeter-ruby/dsl/http_url_rewriting_modifier.rb +30 -0
- data/lib/jmeter-ruby/dsl/if_controller.rb +27 -0
- data/lib/jmeter-ruby/dsl/include_controller.rb +25 -0
- data/lib/jmeter-ruby/dsl/java_request.rb +69 -0
- data/lib/jmeter-ruby/dsl/java_request_defaults.rb +69 -0
- data/lib/jmeter-ruby/dsl/jdbc_connection_configuration.rb +37 -0
- data/lib/jmeter-ruby/dsl/jdbc_postprocessor.rb +33 -0
- data/lib/jmeter-ruby/dsl/jdbc_preprocessor.rb +33 -0
- data/lib/jmeter-ruby/dsl/jdbc_request.rb +33 -0
- data/lib/jmeter-ruby/dsl/jms_pointtopoint.rb +41 -0
- data/lib/jmeter-ruby/dsl/jms_publisher.rb +43 -0
- data/lib/jmeter-ruby/dsl/jms_subscriber.rb +35 -0
- data/lib/jmeter-ruby/dsl/json_path_postprocessor.rb +27 -0
- data/lib/jmeter-ruby/dsl/jsr223_assertion.rb +29 -0
- data/lib/jmeter-ruby/dsl/jsr223_listener.rb +29 -0
- data/lib/jmeter-ruby/dsl/jsr223_postprocessor.rb +29 -0
- data/lib/jmeter-ruby/dsl/jsr223_preprocessor.rb +29 -0
- data/lib/jmeter-ruby/dsl/jsr223_sampler.rb +29 -0
- data/lib/jmeter-ruby/dsl/jsr223_timer.rb +29 -0
- data/lib/jmeter-ruby/dsl/junit_request.rb +37 -0
- data/lib/jmeter-ruby/dsl/keystore_configuration.rb +28 -0
- data/lib/jmeter-ruby/dsl/ldap_extended_request.rb +42 -0
- data/lib/jmeter-ruby/dsl/ldap_extended_request_defaults.rb +42 -0
- data/lib/jmeter-ruby/dsl/ldap_request.rb +35 -0
- data/lib/jmeter-ruby/dsl/ldap_request_defaults.rb +39 -0
- data/lib/jmeter-ruby/dsl/login_config_element.rb +26 -0
- data/lib/jmeter-ruby/dsl/loop_controller.rb +26 -0
- data/lib/jmeter-ruby/dsl/mail_reader_sampler.rb +37 -0
- data/lib/jmeter-ruby/dsl/mailer_visualizer.rb +64 -0
- data/lib/jmeter-ruby/dsl/md5hex_assertion.rb +25 -0
- data/lib/jmeter-ruby/dsl/module_controller.rb +25 -0
- data/lib/jmeter-ruby/dsl/monitor_results.rb +55 -0
- data/lib/jmeter-ruby/dsl/once_only_controller.rb +23 -0
- data/lib/jmeter-ruby/dsl/os_process_sampler.rb +34 -0
- data/lib/jmeter-ruby/dsl/poisson_random_timer.rb +26 -0
- data/lib/jmeter-ruby/dsl/random_controller.rb +25 -0
- data/lib/jmeter-ruby/dsl/random_order_controller.rb +23 -0
- data/lib/jmeter-ruby/dsl/random_variable.rb +30 -0
- data/lib/jmeter-ruby/dsl/recording_controller.rb +23 -0
- data/lib/jmeter-ruby/dsl/regex_user_parameters.rb +27 -0
- data/lib/jmeter-ruby/dsl/regular_expression_extractor.rb +32 -0
- data/lib/jmeter-ruby/dsl/response_assertion.rb +31 -0
- data/lib/jmeter-ruby/dsl/response_time_graph.rb +55 -0
- data/lib/jmeter-ruby/dsl/result_status_action_handler.rb +25 -0
- data/lib/jmeter-ruby/dsl/runtime_controller.rb +25 -0
- data/lib/jmeter-ruby/dsl/save_responses_to_a_file.rb +29 -0
- data/lib/jmeter-ruby/dsl/setup_thread_group.rb +36 -0
- data/lib/jmeter-ruby/dsl/simple_config_element.rb +23 -0
- data/lib/jmeter-ruby/dsl/simple_controller.rb +23 -0
- data/lib/jmeter-ruby/dsl/simple_data_writer.rb +55 -0
- data/lib/jmeter-ruby/dsl/smime_assertion.rb +35 -0
- data/lib/jmeter-ruby/dsl/smtp_sampler.rb +51 -0
- data/lib/jmeter-ruby/dsl/soapxmlrpc_request.rb +33 -0
- data/lib/jmeter-ruby/dsl/spline_visualizer.rb +55 -0
- data/lib/jmeter-ruby/dsl/summary_report.rb +55 -0
- data/lib/jmeter-ruby/dsl/switch_controller.rb +25 -0
- data/lib/jmeter-ruby/dsl/synchronizing_timer.rb +26 -0
- data/lib/jmeter-ruby/dsl/tcp_sampler.rb +33 -0
- data/lib/jmeter-ruby/dsl/tcp_sampler_config.rb +31 -0
- data/lib/jmeter-ruby/dsl/test_action.rb +27 -0
- data/lib/jmeter-ruby/dsl/test_fragment.rb +23 -0
- data/lib/jmeter-ruby/dsl/test_plan.rb +31 -0
- data/lib/jmeter-ruby/dsl/thread_group.rb +37 -0
- data/lib/jmeter-ruby/dsl/throughput_controller.rb +32 -0
- data/lib/jmeter-ruby/dsl/transaction_controller.rb +26 -0
- data/lib/jmeter-ruby/dsl/uniform_random_timer.rb +26 -0
- data/lib/jmeter-ruby/dsl/user_defined_variables.rb +33 -0
- data/lib/jmeter-ruby/dsl/user_parameters.rb +30 -0
- data/lib/jmeter-ruby/dsl/view_results_in_table.rb +55 -0
- data/lib/jmeter-ruby/dsl/view_results_tree.rb +55 -0
- data/lib/jmeter-ruby/dsl/while_controller.rb +25 -0
- data/lib/jmeter-ruby/dsl/xml_assertion.rb +23 -0
- data/lib/jmeter-ruby/dsl/xml_schema_assertion.rb +25 -0
- data/lib/jmeter-ruby/dsl/xpath_assertion.rb +31 -0
- data/lib/jmeter-ruby/dsl/xpath_extractor.rb +31 -0
- data/lib/jmeter-ruby/dsl.rb +102 -0
- data/lib/jmeter-ruby/extend/assertions/response_assertion.rb +36 -0
- data/lib/jmeter-ruby/extend/config_elements/header_manager.rb +13 -0
- data/lib/jmeter-ruby/extend/config_elements/http_cache_manager.rb +12 -0
- data/lib/jmeter-ruby/extend/config_elements/http_cookie_manager.rb +36 -0
- data/lib/jmeter-ruby/extend/config_elements/http_request_defaults.rb +39 -0
- data/lib/jmeter-ruby/extend/config_elements/user_defined_variables.rb +13 -0
- data/lib/jmeter-ruby/extend/config_elements/user_parameters.rb +31 -0
- data/lib/jmeter-ruby/extend/controllers/foreach_controller.rb +27 -0
- data/lib/jmeter-ruby/extend/controllers/loop_controller.rb +11 -0
- data/lib/jmeter-ruby/extend/controllers/module_controller.rb +23 -0
- data/lib/jmeter-ruby/extend/controllers/throughput_controller.rb +15 -0
- data/lib/jmeter-ruby/extend/controllers/transaction_controller.rb +14 -0
- data/lib/jmeter-ruby/extend/misc/aliases.rb +21 -0
- data/lib/jmeter-ruby/extend/misc/exists.rb +13 -0
- data/lib/jmeter-ruby/extend/misc/rsync.rb +24 -0
- data/lib/jmeter-ruby/extend/misc/uuid.rb +12 -0
- data/lib/jmeter-ruby/extend/misc/with_helpers.rb +27 -0
- data/lib/jmeter-ruby/extend/plugins/jmeter_plugins.rb +120 -0
- data/lib/jmeter-ruby/extend/processors/extract.rb +28 -0
- data/lib/jmeter-ruby/extend/processors/regular_expression_extractor.rb +25 -0
- data/lib/jmeter-ruby/extend/samplers/http_request.rb +58 -0
- data/lib/jmeter-ruby/extend/samplers/jms_pointtopoint.rb +26 -0
- data/lib/jmeter-ruby/extend/samplers/soapxmlrpc_request.rb +9 -0
- data/lib/jmeter-ruby/extend/threads/setup_thread_group.rb +18 -0
- data/lib/jmeter-ruby/extend/threads/thread_group.rb +19 -0
- data/lib/jmeter-ruby/extend/timers/constant_throughput_timer.rb +11 -0
- data/lib/jmeter-ruby/extend/timers/random_timer.rb +14 -0
- data/lib/jmeter-ruby/helpers/fallback_content_proxy.rb +54 -0
- data/lib/jmeter-ruby/helpers/helper.rb +75 -0
- data/lib/jmeter-ruby/helpers/logger-colors.rb +48 -0
- data/lib/jmeter-ruby/helpers/parser.rb +135 -0
- data/lib/jmeter-ruby/helpers/strip-heredoc.rb +5 -0
- data/lib/jmeter-ruby/helpers/user-agents.rb +27 -0
- data/lib/jmeter-ruby/idl.rb +70 -0
- data/lib/jmeter-ruby/idl.xml +1488 -0
- data/lib/jmeter-ruby/plugins/active_threads_over_time.rb +57 -0
- data/lib/jmeter-ruby/plugins/composite_graph.rb +71 -0
- data/lib/jmeter-ruby/plugins/console_status_logger.rb +15 -0
- data/lib/jmeter-ruby/plugins/dummy_sampler.rb +26 -0
- data/lib/jmeter-ruby/plugins/jmx_collector.rb +73 -0
- data/lib/jmeter-ruby/plugins/json_path_assertion.rb +19 -0
- data/lib/jmeter-ruby/plugins/json_path_extractor.rb +20 -0
- data/lib/jmeter-ruby/plugins/latencies_over_time.rb +49 -0
- data/lib/jmeter-ruby/plugins/loadosophia_uploader.rb +63 -0
- data/lib/jmeter-ruby/plugins/perfmon_collector.rb +80 -0
- data/lib/jmeter-ruby/plugins/redis_data_set.rb +39 -0
- data/lib/jmeter-ruby/plugins/response_codes_per_second.rb +49 -0
- data/lib/jmeter-ruby/plugins/response_times_distribution.rb +49 -0
- data/lib/jmeter-ruby/plugins/response_times_over_time.rb +50 -0
- data/lib/jmeter-ruby/plugins/response_times_percentiles.rb +51 -0
- data/lib/jmeter-ruby/plugins/stepping_thread_group.rb +30 -0
- data/lib/jmeter-ruby/plugins/transactions_per_second.rb +50 -0
- data/lib/jmeter-ruby/plugins/ultimate_thread_group.rb +23 -0
- data/lib/jmeter-ruby/plugins/variable_throughput_timer.rb +27 -0
- data/lib/jmeter-ruby/version.rb +12 -0
- data/lib/jmeter-ruby.rb +27 -0
- data/mise.toml +2 -0
- data/script/release +162 -0
- data/spec/constant_throughput_timer_spec.rb +20 -0
- data/spec/csv_data_set_config_spec.rb +33 -0
- data/spec/header_manager_spec.rb +37 -0
- data/spec/http_cache_manager_spec.rb +29 -0
- data/spec/http_cookie_manager_spec.rb +169 -0
- data/spec/http_request_defaults_spec.rb +57 -0
- data/spec/http_request_spec.rb +305 -0
- data/spec/jmeter_plugins_spec.rb +245 -0
- data/spec/json_extractor_spec.rb +19 -0
- data/spec/json_path_assertion_spec.rb +28 -0
- data/spec/logic_controller_spec.rb +148 -0
- data/spec/loop_controller_spec.rb +19 -0
- data/spec/module_controller_spec.rb +56 -0
- data/spec/regular_expression_extractor_spec.rb +63 -0
- data/spec/response_assertion_spec.rb +69 -0
- data/spec/setup_thread_group_spec.rb +31 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/thread_group_spec.rb +57 -0
- data/spec/throughput_controller_spec.rb +24 -0
- data/spec/transaction_controller_spec.rb +30 -0
- data/spec/user_defined_variables_spec.rb +22 -0
- data/spec/user_parameters_spec.rb +45 -0
- data/spec/with_helpers_spec.rb +57 -0
- data/spec/xpath_extractor_spec.rb +15 -0
- metadata +360 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
################################################################################
|
2
|
+
# This is an example of how to use a Redis data set with CSV data.
|
3
|
+
# The test plan defines a setup thread group with a JSR223 sampler (scripted in
|
4
|
+
# Groovy), which pre-populates Redis with the data used for the actual test.
|
5
|
+
# The test itself simply calls a REST API with data seeded from Redis.
|
6
|
+
#
|
7
|
+
# The redis key is "test_data" and the format of the CSV data is:
|
8
|
+
# user_id,start_date,end_date
|
9
|
+
#
|
10
|
+
# Requires:
|
11
|
+
# JMeter (recommended version: 2.13 or later)
|
12
|
+
# jmeter-plugins extras with libs (this gives us the redis data set config)
|
13
|
+
# Groovy 2.4 or later (put the groovy-all jar into $JMETER_HOME/lib)
|
14
|
+
################################################################################
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
17
|
+
require 'jmeter-ruby'
|
18
|
+
|
19
|
+
# For redis dataset config.
|
20
|
+
redis_host = 'localhost'
|
21
|
+
redis_port = 6379
|
22
|
+
redis_key = 'test_data'
|
23
|
+
num_records = 1000 # how many rows of test data to generate
|
24
|
+
|
25
|
+
# for HTTP request defaults
|
26
|
+
protocol = 'http'
|
27
|
+
host = 'localhost'
|
28
|
+
port = 8080
|
29
|
+
|
30
|
+
# JMeter test plan begins here.
|
31
|
+
test do
|
32
|
+
|
33
|
+
# Setup the data set we will use to run the tests.
|
34
|
+
setup_thread_group name: 'Redis Fill',
|
35
|
+
loops: 1 do
|
36
|
+
jsr223_sampler name: 'redis fill',
|
37
|
+
scriptLanguage: 'groovy',
|
38
|
+
cacheKey: 'prefill_user_ids',
|
39
|
+
script: <<-EOS.strip_heredoc
|
40
|
+
import redis.clients.jedis.JedisPoolConfig;
|
41
|
+
import redis.clients.jedis.JedisPool;
|
42
|
+
import redis.clients.jedis.Jedis;
|
43
|
+
|
44
|
+
import java.util.Random;
|
45
|
+
import java.util.Date;
|
46
|
+
import java.text.DateFormat;
|
47
|
+
import java.text.SimpleDateFormat;
|
48
|
+
|
49
|
+
JedisPoolConfig config = new JedisPoolConfig();
|
50
|
+
JedisPool pool = new JedisPool(config, "#{redis_host}", #{redis_port});
|
51
|
+
Jedis jedis = null;
|
52
|
+
try {
|
53
|
+
jedis = pool.getResource();
|
54
|
+
|
55
|
+
//delete old data, if it exists
|
56
|
+
jedis.del("#{redis_key}");
|
57
|
+
|
58
|
+
// Create a list of the last 90 days. We will seed our test data from this.
|
59
|
+
Date now = new Date();
|
60
|
+
Date oldest = now - 90;
|
61
|
+
Range days = oldest..now;
|
62
|
+
|
63
|
+
Random random = new Random();
|
64
|
+
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
65
|
+
|
66
|
+
/*
|
67
|
+
* Generate CSV data in the form of:
|
68
|
+
* user_id,start_date,end_date
|
69
|
+
*/
|
70
|
+
for (int i = 1; i <= #{num_records}; i++) {
|
71
|
+
Date day = days[random.nextInt(days.size())]
|
72
|
+
String data = [i, df.format(day), df.format(day)].join(',')
|
73
|
+
jedis.sadd("#{redis_key}", data);
|
74
|
+
}
|
75
|
+
}finally {
|
76
|
+
if(jedis != null) {
|
77
|
+
pool.returnResource(jedis);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
EOS
|
81
|
+
end
|
82
|
+
|
83
|
+
# Defines a thread group. We allow certain parameters to be passed in
|
84
|
+
# as system properties.
|
85
|
+
threads name: 'Test Scenario - REST API query',
|
86
|
+
count: '${__P(threads,1)}',
|
87
|
+
rampup: '${__P(rampup,600)}',
|
88
|
+
duration: '${__P(duration, 600)}' do
|
89
|
+
|
90
|
+
# HTTP request defaults
|
91
|
+
defaults domain: host, # default domain if not specified in URL
|
92
|
+
protocol: protocol, # default protocol if not specified in URL
|
93
|
+
port: port,
|
94
|
+
download_resources: false # download images/CSS/JS (no)
|
95
|
+
|
96
|
+
cookies # om nom nom
|
97
|
+
|
98
|
+
cache clear_each_iteration: true # each thread iteration mimics a new user with an empty browser cache
|
99
|
+
|
100
|
+
with_gzip # add HTTP request headers to allow GZIP compression. Most sites support this nowadays.
|
101
|
+
|
102
|
+
# Test data. Note how the variableNames match the variables used by the
|
103
|
+
# sampler below.
|
104
|
+
redis_data_set 'test data',
|
105
|
+
redisKey: redis_key,
|
106
|
+
host: redis_host,
|
107
|
+
port: redis_port,
|
108
|
+
variableNames: 'user_id,start_date,end_date'
|
109
|
+
|
110
|
+
# User workflow begins here.
|
111
|
+
visit name: 'REST API query',
|
112
|
+
url: '/rest/query',
|
113
|
+
always_encode: true,
|
114
|
+
fill_in: {
|
115
|
+
'user_id' => '${user_id}',
|
116
|
+
'start' => '${start_date}',
|
117
|
+
'end' => '${end_date}'
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
response_time_graph
|
122
|
+
view_results_tree
|
123
|
+
end.jmx(file: 'real_redis_data_set_with_setup.jmx')
|
@@ -0,0 +1,112 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
# Virtual user definitions
|
5
|
+
class VirtualUser
|
6
|
+
|
7
|
+
# initializes the VirtualUser object and adds some default test
|
8
|
+
# components.
|
9
|
+
# @param dsl the dsl
|
10
|
+
def initialize(dsl)
|
11
|
+
@dsl = dsl
|
12
|
+
|
13
|
+
defaults domain: 'github.com', # default domain if not specified in URL
|
14
|
+
protocol: 'http', # default protocol if not specified in URL
|
15
|
+
download_resources: true, # download images/CSS/JS
|
16
|
+
use_concurrent_pool: 6, # mimic Chrome/IE parallelism for images/CSS/JS
|
17
|
+
urls_must_match: '(https?.\/\/)?([^\.]*\.)*(github\.com)?\/.*' # only download resources for the target domain
|
18
|
+
|
19
|
+
cookies # om nom nom
|
20
|
+
|
21
|
+
cache clear_each_iteration: true # each thread iteration mimics a new user with an empty browser cache
|
22
|
+
|
23
|
+
with_user_agent 'ie9' # send IE9 browser headers
|
24
|
+
|
25
|
+
with_gzip # add HTTP request headers to allow GZIP compression. Most sites support this nowadays.
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# Adds a user think time. Note that this is slightly different than the
|
30
|
+
# default JMeter think time, in that it executes sequentially with test steps.
|
31
|
+
# @param delay [int] the target pause time, in milliseconds
|
32
|
+
# @param deviation [int] the pause deviation, in milliseconds
|
33
|
+
def pause(delay=30000, deviation=5000)
|
34
|
+
test_action name: 'Think Time', action: 1, target: 0, duration: 0 do
|
35
|
+
think_time delay, deviation
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Requests the home page.
|
40
|
+
def home_page
|
41
|
+
visit name: 'Home page', url: '/'
|
42
|
+
pause
|
43
|
+
end
|
44
|
+
|
45
|
+
# Searches for a repository.
|
46
|
+
# @param repo [String] the repository to search for
|
47
|
+
def search_for_repository(repo)
|
48
|
+
visit name: 'Search for project', url: '/search',
|
49
|
+
always_encode: true,
|
50
|
+
fill_in: {
|
51
|
+
'q' => repo,
|
52
|
+
'ref' => 'cmdform'
|
53
|
+
}
|
54
|
+
pause
|
55
|
+
end
|
56
|
+
|
57
|
+
# Visits a repository page.
|
58
|
+
# @param repo_path [String] the repository URL path
|
59
|
+
def view_repository(repo_path)
|
60
|
+
visit name: 'Repository page', url: repo_path
|
61
|
+
pause
|
62
|
+
end
|
63
|
+
|
64
|
+
# Views a branch/tag page.
|
65
|
+
# @param branch_path [String] the branch URL path
|
66
|
+
def view_branch(branch_path)
|
67
|
+
visit name: 'Branch page', url: branch_path
|
68
|
+
pause
|
69
|
+
end
|
70
|
+
|
71
|
+
####################################################################
|
72
|
+
private
|
73
|
+
|
74
|
+
# Passes method calls through to the underlying DSL.
|
75
|
+
# @param method the method
|
76
|
+
# @param args the arguments
|
77
|
+
# @param block the block
|
78
|
+
def method_missing method, *args, &block
|
79
|
+
@dsl.__send__ method, *args, &block
|
80
|
+
end
|
81
|
+
####################################################################
|
82
|
+
end
|
83
|
+
|
84
|
+
# JMeter test plan begins here.
|
85
|
+
test do
|
86
|
+
|
87
|
+
# Defines a thread group. We allow certain parameters to be passed in
|
88
|
+
# as system properties.
|
89
|
+
threads count: '${__P(threads,1)}',
|
90
|
+
rampup: '${__P(rampup,600)}',
|
91
|
+
name: 'Test Scenario - GitHub project navigation',
|
92
|
+
duration: '${__P(duration, 600)}' do
|
93
|
+
|
94
|
+
user = VirtualUser.new(self) # This will add a bunch of test components.
|
95
|
+
|
96
|
+
# In the event of an error, the thread will start a new loop. If this
|
97
|
+
# happens on the first request, we could start flooding the site with
|
98
|
+
# requests.
|
99
|
+
# To prevent this from happening, we insert a quick pause before the
|
100
|
+
# first request.
|
101
|
+
user.pause 1000,0
|
102
|
+
|
103
|
+
# User workflow begins here.
|
104
|
+
# Note that think times are defined inside the page methods.
|
105
|
+
user.home_page
|
106
|
+
user.search_for_repository 'jmeter-ruby'
|
107
|
+
user.view_repository '/flood-io/jmeter-ruby'
|
108
|
+
user.view_branch '/flood-io/jmeter-ruby/tree/v2.11.8'
|
109
|
+
|
110
|
+
end
|
111
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
112
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 1 do
|
6
|
+
visit name: 'Home', url: 'https://flooded.io' do
|
7
|
+
regex pattern: "content='(.+?)' name='csrf-token'", name: 'csrf-token', match_number: 1, default: '424242'
|
8
|
+
regex pattern: 'pattern', name: 'jmeter_variable_regex', variable: 'test'
|
9
|
+
regex pattern: 'pattern', name: 'jmeter_headers_regex', useHeaders: true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end.run(path: '/usr/local/share/jmeter-3.1/bin/', gui: true)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 2 do
|
6
|
+
transaction name: 'Assertions' do
|
7
|
+
visit name: 'Altentee', url: 'http://altentee.com/' do
|
8
|
+
assert contains: 'We test, tune and secure your site'
|
9
|
+
assert 'not-contains' => 'Something in frames', scope: 'children'
|
10
|
+
assert 'substring' => 'Something in frames', variable: 'test'
|
11
|
+
assert pattern: 'pattern', test_field: 'Assertion.response_headers'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end.run(path: '/usr/local/share/jmeter-3.1/bin/', gui: true)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 100 do
|
6
|
+
response_times_percentiles 'Response Times Percentiles', filename: '/path/to/output', update_at_xpath: [
|
7
|
+
{ '//value/xml' => 'false' }
|
8
|
+
]
|
9
|
+
|
10
|
+
end
|
11
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
data/examples/rsync.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 10 do
|
6
|
+
visit name: 'Home Page', url: 'https://flooded.io'
|
7
|
+
end
|
8
|
+
end.rsync(
|
9
|
+
remote_host: 'xxx.xxx.xxx.xxx',
|
10
|
+
remote_user: 'user',
|
11
|
+
remote_path: '/path/to/remote',
|
12
|
+
rsync_bin_path: '/usr/bin/rsync',
|
13
|
+
rsync_params: '-az -e "ssh -i /path/to/key.pem"',
|
14
|
+
file: './jmx/' + File.basename(__FILE__, ".rb") + '.jmx',
|
15
|
+
debug: true
|
16
|
+
)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 1 do
|
6
|
+
# this will let you sample 1 in every N (e.g. 100) transactions on Flood IO
|
7
|
+
get name: 'Home Page', sample: 100, url: 'http://google.com/'
|
8
|
+
|
9
|
+
post name: 'create session', url: '/api/oauth', sample: 100,
|
10
|
+
fill_in: {
|
11
|
+
username: 'Michel Rosen',
|
12
|
+
password: 4141414141
|
13
|
+
} do
|
14
|
+
extract json: '.access_token', name: 'access_token'
|
15
|
+
with_xhr
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 1 do
|
6
|
+
visit name: 'Home Page', url: 'https://flooded.io/'
|
7
|
+
|
8
|
+
# write errors to a simple data writer with the log alias
|
9
|
+
log filename: '/var/log/flood/custom.log', error_logging: true
|
10
|
+
end
|
11
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
|
6
|
+
defaults domain: 'example.com'
|
7
|
+
|
8
|
+
with_user_agent :chrome
|
9
|
+
|
10
|
+
header [
|
11
|
+
{ name: 'Accept-Encoding', value: 'gzip,deflate,sdch' },
|
12
|
+
{ name: 'Accept', value: 'text/javascript, text/html, application/xml, text/xml, */*' }
|
13
|
+
]
|
14
|
+
|
15
|
+
step name: 'stepping thread group example',
|
16
|
+
total_threads: 200,
|
17
|
+
initial_delay: 0,
|
18
|
+
start_threads: 20,
|
19
|
+
add_threads: 0,
|
20
|
+
start_every: 30,
|
21
|
+
stop_threads: 50,
|
22
|
+
stop_every: 5,
|
23
|
+
flight_time: 1800,
|
24
|
+
rampup: 5 do
|
25
|
+
|
26
|
+
random_timer 1000, 3000
|
27
|
+
|
28
|
+
get name: 'home', url: '/'
|
29
|
+
end
|
30
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
|
6
|
+
test_fragment name: 'anonymous_user', enabled: false do
|
7
|
+
get name: 'Home Page', url: 'http://google.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
threads count: 1 do
|
11
|
+
module_controller test_fragment: 'WorkBench/TestPlan/anonymous_user'
|
12
|
+
end
|
13
|
+
|
14
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 100 do
|
6
|
+
|
7
|
+
think_time 5000, 5000
|
8
|
+
|
9
|
+
transaction name: 'Google Search' do
|
10
|
+
visit name: 'Home Page', url: 'https://flooded.io/'
|
11
|
+
random_timer 3000
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 100 do
|
6
|
+
|
7
|
+
think_time 5000,5000
|
8
|
+
|
9
|
+
throughput_controller percent: 99 do
|
10
|
+
transaction name: "TC_01", parent: true, include_timers: true
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 100 do # threads = RPS * <max response time ms> / 1000
|
6
|
+
|
7
|
+
throughput_shaper name: 'increasing load test', steps: [
|
8
|
+
{ :start_rps => 100, :end_rps => 100, :duration => 60 },
|
9
|
+
{ :start_rps => 200, :end_rps => 200, :duration => 60 },
|
10
|
+
{ :start_rps => 300, :end_rps => 300, :duration => 60 },
|
11
|
+
{ :start_rps => 400, :end_rps => 400, :duration => 60 },
|
12
|
+
{ :start_rps => 500, :end_rps => 500, :duration => 60 },
|
13
|
+
{ :start_rps => 600, :end_rps => 600, :duration => 60 }
|
14
|
+
]
|
15
|
+
|
16
|
+
transaction name: 'Google Search' do
|
17
|
+
visit name: 'Home Page', url: 'https://flooded.io/'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
|
6
|
+
defaults domain: 'example.com'
|
7
|
+
|
8
|
+
with_user_agent :chrome
|
9
|
+
|
10
|
+
header [
|
11
|
+
{ name: 'Accept-Encoding', value: 'gzip,deflate,sdch' },
|
12
|
+
{ name: 'Accept', value: 'text/javascript, text/html, application/xml, text/xml, */*' }
|
13
|
+
]
|
14
|
+
|
15
|
+
ultimate name: 'ultimate thread group example',
|
16
|
+
on_sample_error: 'startnextloop',
|
17
|
+
threads: [
|
18
|
+
{
|
19
|
+
start_threads: 200,
|
20
|
+
initial_delay: 0,
|
21
|
+
start_time: 30,
|
22
|
+
hold_time: 60,
|
23
|
+
stop_time: 5
|
24
|
+
},
|
25
|
+
{
|
26
|
+
start_threads: 200,
|
27
|
+
initial_delay: 60,
|
28
|
+
start_time: 30,
|
29
|
+
hold_time: 60,
|
30
|
+
stop_time: 5
|
31
|
+
}
|
32
|
+
] do
|
33
|
+
|
34
|
+
random_timer 1000, 3000
|
35
|
+
|
36
|
+
get name: 'home', url: '/'
|
37
|
+
|
38
|
+
end
|
39
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
data/examples/unicode.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
# user defined with multiple values
|
6
|
+
variables [
|
7
|
+
{ name: 'email', value: 'support@flood.io' },
|
8
|
+
{ name: 'password', value: 'password' }
|
9
|
+
]
|
10
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
# user parameters with multiple values
|
6
|
+
post name: 'oauth', url: 'https://flooded.io/api/oauth', raw_body: '${token}' do
|
7
|
+
user_parameters names: ['token'],
|
8
|
+
thread_values: {
|
9
|
+
user_1: [
|
10
|
+
'<xml>fidget widget</xml>'
|
11
|
+
]
|
12
|
+
}
|
13
|
+
|
14
|
+
user_parameters names: ['name1', 'name2'],
|
15
|
+
thread_values: {
|
16
|
+
user_1: [
|
17
|
+
'user1_value1',
|
18
|
+
'user1_value2'
|
19
|
+
],
|
20
|
+
|
21
|
+
user_2: [
|
22
|
+
'user2_value1',
|
23
|
+
'user2_value2'
|
24
|
+
]
|
25
|
+
},
|
26
|
+
per_iteration: true
|
27
|
+
end
|
28
|
+
end.run(path: '/usr/local/share/jmeter-3.1/bin/', gui: true)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'jmeter-ruby'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads count: 1, loops: 5, scheduler: false do
|
6
|
+
# Helper method to generate a single UUID per iteration
|
7
|
+
uuid_per_iteration
|
8
|
+
|
9
|
+
dummy_sampler name: '${__threadNum} - ${UUID}'
|
10
|
+
dummy_sampler name: '${__threadNum} - ${UUID}'
|
11
|
+
dummy_sampler name: '${__threadNum} - ${UUID}'
|
12
|
+
|
13
|
+
view_results
|
14
|
+
end
|
15
|
+
end.run(path: '/usr/local/share/jmeter-3.1/bin', gui: true)
|
data/jmeter-ruby.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jmeter-ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'jmeter-ruby'
|
8
|
+
gem.version = JmeterRuby::VERSION::STRING
|
9
|
+
gem.authors = ['Reegan Viljoen']
|
10
|
+
gem.email = ['reeganviljoen@outlook.com']
|
11
|
+
gem.description = %q{Ruby based DSL for writing JMeter test plans}
|
12
|
+
gem.summary = %q{Ruby based DSL for writing JMeter test plans}
|
13
|
+
gem.homepage = 'https://github.com/reeganviljoen/jmeter-ruby/issues'
|
14
|
+
gem.required_ruby_version = ">= 3.1.0"
|
15
|
+
|
16
|
+
gem.add_dependency 'rest-client'
|
17
|
+
gem.add_dependency 'nokogiri'
|
18
|
+
gem.add_runtime_dependency('json-jruby') if RUBY_PLATFORM == 'java'
|
19
|
+
|
20
|
+
gem.add_development_dependency "simplecov", "~> 0.22.0"
|
21
|
+
gem.add_development_dependency "simplecov-console", "~> 0.9.1"
|
22
|
+
|
23
|
+
gem.files = `git ls-files`.split($/)
|
24
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
25
|
+
gem.require_paths = ['lib']
|
26
|
+
|
27
|
+
gem.license = 'MIT'
|
28
|
+
end
|