├── .edts ├── .gitignore ├── INSTALL ├── Makefile ├── README.md ├── basho_builds.yml ├── bcrunner.sh ├── bin ├── reset-current-env.sh ├── rtdev-all.sh ├── rtdev-build-releases.sh ├── rtdev-current.sh ├── rtdev-install.sh └── rtdev-setup-releases.sh ├── compare.sh ├── dialyzer.ignore-warnings ├── doc └── overview.edoc ├── examples ├── riak_test.config └── riak_test.config.perf ├── include ├── rt.hrl ├── rt_pipe.hrl └── yokozuna_rt.hrl ├── intercepts ├── hashtree_intercepts.erl ├── init_intercepts.erl ├── intercept.erl ├── intercept.hrl ├── riak_core_broadcast_intercepts.erl ├── riak_core_connection_intercepts.erl ├── riak_core_console_intercepts.erl ├── riak_core_handoff_sender_intercepts.erl ├── riak_core_ring_manager_intercepts.erl ├── riak_core_vnode_master_intercepts.erl ├── riak_core_vnode_proxy_sup_intercepts.erl ├── riak_ensemble_peer_intercepts.erl ├── riak_kv_bitcask_backend_intercepts.erl ├── riak_kv_console_intercepts.erl ├── riak_kv_eleveldb_backend_intercepts.erl ├── riak_kv_get_fsm_intercepts.erl ├── riak_kv_index_hashtree_intercepts.erl ├── riak_kv_js_manager_intercepts.erl ├── riak_kv_put_fsm_intercepts.erl ├── riak_kv_qry_buffers_intercepts.erl ├── riak_kv_ts_newtype_intercepts.erl ├── riak_kv_vnode_intercepts.erl ├── riak_kv_worker_intercepts.erl ├── riak_object_intercepts.erl ├── riak_pipe_vnode_intercepts.erl ├── riak_repl2_fs_node_reserver_intercepts.erl ├── riak_repl2_fssource_intercepts.erl ├── riak_repl2_leader_intercepts.erl ├── riak_repl2_rtq_intercepts.erl ├── riak_repl2_rtsink_conn_intercepts.erl ├── riak_repl2_rtsource_helper_intercepts.erl ├── riak_repl_aae_source_intercepts.erl ├── riak_repl_console_intercepts.erl ├── riak_repl_reduced_intercepts.erl ├── riak_repl_ring_handler_intercepts.erl └── riak_repl_util_intercepts.erl ├── perf ├── 2iperf.erl ├── consistent_get_put.erl ├── crdt_team_map.erl └── get_put.erl ├── priv ├── 1.4-default-app.config ├── certs │ ├── README │ ├── cacert.org │ │ ├── ca-cert-old.pem │ │ ├── ca-cert.pem │ │ ├── ca-key.pem │ │ ├── ca │ │ │ └── root.crt │ │ ├── ny-cert-old.pem │ │ ├── ny-cert.pem │ │ └── ny-key.pem │ └── selfsigned │ │ ├── ca │ │ ├── cacert.pem │ │ └── rootcert.pem │ │ ├── site1-cert.pem │ │ ├── site1-key.pem │ │ ├── site2-cert.pem │ │ ├── site2-key.pem │ │ ├── site3-cert.pem │ │ ├── site3-key.pem │ │ ├── site4-cert.pem │ │ └── site4-key.pem ├── dir_sum.sh ├── install │ ├── drop │ └── drop_caches.sh ├── reporting │ ├── compare.sh │ ├── gen_report.escript │ ├── report-2i.sh │ ├── report-crdt-team-map.sh │ ├── report.sh │ ├── riak-digest.escript │ ├── summarize-crdt-team-map.gpl │ ├── summarize.gpl │ ├── summarize1.gpl │ └── summarize2i.gpl └── riak_shell │ └── riak_shell_regression1.log ├── rebar ├── rebar.config ├── rebar.config.lock ├── rebar.config.script ├── report-2i.sh ├── report.sh ├── results └── .gitignore ├── riak ├── run-perf-test.sh ├── search-corpus └── spam.0.1.tar.gz ├── src ├── giddyup.erl ├── make_certs.erl ├── observer.erl ├── rebar_riak_test_plugin.erl ├── riak_test.app.src ├── riak_test.erl ├── riak_test_escript.erl ├── riak_test_group_leader.erl ├── riak_test_lager_backend.erl ├── riak_test_runner.erl ├── rt.erl ├── rt_bench.erl ├── rt_client.erl ├── rt_config.erl ├── rt_cover.erl ├── rt_intercept.erl ├── rt_intercept_pt.erl ├── rt_local.erl ├── rt_pipe.erl ├── rt_pipe_sink_fsm.erl ├── rt_redbug.erl ├── rt_slave.erl ├── rt_util.erl ├── rt_worker_sup.erl ├── rtdev.erl ├── rtperf.erl ├── rtssh.erl └── smoke_test_escript.erl ├── tests ├── always_fail_test.erl ├── always_pass_test.erl ├── basic_command_line.erl ├── bucket_props_roundtrip.erl ├── bucket_props_validation.erl ├── bucket_types.erl ├── cause_bdp.erl ├── cluster_meta_basic.erl ├── cluster_meta_proxy_server.erl ├── cluster_meta_rmr.erl ├── coverage.erl ├── cuttlefish_configuration.erl ├── ensemble_basic.erl ├── ensemble_basic2.erl ├── ensemble_basic3.erl ├── ensemble_basic4.erl ├── ensemble_byzantine.erl ├── ensemble_interleave.erl ├── ensemble_remove_node.erl ├── ensemble_remove_node2.erl ├── ensemble_ring_changes.erl ├── ensemble_start_without_aae.erl ├── ensemble_sync.erl ├── ensemble_util.erl ├── ensemble_vnode_crash.erl ├── gh_riak_core_154.erl ├── gh_riak_core_155.erl ├── gh_riak_core_176.erl ├── gh_riak_kv_765.erl ├── hooks.erl ├── http_bucket_types.erl ├── http_security.erl ├── jmx_verify.erl ├── job_enable_common.erl ├── job_enable_common.hrl ├── kv679_dataloss.erl ├── kv679_dataloss_fb.erl ├── kv679_dataloss_fb2.erl ├── kv679_tombstone.erl ├── kv679_tombstone2.erl ├── kv679_uid.erl ├── kv_vnode_requests_upgrade_downgrade.erl ├── loaded_upgrade.erl ├── loaded_upgrade_worker_sup.erl ├── mapred_basic_compat.erl ├── mapred_buffer_prereduce.erl ├── mapred_dead_pipe.erl ├── mapred_http_errors.erl ├── mapred_javascript.erl ├── mapred_notfound_failover.erl ├── mapred_search_switch.erl ├── mapred_verify_rt.erl ├── overload.erl ├── overload_proxy.erl ├── partition_repair.erl ├── pb_cipher_suites.erl ├── pb_security.erl ├── pipe_verify_basics.erl ├── pipe_verify_examples.erl ├── pipe_verify_exceptions.erl ├── pipe_verify_handoff.erl ├── pipe_verify_handoff_blocking.erl ├── pipe_verify_restart_input_forwarding.erl ├── pipe_verify_sink_types.erl ├── post_generate_key.erl ├── pr_pw.erl ├── proxy_overload_recovery.erl ├── repl_aae_fullsync.erl ├── repl_aae_fullsync_bench.erl ├── repl_aae_fullsync_bt.erl ├── repl_aae_fullsync_custom_n.erl ├── repl_aae_fullsync_util.erl ├── repl_bucket_types.erl ├── repl_cancel_fullsync.erl ├── repl_consistent_object_filter.erl ├── repl_fs_bench.erl ├── repl_fs_stat_caching.erl ├── repl_handoff_deadlock_aae.erl ├── repl_handoff_deadlock_common.erl ├── repl_handoff_deadlock_keylist.erl ├── repl_location_failures.erl ├── repl_process_leak.erl ├── repl_rt_cascading_rtq.erl ├── repl_rt_heartbeat.erl ├── repl_rt_overload.erl ├── repl_rt_pending.erl ├── repl_util.erl ├── replication.erl ├── replication2.erl ├── replication2_connections.erl ├── replication2_console_tests.erl ├── replication2_dirty.erl ├── replication2_fsschedule.erl ├── replication2_pg.erl ├── replication2_rt_sink_connection.erl ├── replication2_ssl.erl ├── replication2_upgrade.erl ├── replication_object_reformat.erl ├── replication_ssl.erl ├── replication_stats.erl ├── replication_upgrade.erl ├── riak667_mixed.erl ├── riak667_safe.erl ├── riak727.erl ├── riak_admin_console_tests.erl ├── riak_control.erl ├── riak_control_authentication.erl ├── riak_rex.erl ├── riak_shell_test_connecting.erl ├── riak_shell_test_connecting_error.erl ├── riak_shell_test_disconnecting.erl ├── riak_shell_test_reconnecting.erl ├── riak_shell_test_util.erl ├── riaknostic_rt.erl ├── rolling_capabilities.erl ├── rpc_output.erl ├── rt_basic_test.erl ├── rt_cascading.erl ├── rt_cascading_big_circle.erl ├── rt_cascading_circle.erl ├── rt_cascading_circle_and_spurs.erl ├── rt_cascading_diamond.erl ├── rt_cascading_ensure_ack.erl ├── rt_cascading_mixed_clusters.erl ├── rt_cascading_new_to_old.erl ├── rt_cascading_pyramid.erl ├── rt_cascading_simple.erl ├── rt_cascading_unacked_and_queue.erl ├── secondary_index_tests.erl ├── sibling_explosion.erl ├── sweeper_bench.erl ├── sweeper_long_test.erl ├── test_cluster.erl ├── test_hll.erl ├── ts.README ├── ts_cluster_activate_table_pass_1.erl ├── ts_cluster_aggregation.erl ├── ts_cluster_capabilities_SUITE.erl ├── ts_cluster_comprehensive.erl ├── ts_cluster_coverage.erl ├── ts_cluster_create_table_pass_1.erl ├── ts_cluster_create_table_via_sql_SUITE.erl ├── ts_cluster_group_by_SUITE.erl ├── ts_cluster_handoff_SUITE.erl ├── ts_cluster_keys_SUITE.erl ├── ts_cluster_list_irreg_keys_SUITE.erl ├── ts_cluster_overload_reported.erl ├── ts_cluster_put_pass_1.erl ├── ts_cluster_quantum_boundaries_SUITE.erl ├── ts_cluster_random_query_pass_eqc.erl ├── ts_cluster_replication.erl ├── ts_cluster_riak_shell_basic_sql.erl ├── ts_cluster_riak_shell_regression_log.erl ├── ts_cluster_select_desc_SUITE.erl ├── ts_cluster_select_pass_1.erl ├── ts_cluster_select_pass_2.erl ├── ts_cluster_select_pass_3_sorted_on_key.erl ├── ts_cluster_stream_list_keys_SUITE.erl ├── ts_cluster_table_active_state.erl ├── ts_cluster_unicode.erl ├── ts_cluster_updowngrade_group_by_SUITE.erl ├── ts_cluster_updowngrade_order_by_SUITE.erl ├── ts_cluster_updowngrade_select_aggregation_SUITE.erl ├── ts_data.erl ├── ts_degraded_activate_table_fail_1.erl ├── ts_degraded_aggregation.erl ├── ts_degraded_select_pass_1.erl ├── ts_degraded_select_pass_2.erl ├── ts_ops.erl ├── ts_qbuf_util.erl ├── ts_qbuf_util.hrl ├── ts_setup.erl ├── ts_simple_activate_table_pass_1.erl ├── ts_simple_activate_table_pass_2.erl ├── ts_simple_aggregation.erl ├── ts_simple_aggregation_fail.erl ├── ts_simple_aggregation_math.erl ├── ts_simple_api.erl ├── ts_simple_batch.erl ├── ts_simple_blob.erl ├── ts_simple_create_table_already_created.erl ├── ts_simple_create_table_dup_primary_key.erl ├── ts_simple_create_table_no_primary_key.erl ├── ts_simple_create_table_not_null_pk_fields.erl ├── ts_simple_create_table_pass_1.erl ├── ts_simple_create_table_split_key.erl ├── ts_simple_describe_table.erl ├── ts_simple_div_by_zero.erl ├── ts_simple_explain_query.erl ├── ts_simple_get.erl ├── ts_simple_get_not_found.erl ├── ts_simple_http_api_SUITE.erl ├── ts_simple_http_security_SUITE.erl ├── ts_simple_insert.erl ├── ts_simple_insert_incorrect_columns.erl ├── ts_simple_insert_iso8601.erl ├── ts_simple_invdist_funs_SUITE.erl ├── ts_simple_latin1_create_table_not_allowed.erl ├── ts_simple_object_size_limits.erl ├── ts_simple_pb_security_SUITE.erl ├── ts_simple_put.erl ├── ts_simple_put_all_datatypes.erl ├── ts_simple_put_all_null_datatypes.erl ├── ts_simple_put_bad_date.erl ├── ts_simple_put_invalid_data.erl ├── ts_simple_put_non_existent_bucket.erl ├── ts_simple_query_buffers_SUITE.erl ├── ts_simple_recompile_ddl.erl ├── ts_simple_select.erl ├── ts_simple_select_compare_two_fields_not_allowed.erl ├── ts_simple_select_double_in_key.erl ├── ts_simple_select_incompatible_type_float_not_allowed.erl ├── ts_simple_select_incompatible_type_integer_not_allowed.erl ├── ts_simple_select_is_null.erl ├── ts_simple_select_iso8601.erl ├── ts_simple_select_missing_field_in_pk_not_allowed.erl ├── ts_simple_select_nogap.erl ├── ts_simple_select_not_found.erl ├── ts_simple_select_table_not_existing.erl ├── ts_simple_select_unexpected_token_not_allowed.erl ├── ts_simple_select_where_has_no_lower_bounds_not_allowed.erl ├── ts_simple_select_where_has_no_upper_bounds_not_allowed.erl ├── ts_simple_show_create_table.erl ├── ts_simple_show_tables.erl ├── ts_simple_single_key_ops.erl ├── ts_simple_unicode_create_table_not_allowed.erl ├── ts_updown_util.erl ├── ts_updown_util.hrl ├── ts_updowngrade_test.part ├── verify_2i_aae.erl ├── verify_2i_eqc.erl ├── verify_2i_limit.erl ├── verify_2i_mixed_cluster.erl ├── verify_2i_returnbody.erl ├── verify_2i_returnterms.erl ├── verify_2i_stream.erl ├── verify_2i_timeout.erl ├── verify_aae.erl ├── verify_api_timeouts.erl ├── verify_asis_put.erl ├── verify_backup_restore.erl ├── verify_basic_upgrade.erl ├── verify_bdp_event_handler.erl ├── verify_bitcask_tombstone2_upgrade.erl ├── verify_build_cluster.erl ├── verify_build_cluster_caps_race.erl ├── verify_busy_dist_port.erl ├── verify_capabilities.erl ├── verify_claimant.erl ├── verify_cluster_converge.erl ├── verify_commit_hooks.erl ├── verify_conditional_postcommit.erl ├── verify_corruption_filtering.erl ├── verify_counter_capability.erl ├── verify_counter_converge.erl ├── verify_counter_repl.erl ├── verify_crdt_capability.erl ├── verify_cs_bucket.erl ├── verify_down.erl ├── verify_dt_context.erl ├── verify_dt_converge.erl ├── verify_dt_data_upgrade.erl ├── verify_dt_upgrade.erl ├── verify_dvv_repl.erl ├── verify_dynamic_ring.erl ├── verify_handoff.erl ├── verify_handoff_mixed.erl ├── verify_handoff_write_once.erl ├── verify_job_enable_ac.erl ├── verify_job_enable_rc.erl ├── verify_job_switch_defaults.erl ├── verify_kv_health_check.erl ├── verify_leave.erl ├── verify_link_walk_urls.erl ├── verify_listkeys.erl ├── verify_listkeys_eqcfsm.erl ├── verify_membackend.erl ├── verify_mr_prereduce_node_down.erl ├── verify_no_datatype_siblings.erl ├── verify_no_writes_on_read.erl ├── verify_object_limits.erl ├── verify_object_ttl.erl ├── verify_removed_capability.erl ├── verify_reset_bucket_props.erl ├── verify_riak_lager.erl ├── verify_riak_object_reformat.erl ├── verify_riak_stats.erl ├── verify_search.erl ├── verify_snmp.erl ├── verify_snmp_repl.erl ├── verify_staged_clustering.erl ├── verify_stats_removal.erl ├── verify_sweep_reaper.erl ├── verify_tick_change.erl ├── verify_vclock.erl ├── verify_vclock_encoding_upgrade.erl ├── verify_write_once.erl └── vnode_util.erl ├── tools.mk └── utils ├── riak_test.bash ├── riak_test.zsh └── rt-cluster /.edts: -------------------------------------------------------------------------------- 1 | :node-sname "rt" 2 | :lib-dirs "deps" 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | deps 2 | ebin 3 | log 4 | ct_logs/ 5 | riak_test 6 | smoke_test 7 | .eunit 8 | .DS_Store 9 | out 10 | search-corpus/spam.0 11 | erl_crash.dump 12 | *~ 13 | #*# 14 | doc/ 15 | !doc/overview.edoc 16 | *.jar 17 | coverage 18 | tags 19 | riak-* 20 | *.png 21 | .rebar/ 22 | .local_dialyzer_plt 23 | dialyzer_unhandled_warnings 24 | dialyzer_warnings 25 | .idea 26 | riak_test.iml 27 | variables-riak_test@127.0.0.1 28 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | - to get the reporting stuff working, you'll need to have gnuplot 2 | installed on your local machine, at at least version 4.6.3. If you 3 | need to install from source, you'll need at least these two deps: 4 | 5 | - sudo apt-get install libgd2-xpm-dev libreadline6-dev 6 | 7 | - symlink the stuff in perf/reporting to ~/bin/, assuming that is on 8 | your path. 9 | 10 | - drop_caches.sh needs to be visible on the remote machine. the 11 | initial version of these scripts assumes that everyone is on the 12 | same filer. This isn't going to be true everywhere. drop is meant 13 | to contain your username, and be in /etc/sudoers.d/. 14 | 15 | - ssh needs to be setup so that the user doesn't need to provide 16 | credentials. The current way is that I just generated a bos-local 17 | key and use that. This isn't a terrible idea, but should at least 18 | be automated on setup. 19 | 20 | 21 | - ~/.riak_test.config should have a harness entry like this: 22 | 23 | {rtperf, 24 | [ 25 | {rt_deps, ["/usr/local/basho/evan/riak2.0/deps"]}, 26 | %% should be really long to allow full bitcasks to 27 | %% come up 28 | {rt_max_wait_time, 600000000000000}, 29 | {basho_bench, "/usr/local/basho/evan/basho_bench/"}, 30 | {basho_bench_statedir, "/tmp/bb_seqstate/"}, 31 | {rt_retry_delay, 500}, 32 | {rt_harness, rtperf}, 33 | {load_intercepts, false}, 34 | {perf_builds, "/usr/local/basho/evan/"}, 35 | {perf_loadgens, ["localhost", "r2s24"]}, 36 | {rtdev_path, []} 37 | 38 | ]}. 39 | 40 | at least right now. this will problably change as the configuration 41 | stuff gets sorted out. some of these may not be necessary. 42 | rt_max_wait_time is (could maybe be set to infinity? maybe by the 43 | harness?), perf_* and basho_bench* are also critical. rt_deps 44 | should maybe be dynamic? 45 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | HEAD_REVISION ?= $(shell git describe --tags --exact-match HEAD 2>/dev/null) 2 | 3 | .PHONY: deps 4 | 5 | APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \ 6 | xmerl webtool eunit syntax_tools compiler hipe mnesia public_key \ 7 | observer wx gs 8 | PLT = $(HOME)/.riak-test_dialyzer_plt 9 | 10 | all: deps compile 11 | ./rebar skip_deps=true escriptize 12 | SMOKE_TEST=1 ./rebar skip_deps=true escriptize 13 | 14 | deps: 15 | $(if $(HEAD_REVISION),$(warning "Warning: you have checked out a tag ($(HEAD_REVISION)) and should use the locked-deps target")) 16 | ./rebar get-deps 17 | 18 | docsclean: 19 | @rm -rf doc/*.png doc/*.html doc/*.css edoc-info 20 | 21 | compile: deps 22 | ./rebar compile 23 | 24 | clean: 25 | @./rebar clean 26 | 27 | distclean: clean 28 | @rm -rf riak_test deps 29 | 30 | quickbuild: 31 | ./rebar skip_deps=true compile 32 | ./rebar escriptize 33 | 34 | ## 35 | ## Lock Targets 36 | ## 37 | ## see https://github.com/seth/rebar_lock_deps_plugin 38 | lock: deps compile 39 | ./rebar lock-deps 40 | 41 | locked-all: locked-deps compile 42 | 43 | locked-deps: 44 | @echo "Using rebar.config.lock file to fetch dependencies" 45 | ./rebar -C rebar.config.lock get-deps 46 | 47 | ################## 48 | # Dialyzer targets 49 | ################## 50 | 51 | # Legacy target left for compatibility with any existing automation 52 | # scripts ... 53 | clean_plt: 54 | cleanplt 55 | 56 | include tools.mk 57 | -------------------------------------------------------------------------------- /basho_builds.yml: -------------------------------------------------------------------------------- 1 | docker_rt_riak_test_config: 2 | - version: current 3 | product_version: current 4 | product: "riak{% if ee == 'true' %}_ee{% endif %}" 5 | - version: previous 6 | product_version: 2.2.0 7 | product: "riak{% if ee == 'true' %}_ee{% endif %}" 8 | - version: legacy 9 | product_version: 2.0.9 10 | product: "riak{% if ee == 'true' %}_ee{% endif %}" 11 | - version: 2.0.2 12 | product_version: 2.0.2 13 | product: "riak{% if ee == 'true' %}_ee{% endif %}" 14 | - version: 2.0.4 15 | product_version: 2.0.4 16 | product: "riak{% if ee == 'true' %}_ee{% endif %}" 17 | - version: 2.0.5 18 | product_version: 2.0.5 19 | product: "riak{% if ee == 'true' %}_ee{% endif %}" 20 | -------------------------------------------------------------------------------- /bcrunner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test_name=$1 4 | bin_size=$2 5 | version=$3 6 | perf_test=$4 7 | backend=$5 8 | cuttle=$5 9 | 10 | if [ -z $version -o -z $test_name -o -z $bin_size ]; then 11 | echo "out" 12 | exit 1 13 | fi 14 | 15 | if [ -z $perf_test ]; then 16 | perf_test="get_put" 17 | fi 18 | 19 | if [ -z $backend ]; then 20 | backend="riak_kv_bitcask_backend" 21 | fi 22 | 23 | if [ ! -z $cuttle ]; then 24 | cuttle="--cuttle false" 25 | else 26 | cuttle="" 27 | fi 28 | 29 | ./riak_test -c rtperf2 -t $perf_test -b $backend -- --restart true --prepop true \ 30 | --run-time 120 --target-pct 120 --ram-size 48 \ 31 | --bin-size $bin_size --name $test_name --bin-type exponential \ 32 | --version $version $cuttle 33 | 34 | ./riak_test -c rtperf2 -t $perf_test -b $backend -- --restart true --prepop true \ 35 | --run-time 120 --target-pct 70 --ram-size 48 \ 36 | --bin-size $bin_size --name $test_name --bin-type exponential \ 37 | --version $version $cuttle 38 | 39 | ./riak_test -c rtperf2 -t $perf_test -b $backend -- --restart true --prepop true \ 40 | --run-time 120 --target-pct 20 --ram-size 48 \ 41 | --bin-size $bin_size --name $test_name --bin-type exponential \ 42 | --version $version $cuttle 43 | 44 | -------------------------------------------------------------------------------- /bin/rtdev-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ORIGDIR=`pwd` 4 | pushd `dirname $0` > /dev/null 5 | SCRIPT_DIR=`pwd` 6 | popd > /dev/null 7 | : ${CURRENT_OTP:="$HOME/erlang-R16B02"} 8 | : ${RT_CURRENT_TAG:=""} 9 | 10 | 11 | if [ -n "$DEBUG_RTDEV" ]; then 12 | echo "= Configuration =================================================" 13 | echo "Build dir: $ORIGDIR" 14 | echo "rtdev-* scripts: $SCRIPT_DIR" 15 | echo "Erlang: $CURRENT_OTP" 16 | echo 17 | fi 18 | 19 | echo "================== riak_test Omnibus Installer ==================" 20 | echo 21 | echo "This is an omnibus script that builds all the necessary versions " 22 | echo "of Erlang and Riak (including the latest from Github) for running" 23 | echo "riak_test and installs them into $HOME/rt/riak. " 24 | echo 25 | echo -n "Are you sure you want to continue? [Y|n] " 26 | read continue 27 | if [[ $continue == n || $continue == N ]]; then 28 | echo 29 | echo "Aborting install!" 30 | exit 1 31 | fi 32 | 33 | echo 34 | echo "= Building Riak Releases ========================================" 35 | echo 36 | 37 | source $SCRIPT_DIR/rtdev-build-releases.sh 38 | 39 | echo "= Installing Riak Releases ======================================" 40 | echo 41 | source $SCRIPT_DIR/rtdev-setup-releases.sh 42 | 43 | echo 44 | echo "= Building and Installing Riak from Git =========================" 45 | echo 46 | 47 | cd $ORIGDIR 48 | build "current" $CURRENT_OTP $RT_CURRENT_TAG 49 | echo 50 | cd current 51 | source $SCRIPT_DIR/rtdev-current.sh 52 | 53 | cd $ORIGDIR 54 | echo 55 | echo "= Build complete! ===============================================" 56 | -------------------------------------------------------------------------------- /bin/rtdev-current.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPT=$0 3 | DIR=${SCRIPT%/*} 4 | $DIR/rtdev-install.sh current 5 | -------------------------------------------------------------------------------- /bin/rtdev-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # bail out if things go south 4 | set -e 5 | 6 | : ${RT_DEST_DIR:="$HOME/rt/riak"} 7 | if [[ $# < 1 ]]; then 8 | echo "Missing release directory as argument, e.g. riak_ee-2.1.2" 9 | exit 1 10 | fi 11 | RELEASE=$1 12 | 13 | echo "Making $(pwd) the $RELEASE release:" 14 | cwd=$(pwd) 15 | 16 | echo -n " - Determining version: " 17 | if [[ -f $cwd/dependency_manifest.git ]] 18 | then 19 | VERSION="$(awk '/^-/ { print $NF }' $cwd/dependency_manifest.git)" 20 | else 21 | VERSION="$(git describe --tags)-$(git branch | awk '/\*/ {print $2}')" 22 | fi 23 | 24 | if [[ "$RELEASE" == "current" && ! -z "$RT_CURRENT_TAG" ]]; then 25 | VERSION=$RT_CURRENT_TAG 26 | fi 27 | 28 | echo $VERSION 29 | cd $RT_DEST_DIR 30 | 31 | echo " - Resetting existing $RT_DEST_DIR" 32 | export GIT_WORK_TREE="$RT_DEST_DIR" 33 | git reset HEAD --hard > /dev/null 34 | git clean -fd > /dev/null 35 | 36 | echo " - Removing and recreating $RT_DEST_DIR/$RELEASE" 37 | rm -rf $RT_DEST_DIR/$RELEASE 38 | mkdir $RT_DEST_DIR/$RELEASE 39 | cd $cwd 40 | 41 | echo " - Copying devrel to $RT_DEST_DIR/$RELEASE" 42 | cp -p -P -R dev $RT_DEST_DIR/$RELEASE 43 | echo " - Writing $RT_DEST_DIR/$RELEASE/VERSION" 44 | echo -n $VERSION > $RT_DEST_DIR/$RELEASE/VERSION 45 | cd $RT_DEST_DIR 46 | 47 | echo " - Reinitializing git state" 48 | 49 | # Set the path to the root of the working tree. This prevents git to 50 | # ascend the directory tree (and possibly mess with other 51 | # repositories). That is, changes we are going to make with `git 52 | # config` will only affect the rt repo we have just created. 53 | GIT_WORK_TREE="$RT_DEST_DIR" 54 | git config user.name "Riak Test" 55 | git config user.email "dev@basho.com" 56 | git config core.autocrlf input 57 | git config core.safecrlf false 58 | git config core.filemode true 59 | 60 | 61 | git add --all --force . 62 | git commit -a -m "riak_test init" --amend > /dev/null 63 | 64 | echo " - Successfully re-initialized git state in $RT_DEST_DIR" 65 | -------------------------------------------------------------------------------- /bin/rtdev-setup-releases.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # bail out if things go south 4 | set -e 5 | 6 | # Creates a mixed-version directory structure for running riak_test 7 | # using rtdev-mixed.config settings. Should be run inside a directory 8 | # that contains devrels for prior Riak releases. Easy way to create this 9 | # is to use the rtdev-build-releases.sh script 10 | 11 | : ${RT_DEST_DIR:="$HOME/rt/riak"} 12 | 13 | echo "Setting up releases from $(pwd):" 14 | echo " - Creating $RT_DEST_DIR" 15 | 16 | rm -rf $RT_DEST_DIR 17 | mkdir -p $RT_DEST_DIR 18 | 19 | count=$(ls */dev 2> /dev/null | wc -l) 20 | if [ "$count" -ne "0" ] 21 | then 22 | for rel in */dev; do 23 | vsn=$(dirname "$rel") 24 | echo " - Initializing $RT_DEST_DIR/$vsn" 25 | mkdir -p "$RT_DEST_DIR/$vsn" 26 | cp -p -P -R "$rel" "$RT_DEST_DIR/$vsn" 27 | # Route out the product and version from Git 28 | (cd "$rel"; VERSION="$(git describe --tags)"; echo -n $VERSION > $RT_DEST_DIR/$vsn/VERSION) 29 | done 30 | else 31 | # This is useful when only testing with 'current' 32 | # The repo still needs to be initialized for current 33 | # and we don't want to bomb out if */dev doesn't exist 34 | touch $RT_DEST_DIR/.current_init 35 | echo "No devdirs found. Not copying any releases." 36 | fi 37 | 38 | cd "$RT_DEST_DIR" 39 | git init 40 | 41 | # Set the path to the root of the working tree. This prevents git to 42 | # ascend the directory tree (and possibly mess with other 43 | # repositories). That is, changes we are going to make with `git 44 | # config` will only affect the rt repo we have just created. 45 | GIT_WORK_TREE="$RT_DEST_DIR" 46 | git config user.name "Riak Test" 47 | git config user.email "dev@basho.com" 48 | git config core.autocrlf input 49 | git config core.safecrlf false 50 | git config core.filemode true 51 | 52 | ## this prevents priv/*.so files from being deleted by git clean -fd 53 | ## (the latter is executed in rtdev-current.sh): 54 | echo "priv/" >.gitignore 55 | 56 | git add --all --force . 57 | git commit -a -m "riak_test init" > /dev/null 58 | echo " - Successfully completed initial git commit of $RT_DEST_DIR" 59 | -------------------------------------------------------------------------------- /compare.sh: -------------------------------------------------------------------------------- 1 | priv/reporting/compare.sh -------------------------------------------------------------------------------- /examples/riak_test.config.perf: -------------------------------------------------------------------------------- 1 | {rtperf, [ 2 | {rt_deps, ["/mnt/riak_ee/deps"]}, 3 | %% should be really long to allow full bitcasks to 4 | %% come up 5 | {rt_max_wait_time, 600000000000000}, 6 | {basho_bench, "/mnt/basho_bench"}, 7 | {basho_bench_escript, "/usr/local/erlang-r16b02/bin/escript"}, 8 | {basho_bench_statedir, "/tmp/bb_seqstate/"}, 9 | {rt_retry_delay, 500}, 10 | {rt_harness, rtperf}, 11 | {load_intercepts, false}, 12 | {perf_builds, "/mnt/perf_builds"}, 13 | {perf_loadgens, ["bench101.aws"]}, 14 | {rtdev_path, [{root, "/mnt/rt/riak_ee"}, 15 | {current, "/mnt/rt/riak_ee/riak-ee-2.0.0rc1"}, 16 | {previous, "/mnt/rt/riak_ee/riak-ee-1.4.8"}, 17 | {legacy, "/mnt/rt/riak_ee/riak-ee-1.3.4"}]} 18 | ]}. 19 | -------------------------------------------------------------------------------- /include/rt.hrl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2013 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -record(rt_webhook, { 22 | name :: string(), 23 | url :: string(), 24 | headers=[] :: [{atom(), string()}] 25 | }). 26 | -------------------------------------------------------------------------------- /include/rt_pipe.hrl: -------------------------------------------------------------------------------- 1 | %% This is a copy of riak_pipe/include/riak_pipe.hrl, so that we don't 2 | %% have to pull riak_pipe and its dependencies in as dependencies of 3 | %% riak_test. 4 | 5 | -record(fitting, 6 | { 7 | pid :: pid(), 8 | ref :: reference(), 9 | chashfun :: riak_pipe_vnode:chashfun(), 10 | nval :: riak_pipe_vnode:nval() 11 | }). 12 | 13 | -record(fitting_details, 14 | { 15 | fitting :: #fitting{}, 16 | name :: term(), 17 | module :: atom(), 18 | arg :: term(), 19 | output :: #fitting{}, 20 | options :: riak_pipe:exec_opts(), 21 | q_limit :: pos_integer() 22 | }). 23 | 24 | -record(fitting_spec, 25 | { 26 | name :: term(), 27 | module :: atom(), 28 | arg :: term(), 29 | chashfun = {chash, key_of} :: riak_pipe_vnode:chashfun(), 30 | nval = 1 :: riak_pipe_vnode:nval(), 31 | q_limit = 64 :: pos_integer() 32 | }). 33 | 34 | -record(pipe, 35 | { 36 | builder :: pid(), 37 | fittings :: [{Name::term(), #fitting{}}], 38 | sink :: #fitting{} 39 | }). 40 | 41 | -record(pipe_result, 42 | { 43 | ref, 44 | from, 45 | result 46 | }). 47 | 48 | -record(pipe_eoi, 49 | { 50 | ref 51 | }). 52 | 53 | -record(pipe_log, 54 | { 55 | ref, 56 | from, 57 | msg 58 | }). 59 | -------------------------------------------------------------------------------- /include/yokozuna_rt.hrl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -type index_name() :: binary(). 21 | -type schema_name() :: string(). 22 | -type raw_schema() :: binary(). 23 | -type bucket() :: bucket() | {bucket(), bucket()}. 24 | 25 | -define(IBROWSE_TIMEOUT, 60000). 26 | -------------------------------------------------------------------------------- /intercepts/hashtree_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(hashtree_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | sleep_update_perform(State) -> 26 | ?I_INFO("sleeping update_perform 60s\n"), 27 | timer:sleep(60000), 28 | hashtree_orig:update_perform_orig(State). 29 | -------------------------------------------------------------------------------- /intercepts/init_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(init_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | -define(M, init_orig). 25 | 26 | get_status() -> 27 | {starting, starting}. 28 | -------------------------------------------------------------------------------- /intercepts/intercept.hrl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -define(I_TAG(S), "INTERCEPT: " ++ S). 22 | -define(I_INFO(Msg), error_logger:info_msg(?I_TAG(Msg))). 23 | -define(I_INFO(Msg, Args), error_logger:info_msg(?I_TAG(Msg), Args)). 24 | -------------------------------------------------------------------------------- /intercepts/riak_core_broadcast_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_core_broadcast_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | global_send(Msg, Peers) when is_list(Peers) -> 26 | [global_send(Msg, P) || P <- Peers]; 27 | global_send(Msg, P) -> 28 | ?I_INFO("sending through proxy"), 29 | gen_server:cast({global, cluster_meta_proxy_server}, {node(), riak_core_broadcast, P, Msg}). 30 | -------------------------------------------------------------------------------- /intercepts/riak_core_connection_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_core_connection_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_core_connection_orig). 26 | 27 | %% @doc Return econnrefused for all connection attempts 28 | return_econnrefused(Addr,_ClientSpec) -> 29 | ?I_INFO("Returning econnrefused for all connections to: ~p",[Addr]), 30 | {error, econnrefused}. 31 | 32 | %% @doc Pass through for sync_connect function 33 | sync_connect(Addr, ClientSpec) -> 34 | ?I_INFO("Intercept is allowing connections"), 35 | ?M:sync_connect_orig(Addr, ClientSpec). 36 | -------------------------------------------------------------------------------- /intercepts/riak_core_handoff_sender_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_core_handoff_sender_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | -define(M, riak_core_handoff_sender_orig). 25 | 26 | delayed_visit_item_3(K, V, Acc) -> 27 | timer:sleep(100), 28 | ?M:visit_item_orig(K, V, Acc). 29 | -------------------------------------------------------------------------------- /intercepts/riak_core_ring_manager_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_core_ring_manager_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | noop_ring_trans(_Fun, _Args) -> 26 | ?I_INFO("overriding ring_trans as a noop"), 27 | not_changed. 28 | -------------------------------------------------------------------------------- /intercepts/riak_core_vnode_proxy_sup_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_core_vnode_proxy_sup_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | -define(M, riak_core_vnode_proxy_sup_orig). 25 | 26 | sleep_start_proxies(Mod=riak_kv_vnode) -> 27 | ?I_INFO("Delaying start of riak_kv_vnode proxies for 3s\n"), 28 | timer:sleep(3000), 29 | ?M:start_proxies_orig(Mod); 30 | sleep_start_proxies(Mod) -> 31 | ?M:start_proxies_orig(Mod). 32 | 33 | -------------------------------------------------------------------------------- /intercepts/riak_ensemble_peer_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_ensemble_peer_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_ensemble_peer_orig). 26 | 27 | -define(INTERCEPT_TAB, intercept_leader_tick_counts). 28 | 29 | count_leader_ticks(State) -> 30 | Result = ?M:leader_tick_orig(State), 31 | case ets:lookup(?INTERCEPT_TAB, self()) of 32 | [] -> 33 | ets:insert(?INTERCEPT_TAB, {self(), 1}); 34 | _ -> 35 | ets:update_counter(?INTERCEPT_TAB, self(), 1) 36 | end, 37 | Result. 38 | -------------------------------------------------------------------------------- /intercepts/riak_kv_bitcask_backend_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_bitcask_backend_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_kv_bitcask_backend_orig). 26 | 27 | corrupting_put(Bucket, Key, IndexSpecs, Val0, ModState) -> 28 | Val = 29 | case random:uniform(20) of 30 | 10 -> 31 | corrupt_binary(Val0); 32 | _ -> Val0 33 | end, 34 | ?M:put_orig(Bucket, Key, IndexSpecs, Val, ModState). 35 | 36 | corrupting_get(Bucket, Key, ModState) -> 37 | case ?M:get_orig(Bucket, Key, ModState) of 38 | {ok, BinVal0, UpdModState} -> 39 | BinVal = 40 | case random:uniform(20) of 41 | 10 -> 42 | corrupt_binary(BinVal0); 43 | _ -> BinVal0 44 | end, 45 | {ok, BinVal, UpdModState}; 46 | Else -> Else 47 | end. 48 | 49 | corrupt_binary(O) -> 50 | crypto:rand_bytes(byte_size(O)). 51 | 52 | always_corrupt_get(Bucket, Key, ModState) -> 53 | case ?M:get_orig(Bucket, Key, ModState) of 54 | {ok, BinVal0, UpdModState} -> 55 | BinVal = corrupt_binary(BinVal0), 56 | {ok, BinVal, UpdModState}; 57 | Else -> Else 58 | end. 59 | -------------------------------------------------------------------------------- /intercepts/riak_kv_eleveldb_backend_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_eleveldb_backend_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_kv_eleveldb_backend_orig). 26 | 27 | corrupting_put(Bucket, Key, IndexSpecs, Val0, ModState) -> 28 | Val = 29 | case random:uniform(20) of 30 | 10 -> 31 | corrupt_binary(Val0); 32 | _ -> Val0 33 | end, 34 | ?M:put_orig(Bucket, Key, IndexSpecs, Val, ModState). 35 | 36 | corrupting_get(Bucket, Key, ModState) -> 37 | case ?M:get_orig(Bucket, Key, ModState) of 38 | {ok, BinVal0, UpdModState} -> 39 | BinVal = 40 | case random:uniform(20) of 41 | 10 -> 42 | corrupt_binary(BinVal0); 43 | _ -> BinVal0 44 | end, 45 | {ok, BinVal, UpdModState}; 46 | Else -> Else 47 | end. 48 | 49 | corrupt_binary(O) -> 50 | crypto:rand_bytes(byte_size(O)). 51 | 52 | batch_put(Context, Values, IndexSpecs, State) -> 53 | Tally = riak_core_metadata:get( 54 | {riak_test, backend_intercept}, 55 | self(), 56 | [{default, 0}]), 57 | riak_core_metadata:put( 58 | {riak_test, backend_intercept}, 59 | self(), 60 | Tally+1), 61 | ?M:batch_put_orig(Context, Values, IndexSpecs, State). 62 | -------------------------------------------------------------------------------- /intercepts/riak_kv_get_fsm_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_get_fsm_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | -define(M, riak_kv_get_fsm_orig). 25 | 26 | count_start_4(From, Bucket, Key, GetOptions) -> 27 | ?I_INFO("sending start/4 through proxy"), 28 | case ?M:start_orig(From, Bucket, Key, GetOptions) of 29 | {error, overload} -> 30 | ?I_INFO("riak_kv_get_fsm not started due to overload."); 31 | {ok, _} -> 32 | gen_server:cast({global, overload_proxy}, increment_count) 33 | end. 34 | 35 | %% @doc simulate slow puts by adding delay to the prepare state. 36 | slow_prepare(Atom, State) -> 37 | timer:sleep(1000), 38 | ?M:prepare_orig(Atom, State). 39 | -------------------------------------------------------------------------------- /intercepts/riak_kv_index_hashtree_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_index_hashtree_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_kv_index_hashtree_orig). 26 | 27 | %% @doc Perform a delayed compare, which delays the receipt of a 28 | %% message. 29 | delayed_compare(_IndexN, _Remote, _AccFun, _TreePid) -> 30 | timer:sleep(1000000), 31 | []. 32 | 33 | %% @doc When attempting to get the lock on a hashtree, return the 34 | %% not_built atom which means the tree has not been computed yet. 35 | not_built(_TreePid, _Type, _Version, _Pid) -> 36 | not_built. 37 | 38 | %% @doc When attempting to get the lock on a hashtree, return the 39 | %% already_locked atom which means the tree is locked by another 40 | %% process. 41 | already_locked(_TreePid, _Type, _Version, _Pid) -> 42 | already_locked. 43 | 44 | %% @doc When attempting to get the lock on a hashtree, return the 45 | %% bad_version atom which means the local tree does not match 46 | %% the requested version 47 | bad_version(_TreePid, _Type, _Version, _Pid) -> 48 | bad_version. -------------------------------------------------------------------------------- /intercepts/riak_kv_js_manager_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2014 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | % 19 | %% ------------------------------------------------------------------- 20 | -module(riak_kv_js_manager_intercepts). 21 | -compile(export_all). 22 | -include("intercept.hrl"). 23 | 24 | %% See tests/riak_admin_console_tests.erl for more info 25 | 26 | -define(M, riak_kv_js_manager_orig). 27 | 28 | 29 | -define(PASS, io:format("pass", [])). 30 | -define(FAIL, io:format("fail", [])). 31 | 32 | verify_console_reload(Val) -> 33 | io:format(user, "XXXX ~p~n", [Val]), 34 | case Val of 35 | ["foo","bar","baz"] -> ?PASS; 36 | _ -> ?FAIL 37 | end. 38 | 39 | -------------------------------------------------------------------------------- /intercepts/riak_kv_put_fsm_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_put_fsm_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_kv_put_fsm_orig). 26 | 27 | 28 | %% @doc simulate slow puts by adding delay to the prepare state. 29 | slow_prepare(Atom, State) -> 30 | timer:sleep(1000), 31 | ?M:prepare_orig(Atom, State). 32 | -------------------------------------------------------------------------------- /intercepts/riak_kv_qry_buffers_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016, 2017 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_qry_buffers_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_kv_qry_buffers_orig). 26 | 27 | %% @doc simulate memory shortage to force inmem->ldb transition 28 | can_afford_inmem_random(_) -> 29 | random:uniform(10) > 5. 30 | 31 | can_afford_inmem_yes(_) -> 32 | true. 33 | 34 | can_afford_inmem_no(_) -> 35 | false. 36 | -------------------------------------------------------------------------------- /intercepts/riak_kv_ts_newtype_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. All Rights Reserved. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(riak_kv_ts_newtype_intercepts). 21 | -compile(export_all). 22 | -include("intercept.hrl"). 23 | 24 | -define(M, riak_kv_ts_newtype_orig). 25 | 26 | delayed_new_type(BucketType) -> 27 | intercepted_new_type(BucketType, 10, "delayed"). 28 | 29 | really_delayed_new_type(BucketType) -> 30 | intercepted_new_type(BucketType, 100, "really_delayed"). 31 | 32 | intercepted_new_type(BucketType, Delay, DelayType) -> 33 | DelayTypeFormat = DelayType ++ "~n", 34 | io:format(DelayTypeFormat), 35 | ?I_INFO(DelayTypeFormat), 36 | timer:sleep(Delay), 37 | ?M:new_type_orig(BucketType). 38 | -------------------------------------------------------------------------------- /intercepts/riak_kv_worker_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_kv_worker_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | -define(M, riak_kv_worker_orig). 25 | 26 | % 27 | % Okay, this is an interesting intercept. The intention here is to insert some 28 | % code into the point where the vnode has completed its fold, but before it invokes the finish 29 | % command, which will inform the riak_core_vnode that handoff has completed for this node. 30 | % This is a magic time, when handoff is running, and the fold has completed. 31 | % In this case, we send a message to a process that is running in riak test 32 | % (see verify_handoff_write_once, for an example), which will do a write during this 33 | % magic time. We wait for said process to return us an ok. 34 | % 35 | % The objective is to force the vnode to trigger a handle_handoff_command, 36 | % thus exercising the runtime/forwarding handoff logic in the vnode. 37 | % 38 | handle_work_intercept({fold, FoldFun, FinishFun}, Sender, State) -> 39 | FinishWrapperFun = fun(X) -> 40 | catch global:send(rt_ho_w1c_proc, {write, self()}), 41 | receive 42 | ok -> ok 43 | end, 44 | FinishFun(X) 45 | end, 46 | ?M:handle_work_orig({fold, FoldFun, FinishWrapperFun}, Sender, State). -------------------------------------------------------------------------------- /intercepts/riak_object_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_object_intercepts). 22 | -export([skippable_index_specs/1, 23 | skippable_diff_index_specs/2]). 24 | -include("intercept.hrl"). 25 | 26 | skippable_index_specs(Obj) -> 27 | case app_helper:get_env(riak_kv, skip_index_specs, false) of 28 | false -> 29 | riak_object_orig:index_specs_orig(Obj); 30 | true -> 31 | [] 32 | end. 33 | 34 | skippable_diff_index_specs(Obj, OldObj) -> 35 | case app_helper:get_env(riak_kv, skip_index_specs, false) of 36 | false -> 37 | riak_object_orig:diff_index_specs_orig(Obj, OldObj); 38 | true -> 39 | [] 40 | end. 41 | -------------------------------------------------------------------------------- /intercepts/riak_pipe_vnode_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_pipe_vnode_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_pipe_vnode_orig). 26 | 27 | %%% Intercepts 28 | 29 | %% @doc Log every command received by the vnode during handoff, so a 30 | %% test can analyze them later. Sends the first element of the `Cmd' 31 | %% tuple (the command type) to the process registered as 32 | %% `riak_test_collector'. 33 | %% 34 | %% Tests using this intercept are expected to start the collector 35 | %% process themselves. 36 | log_handoff_command(Cmd, Sender, State) -> 37 | try 38 | riak_test_collector ! element(1, Cmd) 39 | catch error:badarg when not is_tuple(Cmd) -> 40 | ?I_INFO("Cmd was not a tuple"); 41 | error:badarg -> 42 | ?I_INFO("Collector process not registered") 43 | end, 44 | ?M:handle_handoff_command_orig(Cmd, Sender, State). 45 | 46 | -------------------------------------------------------------------------------- /intercepts/riak_repl2_fs_node_reserver_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_repl2_fs_node_reserver_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_repl2_fs_node_reserver_orig). 26 | 27 | %% @doc Provide an intercept which forces the node reserver to fail when 28 | %% attempting to reserve a node with a location_down message. 29 | down_reserve({reserve, _Partition}, _From, State) -> 30 | io:format("down_reserve~n"), 31 | ?I_INFO("down_reserve~n"), 32 | {reply, down, State}; 33 | down_reserve(Message, From, State) -> 34 | ?M:handle_call_orig(Message, From, State). 35 | -------------------------------------------------------------------------------- /intercepts/riak_repl2_fssource_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_repl2_fssource_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_repl2_fssource_orig). 26 | 27 | slow_handle_info(Msg, State) -> 28 | io:format("slow_handle_info~n"), 29 | ?I_INFO("slow_handle_info~n"), 30 | timer:sleep(10), 31 | ?M:handle_info_orig(Msg, State). 32 | 33 | really_slow_handle_info(Msg, State) -> 34 | io:format("really_slow_handle_info~n"), 35 | ?I_INFO("really_slow_handle_info~n"), 36 | timer:sleep(100), 37 | ?M:handle_info_orig(Msg, State). 38 | -------------------------------------------------------------------------------- /intercepts/riak_repl2_rtq_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | %% Intercepts functions for the riak_test in ../tests/repl_rt_heartbeat.erl 22 | -module(riak_repl2_rtq_intercepts). 23 | -compile(export_all). 24 | -include("intercept.hrl"). 25 | 26 | -define(M, riak_repl2_rtq_orig). 27 | 28 | %% @doc Drop the heartbeat messages from the rt source. 29 | slow_trim_q(State) -> 30 | %% ?I_INFO("slow_trim_q"), 31 | 32 | %% This hideousness is necessary in order to have this intercept sleep only 33 | %% on the first iteration. With hope, it causes the message queue of the 34 | %% RTQ to spike enough to initiate overload handling, then subsequently 35 | %% allows the queue to drain, overload to flip off, and the writes to complete. 36 | case get(hosed) of 37 | undefined -> 38 | put(hosed, true); 39 | true -> 40 | timer:sleep(5000), 41 | put(hosed, false); 42 | false -> 43 | put(hosed, false) 44 | end, 45 | 46 | ?M:trim_q_orig(State). 47 | -------------------------------------------------------------------------------- /intercepts/riak_repl2_rtsink_conn_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | %% Intercepts functions for the riak_test in ../tests/repl_rt_heartbeat.erl 22 | -module(riak_repl2_rtsink_conn_intercepts). 23 | -compile(export_all). 24 | -include("intercept.hrl"). 25 | 26 | %% @doc Forward the heartbeat messages from the rt source by 27 | %% calling the original function. 28 | forward_send_heartbeat_resp(Transport, Socket) -> 29 | %% ?I_INFO("forward_heartbeat"), 30 | riak_repl2_rtsource_helper_orig:send_heartbeat_orig(Transport, Socket). 31 | 32 | %% @doc Drop the heartbeat messages from the rt source. 33 | drop_send_heartbeat_resp(_Transport, _Socket) -> 34 | %% ?I_INFO("drop_heartbeat"), 35 | ok. 36 | -------------------------------------------------------------------------------- /intercepts/riak_repl2_rtsource_helper_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | %% Intercepts functions for the riak_test in ../tests/repl_rt_heartbeat.erl 22 | -module(riak_repl2_rtsource_helper_intercepts). 23 | -compile(export_all). 24 | -include("intercept.hrl"). 25 | 26 | %% @doc Forward the heartbeat messages from the rt source by 27 | %% calling the original function. 28 | forward_send_heartbeat(Pid) -> 29 | %% ?I_INFO("forward_heartbeat"), 30 | riak_repl2_rtsource_helper_orig:send_heartbeat_orig(Pid). 31 | 32 | %% @doc Drop the heartbeat messages from the rt source. 33 | drop_send_heartbeat(_Pid) -> 34 | %% ?I_INFO("drop_heartbeat"), 35 | ok. 36 | -------------------------------------------------------------------------------- /intercepts/riak_repl_aae_source_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_repl_aae_source_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_repl_aae_source_orig). 26 | 27 | %% @doc Introduce 10ms of latency in receiving message off of the 28 | %% socket. 29 | delayed_get_reply(State) -> 30 | io:format("delayed~n"), 31 | ?I_INFO("delayed~n"), 32 | timer:sleep(10), 33 | ?M:get_reply_orig(State). 34 | 35 | %% @doc Introduce 100ms of latency in receiving message off of the 36 | %% socket. 37 | really_delayed_get_reply(State) -> 38 | io:format("really delayed~n"), 39 | ?I_INFO("really delayed~n"), 40 | timer:sleep(100), 41 | ?M:get_reply_orig(State). 42 | -------------------------------------------------------------------------------- /intercepts/riak_repl_ring_handler_intercepts.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %%------------------------------------------------------------------- 20 | 21 | -module(riak_repl_ring_handler_intercepts). 22 | -compile(export_all). 23 | -include("intercept.hrl"). 24 | 25 | -define(M, riak_repl_ring_handler_orig). 26 | 27 | %% @doc Make all commands take abnormally long. 28 | slow_handle_event(Event, State) -> 29 | io:format("slow handle event triggered by intercept", []), 30 | ?I_INFO("slow handle event triggered by intercept"), 31 | timer:sleep(500), 32 | ?M:handle_event_orig(Event, State). 33 | -------------------------------------------------------------------------------- /perf/2iperf.erl: -------------------------------------------------------------------------------- 1 | -module('2iperf'). 2 | -compile(export_all). 3 | -include_lib("eunit/include/eunit.hrl"). 4 | 5 | -define(HARNESS, (rt_config:get(rt_harness))). 6 | 7 | confirm() -> 8 | lager:info("entering get_put:confirm()"), 9 | HostList = rt_config:get(rt_hostnames), 10 | Count = length(HostList), 11 | BinSize = rt_config:get(perf_bin_size), 12 | 13 | Config = rtperf:standard_config(Count), 14 | 15 | ok = rtperf:build_cluster(Config), 16 | 17 | SetSize = rtperf:target_size(rt_config:get(perf_target_pct), 18 | BinSize, 19 | rt_config:get(perf_ram_size), 20 | Count), 21 | LoadConfig = [], 22 | %% rt_bench:config( 23 | %% 50, 24 | %% rt_config:get(perf_duration), 25 | %% HostList, 26 | %% {int_to_bin_bigendian, {truncated_pareto_int, SetSize}}, 27 | %% rt_bench:valgen(rt_config:get(perf_bin_type), BinSize), 28 | %% %% 4:1 get/put 29 | %% [{get, 3}, {update, 1}] 30 | %% ), 31 | 32 | TwoIConfig = 33 | rt_bench:config( 34 | max, 35 | rt_config:get(perf_duration), 36 | HostList, 37 | {truncated_pareto_int, SetSize}, 38 | rt_bench:valgen(rt_config:get(perf_bin_type), BinSize), 39 | [{{query_pb, 100}, 5}, {{query_pb, 1000}, 1}, 40 | {{put_pb, 2}, 1}, {get_pb, 5}], 41 | <<"testbucket">>, '2i' 42 | ), 43 | 44 | ok = rtperf:maybe_prepop(HostList, BinSize, SetSize), 45 | 46 | ok = rtperf:run_test(HostList, TwoIConfig, LoadConfig), 47 | pass. 48 | -------------------------------------------------------------------------------- /perf/consistent_get_put.erl: -------------------------------------------------------------------------------- 1 | -module(consistent_get_put). 2 | -compile(export_all). 3 | -include_lib("eunit/include/eunit.hrl"). 4 | 5 | -define(HARNESS, (rt_config:get(rt_harness))). 6 | 7 | confirm() -> 8 | HostList = rt_config:get(rt_hostnames), 9 | Count = length(HostList), 10 | BinSize = rt_config:get(perf_bin_size), 11 | 12 | Config = rtperf:standard_config(Count), 13 | lager:info("Generated configuration is: ~p", [Config]), 14 | 15 | [Nodes] = rt:build_clusters([Count]), 16 | lager:info("Built cluster: ~p", [Nodes]), 17 | 18 | SetSize = rtperf:target_size(rt_config:get(perf_target_pct), 19 | BinSize, 20 | rt_config:get(perf_ram_size), 21 | Count), 22 | [Node | _] = Nodes, 23 | rt:create_and_activate_bucket_type(Node, 24 | <<"sc">>, 25 | [{consistent, true}]), 26 | 27 | TestConfig = 28 | rt_bench:config( 29 | max, 30 | rt_config:get(perf_duration), 31 | [{Host, 10017} || Host <- HostList], 32 | {int_to_bin_bigendian, {truncated_pareto_int, SetSize}}, 33 | rt_bench:valgen(rt_config:get(perf_bin_type), BinSize), 34 | %% 4:1 get/put 35 | [{get, 3}, {update, 1}], 36 | {<<"sc">>, <<"testbucket">>}, 37 | riakc_pb), 38 | 39 | ok = rtperf:maybe_prepop(Nodes, BinSize, SetSize), 40 | 41 | ok = rtperf:run_test(Nodes, TestConfig, []), 42 | pass. 43 | -------------------------------------------------------------------------------- /perf/crdt_team_map.erl: -------------------------------------------------------------------------------- 1 | -module(crdt_team_map). 2 | -compile(export_all). 3 | -include_lib("eunit/include/eunit.hrl"). 4 | 5 | -define(HARNESS, (rt_config:get(rt_harness))). 6 | 7 | confirm() -> 8 | HostList = rt_config:get(rt_hostnames), 9 | Count = length(HostList), 10 | BinSize = rt_config:get(perf_bin_size), 11 | 12 | Config = rtperf:standard_config(Count), 13 | lager:info("Generated configuration is: ~p", [Config]), 14 | 15 | [Nodes] = rt:build_clusters([Count]), 16 | lager:info("Built cluster: ~p", [Nodes]), 17 | 18 | SetSize = rtperf:target_size(rt_config:get(perf_target_pct), 19 | BinSize, 20 | rt_config:get(perf_ram_size), 21 | Count), 22 | [Node | _] = Nodes, 23 | rt:create_and_activate_bucket_type(Node, 24 | <<"maps">>, 25 | [{datatype, map}]), 26 | 27 | TestConfig = 28 | rt_bench:config( 29 | max, 30 | rt_config:get(perf_duration), 31 | [{Host, 10017} || Host <- HostList], 32 | {uniform_int, 100}, 33 | {uniform_int, 1000}, 34 | [{{game, completed}, 10}, 35 | {{team, player, addition}, 3}, 36 | {{team, player, removal}, 3}, 37 | {{team, read}, 100}, 38 | {{team, write}, 1}], 39 | {<<"maps">>, <<"testbucket">>}, 40 | riakc_pb), 41 | 42 | ok = rtperf:maybe_prepop(Nodes, BinSize, SetSize), 43 | 44 | ok = rtperf:run_test(Nodes, TestConfig, []), 45 | pass. 46 | -------------------------------------------------------------------------------- /perf/get_put.erl: -------------------------------------------------------------------------------- 1 | -module(get_put). 2 | -export([confirm/0]). 3 | -include_lib("eunit/include/eunit.hrl"). 4 | 5 | -define(HARNESS, (rt_config:get(rt_harness))). 6 | 7 | confirm() -> 8 | HostList = rt_config:get(rt_hostnames), 9 | Count = length(HostList), 10 | 11 | Config = rtperf:standard_config(Count), 12 | lager:info("Generated configuration is: ~p", [Config]), 13 | 14 | [Nodes] = rt:build_clusters([Count]), 15 | lager:info("Built cluster: ~p", [Nodes]), 16 | 17 | BinSize = rt_config:get(perf_bin_size), 18 | SetSize = rtperf:target_size(rt_config:get(perf_target_pct), 19 | BinSize, 20 | rt_config:get(perf_ram_size), 21 | Count), 22 | 23 | TestConfig = 24 | rt_bench:config( 25 | max, 26 | rt_config:get(perf_duration), 27 | [{Host, 10017} || Host <- HostList], 28 | {int_to_bin_bigendian, {truncated_pareto_int, SetSize}}, 29 | rt_bench:valgen(rt_config:get(perf_bin_type), BinSize), 30 | %% 4:1 get/put 31 | [{get, 3}, {update, 1}] 32 | ), 33 | 34 | ok = rtperf:maybe_prepop(Nodes, BinSize, SetSize), 35 | 36 | ok = rtperf:run_test(Nodes, TestConfig, []), 37 | pass. 38 | -------------------------------------------------------------------------------- /priv/certs/README: -------------------------------------------------------------------------------- 1 | 2 | 2 directories, 'cacert.org' and 'selfsigned'. Each contains several keys and, in the 'ca' folder, is the CA certificate(s) used to sign them. 3 | 4 | 'selfsigned' has 4 keys, 'site1' and 'site2' are signed by an intermediate CA which was signed by the root CA, 'site3' and 'site4' were signed directly by the root CA. 5 | 6 | The certificate common names are as follows: 7 | * site1.basho.com 8 | * site2.basho.com 9 | * site3.basho.com 10 | * site4.basho.com 11 | * ny.cataclysm-software.net 12 | * ca.catacylsm-software.net 13 | -------------------------------------------------------------------------------- /priv/certs/cacert.org/ca-cert-old.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEbzCCAlegAwIBAgIDC5WvMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv 3 | b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ 4 | Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y 5 | dEBjYWNlcnQub3JnMB4XDTEyMDQxMDE4MTA1NVoXDTEyMTAwNzE4MTA1NVowJDEi 6 | MCAGA1UEAxMZY2EuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDCBnzANBgkqhkiG9w0B 7 | AQEFAAOBjQAwgYkCgYEA03ZAGq21/E22WvtAAeQ2fzd+J3n1TmWw9Fr+qGBOLOXm 8 | NnGbWD5seICYdmOV6A6tMx2dDF/4l4/iLJHV1B3NdfugLzVGwRH7wPpmCMmpzLYz 9 | y/2UZOCOuHybE7eHglUnK3uSnGlebR/rVn6Nw4pochQ9+BV4qAbaIGNfIzWmGLUC 10 | AwEAAaOB2DCB1TAMBgNVHRMBAf8EAjAAMDQGA1UdJQQtMCsGCCsGAQUFBwMCBggr 11 | BgEFBQcDAQYJYIZIAYb4QgQBBgorBgEEAYI3CgMDMAsGA1UdDwQEAwIFoDAzBggr 12 | BgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmNhY2VydC5vcmcv 13 | ME0GA1UdEQRGMESCGWNhLmNhdGFjbHlzbS1zb2Z0d2FyZS5uZXSgJwYIKwYBBQUH 14 | CAWgGwwZY2EuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDANBgkqhkiG9w0BAQUFAAOC 15 | AgEAxutKr2yuHqYlaRyh0qFePVe/PlsfeRZ/+ywBUf/Hl0U2nEMQFSOXhO3z86QS 16 | UmH/GwDEmtwjZC4LYyyBHK+VBS1i/uUWysr/xvzNkZRfdate8kU+yQvwJlR61ACs 17 | ShLZJyY4UDyZ3ygh1G/ToWSGJDYXbxoQ0gXBwym5s6hBpMOEIB6TYI0y62wDHoMd 18 | wxbhoaZArDM8Z1hG7AMG01abh0RkpeGUvahJaromuyIvzRo804icoL5F2nbCFo3V 19 | itcP2485hDOCK7H7Rc5oRFZFPw4nPmtkR4YOK7pbO+XRVPY/xjVKH7URM3Va1OSP 20 | X5zhlJqVNTIs80j5zjSDjT+D2eQTkfp/nEjaQIKrg2LgFD6TNFEzSfi/zkpyksFY 21 | 7O65OgDYlccFqcTGsjOxrBPXWv+q7d5gsUAFbyV/d67XArvlxFbM6YuwySVXxrk0 22 | Uk3IEUl8bIHDLqPqnA6neq/J7KOG4M0rS4CwVV68PP/d/Gv++d93zcbL36F5X1c+ 23 | XdenI7EO+sokfmjeXvR9b7gjMM3ZenKkaSq5l7yYUeM3FQWXvoWK/0+ExCrT46up 24 | +LScAMHmmXDsGjqzgJrSel7Z99c+aN7WTUuJ3Iv89/+XXtFh7JzbJrPN24XmCC09 25 | CMN0VwN3RRo77kGKUKr/JYjqIU9urvSZ5jGk8KWGJ9fql50= 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /priv/certs/cacert.org/ca-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIGKzCCBBOgAwIBAgIDDlBlMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv 3 | b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ 4 | Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y 5 | dEBjYWNlcnQub3JnMB4XDTE0MDEwNjE3NTEzMVoXDTE0MDcwNTE3NTEzMVowJDEi 6 | MCAGA1UEAxMZY2EuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDCCAiIwDQYJKoZIhvcN 7 | AQEBBQADggIPADCCAgoCggIBALUCZ9vl+2MUip9979h8b8CRSLh2yHj5A4+j7Hg2 8 | /0C3zLPRuNjNYA453W2ob+JF6ANAOLykh9a6R5FLD/xbLUfPeycvV5Gnz/MGuStV 9 | leM3ef+lg/GMsxMCl4OflB3Ui4Lr7IziwtuMOQ9Jg5p3xESPfkE2EqbfmLbqNZ8n 10 | uGtmHLK/Mgyav+TFUJExn0OeNtANB199jl2tH4VNIRKkUhKPliVjt+Y7g/5Nvk0m 11 | YWEQqzfQiGrEVeNuDOZDF9+hG4mxtNtGdEoTyhig7Ixznz7w3wRw0MLA2hW14r1L 12 | N8W+Tkwa+hgwDTjlGwGFoUWbvGv1tzxnU816cFkSGRq/r+yDDpTBt1cjJX0hhDXg 13 | hdByfeTmwKctuFpIpW684bwWiSqx8K1vWpWH1xhQbOq/6BK4nv2xZGLI3gqofh/W 14 | /hJA+/9Yi1xwiMtC9ZYbIIJcCUtYASrrH0oh0emdHjoUdNfTmeJwadql4X6SS6vt 15 | 5qMZodtt47AwC4TzoiZ2pIoVRslIrG0Ov0xhujxKiW6wyek3loAQAyQPBUCqAyYq 16 | BPs0lvGPWOPIvONK4P8XCDAg2IwDKFfpFv+hsB7u8MDlWtnwF0EGk3g11fdoGECQ 17 | BIZyUJmlozQnDq51VAcsmzvQEncZEnIMzCp1kd+zar4TayZao20RQGeBupH73kxz 18 | 0fkbAgMBAAGjggEPMIIBCzAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIDqDA0 19 | BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEGCWCGSAGG+EIEAQYKKwYBBAGC 20 | NwoDAzAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmNh 21 | Y2VydC5vcmcvMDEGA1UdHwQqMCgwJqAkoCKGIGh0dHA6Ly9jcmwuY2FjZXJ0Lm9y 22 | Zy9yZXZva2UuY3JsME0GA1UdEQRGMESCGWNhLmNhdGFjbHlzbS1zb2Z0d2FyZS5u 23 | ZXSgJwYIKwYBBQUHCAWgGwwZY2EuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDANBgkq 24 | hkiG9w0BAQUFAAOCAgEAJ3sFvIAfTQGk8tEVH5dSSWpc5h02qmJj9L8DxxU4ZYMl 25 | SZvej9EhCUqx3X1HTdTNFdmAcdeEqi41Npmj58J1o8pF1Dm6hMcJfHEvIe6IQYnQ 26 | /KxAfi0uHOT2viNZPjNgf0DN33vEBMdpDhHTExmtrZM/afYnbh3lmpE1Zxjnsib0 27 | 8/RunbU7sUweQoGQH/g3Lz8faJS4XN436+N/mC7mHYPy33CRtgYqLh3/+xVM4dXL 28 | 1tw61JJvjLSMDxwBY/N7SxrYl6eNvhX//FDyMSG3+a9IqoR8HPGaQTPehcDTWNbp 29 | UakaZW1dBSP6oFE/MIAFrR5+62rjbAiUn7+fIXiulHyBQz2q+anvlLe3s8qdhTHp 30 | 3zG2i3GeY4E8/tChmeWSX3J0HDXVa52UYXScXdosAdaY/L9uBmpuHOrNvqwbbEPJ 31 | RriQMEKsOS6YQkWHfP8VWRX6VGMyCQakIxWGyA4BEho7EvIP8JMNLWBIQFlSSibe 32 | XHBADHAJwgx6t4mF6eCFPpemx0G87ukaQjj1FS/W7pTnRH+FbSxN/KE44R22qAFK 33 | nooqpK61p3xrGYC/6Npuix+q0+vltwlYlo4OyQLBKvE2WiYwYxzdQmQQzr/NyAkp 34 | mRyB9mjklDV9x1HTz2Rb1ATwRnP0olcmJOGOReml05FSsSk5HUkoAZ9INNWF/3I= 35 | -----END CERTIFICATE----- 36 | -------------------------------------------------------------------------------- /priv/certs/cacert.org/ny-cert-old.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEbzCCAlegAwIBAgIDC5WuMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv 3 | b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ 4 | Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y 5 | dEBjYWNlcnQub3JnMB4XDTEyMDQxMDE4MDM0MloXDTEyMTAwNzE4MDM0MlowJDEi 6 | MCAGA1UEAxMZbnkuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDCBnzANBgkqhkiG9w0B 7 | AQEFAAOBjQAwgYkCgYEAtPMzngDQJdM8JcOVcsVKU8yHCUv9SoervEaPAgsFaBFl 8 | qwSDpLAVH3khEBOkG5Ue9+tCi7c75/XQtgEkM05mwAXNuHPPLqDHMvfymkp7tqHJ 9 | zH1eeedZEKl0YsWxFT0hINZKxuwafZ6uPWgTS1YXP2hTjEOP2k/4Gv9ZzNWicGEC 10 | AwEAAaOB2DCB1TAMBgNVHRMBAf8EAjAAMDQGA1UdJQQtMCsGCCsGAQUFBwMCBggr 11 | BgEFBQcDAQYJYIZIAYb4QgQBBgorBgEEAYI3CgMDMAsGA1UdDwQEAwIFoDAzBggr 12 | BgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmNhY2VydC5vcmcv 13 | ME0GA1UdEQRGMESCGW55LmNhdGFjbHlzbS1zb2Z0d2FyZS5uZXSgJwYIKwYBBQUH 14 | CAWgGwwZbnkuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDANBgkqhkiG9w0BAQUFAAOC 15 | AgEAf1pR7FHk2auPPIrYkECFtudYy8DbNYL5G0R5zsQWJCZdU+zSJTYqL36z5W6M 16 | 55C2+NWAKOLdnURegeRZohNo5BnrQP1BSW+2pLqLVgvex0MH9sz8pnKAMl5HXvei 17 | Gap9wMXkIy9P/rdQRlmckoryFhQGKS9uUfNgi/Rt1uk1mpvT3rGPBKQ3kClNpxlh 18 | E5/ZmOfM4WPeHQgDlnqiRSs0rhXNVxrSfmRXGsf4m9PyIfquiIi1VLj5+WgfM1wg 19 | mrXMSN+nD+hq1Gr+Y2fb4OZMcirChHBsw7Y2p7zSo+VtqlW6jlj47TLJZD7qDoc9 20 | tYCx7EQ8vblUJIvdoffjm+Yk4ItDmjZjmkTSIKNQBws2EpxD/DE91+CC65i8u4yJ 21 | eiWJthDsleos6mjWAMffleImLTnc65CBKA2Oc7qNAUMvFwDBh789P0IdDBt/C1m/ 22 | FA0kBrZ7Zwvx2Gs42Sds+NMBAmRv97rP6DDMjNUnQQd6gN5D3fn2nLv2vBbzvTtY 23 | w4vMVd9oS+OXGtcr0h+dxwx9lSVfZIe9p2BQ/gfZDdt1KUdifIGCoFHsCg6xIKaN 24 | YnFRTGZocaakTkY+ClMiKEtQ08K/R2ngbd8WT2lhj3v64K/9bYBumOPp5t7wJy0n 25 | d4Hrz2FOVcPWIQPWTRFdtMaQxpt9aehDCrTMT7PvAi2XFJc= 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /priv/certs/cacert.org/ny-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIGKzCCBBOgAwIBAgIDDlBjMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv 3 | b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ 4 | Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y 5 | dEBjYWNlcnQub3JnMB4XDTE0MDEwNjE3NTAyOVoXDTE0MDcwNTE3NTAyOVowJDEi 6 | MCAGA1UEAxMZbnkuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDCCAiIwDQYJKoZIhvcN 7 | AQEBBQADggIPADCCAgoCggIBAL49A8Cyw0qv8kNuvfBd3jjzPMDVVMvfwg+DAKCf 8 | c9giVWbS5x4IoEBWGDbFuwO4mEbAzJuHhVs3kH99DNplSuRpopThYHW6pqRYJRou 9 | 9Y9ZqoBAClC4k1vR7jf52rgoW+BwO0pSa9KV/RWbGJ+bvpkjDwVHcrxDvp45H1mw 10 | hzgszZnfMnP1GoLVLSGS/QTmqdLDDhr8AeAenD+3nKiLtLYHDB3DBKmuOxZoku7y 11 | qmGRerme055hsDxqWwNsIIAJtkH3mXqHXqCz2AgwtPmdwSrVNsDJFrLzW/U7WJlj 12 | 7g1nvdDEcXgRRkeTig87EVTZDkOYSmBHvPCeaxCzXwzDDpeEulnZVs/y77Xr1vIG 13 | CN0khVWKFkaZTiqR3N8cBw0YoImjhrMGbN22zPBAPuEV4oSluBl1g8HIUCnfzVPa 14 | mobberyOcslrOys6SXKNkMfzEeMqf7e0Mgnma1kvXhF+OfCEnpddD5hEO6SRwXy3 15 | /58tZtou/OK0g5hgUNxrseaAhnbaH/0xfgiRltXe3qNa0a6+bQ/h54b7d9nxVb88 16 | PTlel9JiqGLXzixTQFvKWH8QcHNQWCxBpL5x826Tx1Om37DpntbAIb1Tp3uIyW3c 17 | HQOHS1F7GwK1e7zFko9+tuZ8l/phTTCb5/SmU5n07niipW+V61px4vU7jpgUYALk 18 | Gw5VAgMBAAGjggEPMIIBCzAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIDqDA0 19 | BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEGCWCGSAGG+EIEAQYKKwYBBAGC 20 | NwoDAzAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmNh 21 | Y2VydC5vcmcvMDEGA1UdHwQqMCgwJqAkoCKGIGh0dHA6Ly9jcmwuY2FjZXJ0Lm9y 22 | Zy9yZXZva2UuY3JsME0GA1UdEQRGMESCGW55LmNhdGFjbHlzbS1zb2Z0d2FyZS5u 23 | ZXSgJwYIKwYBBQUHCAWgGwwZbnkuY2F0YWNseXNtLXNvZnR3YXJlLm5ldDANBgkq 24 | hkiG9w0BAQUFAAOCAgEAb3VGTCfuDkpVNwJjF8UtAQ9g3wIzkwMYE0gY0TzVyuAn 25 | SkyTY4W8PDbXBNmwksucpsPnqowEAT+zOegh9TKM8EFMBzyAR4jecbL/gtFQQ09P 26 | MPeMKkrdaEkKuViP7RWfWSzOTe5HW4dKAYo2Cjgp7a2KHFg7PFVxoI/T7NMZg/rz 27 | +PnBkZYm5fQDxoEbTfsaUPMxSC7GU5IqFWS5xtgUAyRYWitkS+tktr6YmNRpRsS8 28 | 5wMqaK1Y1lEycUzeJgSV5Uwo2FocdfLBD4jSBJ4LPzDTz+uWaf5HEH7Ta4/mH7ro 29 | ITwjbtESbSgwf1TUwhame/pDy3iBT8FQxF2RNJn1WgpBcInpS5oLKECcTBtHd7YC 30 | oH0MGSxyV1zAm41bXSZDZ33DkF04K8eKhUmPTAFQz0IAL9X/WtuhCJvwpRipEoNr 31 | EuwBhElm9bzOcl16d8Ls89vSa7CVqU4nl2DR4PqS4/fDpHX0oHlNgocLp0LjtDzY 32 | +sGEySZVPu+AL+mLRA8+xNU+VuYV6/vckBUGAvdDCGRpNQV6/NUb49AsC6W0H7sS 33 | dahCWRyFOT1TYHvc39qnqmBfBj74feRNK2mrzj0EJ0PKnxWlTpDcx+h9ZMkDuoiy 34 | lDfBe3CArkQ647sUIlYPsAf+/IX1vmaevlPuw3Hyii4vJPMy5VsG2cBPZsvrXq0= 35 | -----END CERTIFICATE----- 36 | -------------------------------------------------------------------------------- /priv/certs/selfsigned/site1-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBANVVG2F2f2eOrnPS 3 | LuZ6wYp82HIbewdiFrzc6n9ZcWt9BLdrYNIdx0ddKIBkQ3fCZnNRdyMg11I4JGR+ 4 | KmHkYTmKA6nImJ8PJxPQPjlae4niBRpxM0G0d0yCAINuHx2nTRe4THZNCTpfF1/r 5 | wL0LCxhLrbNqD3p4WtaklkqpjxgjAgMBAAECgYEAjyAfU59N0OuQLVKJdsZLDR+/ 6 | k6bOPuDXQnSwuyoGB0iEHo7jEXU7GqzsnF8oSLPbSmkQljfVXmseN3HR+4VemCKv 7 | +tWVGaEY2YA3YBY91Ew+ayjLoAtmm95xZFzE8BHE3e6K9E1o10020IcLbhJvkgSa 8 | qQj5gF4l5i8d+aJSuFkCQQD58lytdD/Mr94vwDrDSQd2DVVNdO3P9pEbO9diZbtE 9 | q3r+AFOmnSC53ltedLRS6DPChdPmd86rkH5OROOPRUAnAkEA2n+9tieqkdmG414d 10 | oCiFZv9NQHFYraix0s+UDR0q5RF7uv8qaLkCJvRFDs7iJb4tHAlQZIz9tD36wWmC 11 | KbWppQJBAIom7BLzrk/05Vp/ZfuK4hTeScgGWWwZXRsweFxq3peWMOU0SQhO0Ufr 12 | H5WV7BXnQrTCQ92fWxx5QVcBvMX0AQECQQDDuX3lN+8RKzwrW9lJ6EJnmvZGbcIz 13 | /VMdNhi3DpOoEls1jPEeUevdnR5nP2dQy+R4otdC2xFAbey7aJnSZwqJAkEAiTzj 14 | MSit4H/AduWGBMKYcWY5NTvHrkFTZ2ePaurt2DKYzwYmYDjXpiqiGEEG0IITFbG5 15 | jeRIRkPPkD+Wj53fOg== 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /priv/certs/selfsigned/site2-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMer38wG6+wiUb2B 3 | Ea7Fud8B1+uBdwRswy3n4huysoktW+Nooj8q5Owlnh+O9vDpKAlfVD0GcgrqpxDF 4 | e+Y1nR88SQ61X6QqBDJ7hzCR6OcvdXQfbnremJGuHuK42J6QwqOBvVQbai42zHDg 5 | d8uGPju/ZChcy2oDkq+v9QW+pxbHAgMBAAECgYBvaidpuF8Cly/XN2L/i9MobeXm 6 | won/zRSn0+EmJXNb+hRw81y9NJkib+coouSGDwPJHwlpN+SA1Oi+AgQds8LkwrZ3 7 | MHe/88WjN8iSlp8jcmi1I7BbMCiASmundiUMJwGwcJDgg2bBh0ZOlm4DExyMYuPm 8 | hI45R1aDC03TIRifAQJBAPcXwxhPJO2Ujc15rvP176wFfR8PlKQ9hM+47VzYsRqz 9 | V1nGbNo+kO8Yd+Un2MyXQ7AYnEMjylyeQ9PHGm/FLoECQQDO3n6a+o37fuPu4rIk 10 | keepGUnLDTuWiHAp9GXQ9b1lRhR6yOVOdl2nFBjQjJxTGRngPGjOw/9oWBWS2bUh 11 | 0LFHAkEAjzuhBihquaXRhXiyKA06f7c2zpiTi5l1sYv7XETodRfc3NefJev6y/6d 12 | EaNFk2NkA2JgwrKujX3Yx5y1AHGHAQJBAIBh1HCZzkOmHA7E4YmQgxSOfR1muPRS 13 | +EkRQ57K4x9Wvp70zlpDWxu1fTDwEpP/n+9pjiHDwV4gTEM2mRLDUUECQDP+gvps 14 | QFZ0RMXlQRoMZI7s4ASANfM7/fqLdHPzChAKDW4AsAL3tuDNlMgv35GVsQV29158 15 | PHraw/J/0/veLT8= 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /priv/certs/selfsigned/site3-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQCzKS5vPxTR2kmdIwnAI2mrpSrd2eAL+0XX9GXDWqWrsTFqvXYN 3 | TBHrRpnZf0u0rxNkIEaThaY3N+7HVtBnOIR6dhCSWVoNcQpTEs7cWpsq573QjJjA 4 | thBSP3MbIBGQgaTbJhNLoKB4OvjmX5QdAoKo7gMJYJkyMA5rRk9xVENrVwIDAQAB 5 | AoGAP5V++FZf8jZRZ+ZWgI1Q5G0C8Kdxf28XE5SWRSW3pF6HlkVVT1TPCzwMQAeQ 6 | e7ii3iciRRrqqbA9GxvxbKC/Swrtc6ICP96ff7mOQ0ds+wJh1PCYAVKPwhfpJCoc 7 | hlzcF6f8Z/MG4DqNoQ8WgeaoK1y5MggJhp2OT5OIjp6/1eECQQDaxeEfmiZipypV 8 | R+MlVl7pl9X5h9oUhhjqGsdE2WKMHlwFMZiMt+2BGkOBTzW45OjQlHDGQN5IqW+A 9 | Fg6GYgXHAkEA0aW7WLN/5Mz+ZdPgrZPtwbalBC4rB7ZaT/5IWgz5TL8vc5sSUrw/ 10 | u+3wgtqf+YVtBzQqU4i89b9sIVtAUUgt8QJASw1FjQTiFEgK4tTVnRKDXxnCw2cS 11 | rqXOWEm1gO4eu7kSkomQLv5OUVMEQ5E7+eE16ZBzG+BXIZBW+xcWBo4MMwJAQqi1 12 | pwB7+94KTYpO+CH/CQbv9SJQ4ETk9mZdzvQtGG/5wIJgExp0EWcYgCLPluELx6yY 13 | gLMLkf/pe7mt+6o9oQJBALA/+/vHwo9VT7VT/D+G1p5lPK7N+36nccp639HnMTv3 14 | IsaSkKmSvPG5qYRC1ydgnt/O+epMwHq7Dbkn6mhLk9I= 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /priv/certs/selfsigned/site4-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQDCvMx1z1w8Een3vziSjkowwy76vLzQnzSFx241bclNFspDN/fG 3 | 6oD/ty4Ic8ATRGbcGb6C3NUCPbzcmxQxA+25Vf8uVAjp9sBESNPoRFCDSe3wrotQ 4 | uWzwC9uZc3aXkAycv8eempFox0g1EH+NGfiVXFs5RcQouK/VTNG3KbtSTwIDAQAB 5 | AoGBAJF/iqxDQEDJiaxHvTcTBS+lxcYlmlWtfgquVROqcYsdigXrHUAMGlH1RXmf 6 | MlWy979fpM4VvTktc5zIaa+tpcFTDMliGtPMJ17itaa74KJ5vWRcBg1X6yifHLi7 7 | DAKdgSzUvA5yn7ZIxLZ7q/WKEpyxQDQegnb0zZWuO13vOdxBAkEA9JMUa28jFZvt 8 | zcrnGwb8AQkIYb0ncfBecKdnAe3XDWw+N3ZuzhywQBmB57ietsf+SjhqKnY7+f46 9 | 6qkWL3UznwJBAMvVtPhLXbdKPHm8XP2KqJNP18LlWJVZ/2UzbJInXUh6/ImBJ1te 10 | 9OZcPZu4W/1TChcTvAKFIvGCG7pfWxsg41ECQB//NgawLYjgM4Ze60lP6pxAEEap 11 | NoXjipd2bzWDZkUtSh57chepDS31qFcmgi0rkQsowkr32PTl29Njd7GRxcUCQG31 12 | eUzAi2vHNlyNirSTymC9n61Zv7HB/Q6A8T7e0Wm6PuWGsM6PqRlkBTAuAiHkW/sb 13 | AD9zxuf1wjOGIUW/NiECQFZeor6Ur22vb6e7Cxq+6PgWRc2MRPq2fOktSDc6n7Vn 14 | G9vZIzCr8AzIBZ4wdzf1xhiFeBsOp2HlFuawTguODzs= 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /priv/dir_sum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z $1 ]; then 4 | RIAK_DIR=$1 5 | else 6 | echo "No build supplied" 7 | exit 1 8 | fi 9 | 10 | TMP=/tmp/dir_sum.tmp 11 | SORTED=/tmp/dir_sum.tmp.sorted 12 | rm -f $TMP 13 | rm -f $SORTED 14 | 15 | sum_subdir () { 16 | SUBDIR=$1 17 | if [ ! -d $RIAK_DIR/$SUBDIR ]; then 18 | exit 2 19 | fi 20 | find $RIAK_DIR/$SUBDIR -type f -print | xargs md5sum -b >> $TMP 21 | } 22 | 23 | if [ ! -d $RIAK_DIR ]; then 24 | exit 2 25 | fi 26 | 27 | sum_subdir lib 28 | sum_subdir bin 29 | sum_subdir erts* 30 | 31 | sort $TMP > $SORTED 32 | 33 | md5sum $SORTED | awk '{print $1}' 34 | 35 | 36 | rm -f $TMP 37 | rm -f $SORTED 38 | 39 | -------------------------------------------------------------------------------- /priv/install/drop: -------------------------------------------------------------------------------- 1 | evan ALL=NOPASSWD: /usr/local/bos1/home/evan/bin/drop_caches.sh 2 | 3 | -------------------------------------------------------------------------------- /priv/install/drop_caches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sync 3 | sync 4 | sync 5 | sleep 5 6 | echo 3 >/proc/sys/vm/drop_caches 7 | -------------------------------------------------------------------------------- /priv/reporting/compare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if [ ! -d "$1/" -o ! -d "$2" ]; then 5 | echo "two directories must be specified" 6 | exit 1 7 | fi 8 | 9 | #digesting the files is expensive, don't do it by default 10 | if [ ! -z $3 -a $3 = "true" ]; then 11 | #make our digest files 12 | (cd $1; rm -f *-digest; escript ~/bin/riak-digest.escript) 13 | (cd $2; rm -f *-digest; escript ~/bin/riak-digest.escript) 14 | fi 15 | 16 | D1=`basename "$1"` 17 | D2=`basename "$2"` 18 | 19 | #generate our comparison graph 20 | gnuplot -e "dir1=\"$1\"; dir2=\"$2\"; outfilename=\"${D1}vs${D2}-summary.png\";" ~/bin/summarize.gpl 21 | -------------------------------------------------------------------------------- /priv/reporting/gen_report.escript: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript -f 2 | 3 | -mode(compile). 4 | 5 | main([Dir1, Dir2]) -> 6 | main([Dir1, Dir2, "false"]); 7 | main([Dir1, Dir2, Regen]) -> 8 | {ok, L10} = file:list_dir(Dir1), 9 | {ok, L20} = file:list_dir(Dir2), 10 | 11 | 12 | Len = erlang:min(length(L10), length(L20)), 13 | {L1, _} = lists:split(Len, L10), 14 | {L2, _} = lists:split(Len, L20), 15 | 16 | 17 | CL = lists:zip(lists:usort(L1), lists:usort(L2)), 18 | %%M = 19 | lists:map(fun(X) -> 20 | run_compare(X, Dir1, Dir2, Regen) 21 | end, 22 | CL); 23 | % lists:foreach(fun(M1) -> 24 | % io:format(M1) 25 | % end, M); 26 | main(_) -> 27 | io:format("incorrect number of arguments\n"). 28 | 29 | 30 | run_compare({A, B}, DirA, DirB, Regen) -> 31 | %%io:format("~p ~p ~p ~p ~p ~n", [DirA, A, DirB, B, Regen]), 32 | O= os:cmd("./compare.sh "++DirA++"/"++A++" "++ 33 | DirB++"/"++B++" "++Regen), 34 | io:format("~p ~n", [O]). 35 | %%os:cmd("mv summary.png "++A++"vs"++B++"-sumary.png"). 36 | 37 | -------------------------------------------------------------------------------- /priv/reporting/report-2i.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if [ ! -d "$1/" ]; then 5 | echo "a directory must be specified" 6 | exit 1 7 | fi 8 | if [ "x$2" == "xtrue" ]; then 9 | (cd $1; rm -f *-digest; escript ~/bin/riak-digest.escript) 10 | fi 11 | 12 | D1=`basename "$1"` 13 | 14 | #generate our comparison graph 15 | gnuplot -e "dir1=\"$1\"; outfilename=\"${D1}-report.png\";" priv/reporting/summarize2i.gpl 16 | -------------------------------------------------------------------------------- /priv/reporting/report-crdt-team-map.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if [ ! -d "$1/" ]; then 5 | echo "a directory must be specified" 6 | exit 1 7 | fi 8 | if [ "x$2" == "xtrue" ]; then 9 | (cd $1; rm -f *-digest; escript ../../priv/reporting/riak-digest.escript) 10 | fi 11 | 12 | D1=`basename "$1"` 13 | 14 | #generate our comparison graph 15 | gnuplot -e "dir1=\"$1\"; outfilename=\"${D1}-report.png\";" priv/reporting/summarize-crdt-team-map.gpl 16 | -------------------------------------------------------------------------------- /priv/reporting/report.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if [ ! -d "$1/" ]; then 5 | echo "a directory must be specified" 6 | exit 1 7 | fi 8 | if [ "x$2" == "xtrue" ]; then 9 | (cd $1; rm -f *-digest; escript ../../priv/reporting/riak-digest.escript) 10 | fi 11 | 12 | D1=`basename "$1"` 13 | 14 | #generate our comparison graph 15 | gnuplot -e "dir1=\"$1\"; outfilename=\"${D1}-report.png\";" priv/reporting/summarize1.gpl 16 | -------------------------------------------------------------------------------- /rebar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basho/riak_test/8170137b283061ba94bc85bf42575021e26c929d/rebar -------------------------------------------------------------------------------- /rebar.config: -------------------------------------------------------------------------------- 1 | {require_otp_vsn, "R13B04|R14|R15|R16"}. 2 | {cover_enabled, true}. 3 | {edoc_opts, [{preprocess, true}]}. 4 | %%{edoc_opts, [{doclet, edown_doclet}, {pretty_printer, erl_pp}]}. 5 | %%{edoc_opts, [{doclet, my_layout}, {pretty_printer, erl_pp}]}. 6 | %%{edoc_opts, [{layout, my_layout}, {file_suffix, ".xml"}, {pretty_printer, erl_pp}]}. 7 | {erl_opts, [{src_dirs, [src, intercepts, perf]}, 8 | warnings_as_errors, {parse_transform, lager_transform}]}. 9 | {erl_first_files, ["src/rt_intercept_pt.erl"]}. 10 | 11 | {eunit_opts, [verbose]}. 12 | 13 | {deps, [ 14 | {lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.2.4"}}}, 15 | {getopt, ".*", {git, "https://github.com/basho/getopt.git", {tag, "v0.8.2"}}}, 16 | {meck, ".*", {git, "https://github.com/basho/meck.git", {tag, "0.8.2"}}}, 17 | {mapred_verify, ".*", {git, "https://github.com/basho/mapred_verify", {tag, "0.1"}}}, 18 | {riakc, ".*", {git, "https://github.com/basho/riak-erlang-client", {branch, "develop"}}}, 19 | {riakhttpc, ".*", {git, "https://github.com/basho/riak-erlang-http-client", {branch, "develop"}}}, 20 | {kvc, ".*", {git, "https://github.com/basho/kvc.git", {tag, "v1.5.0"}}}, 21 | {druuid, ".*", {git, "https://github.com/basho/druuid.git", {tag, "0.2"}}}, 22 | {tdiff, ".*", {git, "https://github.com/basho/tdiff", {tag, "0.1"}}}, 23 | {rebar_lock_deps_plugin, ".*", {git, "https://github.com/basho/rebar_lock_deps_plugin.git", {tag, "3.1.0p1"}}} 24 | ]}. 25 | 26 | {escript_incl_apps, [goldrush, lager, getopt, riakhttpc, riakc, ibrowse, mochiweb, kvc, tdiff]}. 27 | {escript_emu_args, "%%! -escript main riak_test_escript +K true +P 10000 -env ERL_MAX_PORTS 10000\n"}. 28 | {plugin_dir, "src"}. 29 | {plugins, [rebar_riak_test_plugin, rebar_lock_deps_plugin]}. 30 | {riak_test, [ 31 | {test_paths, ["tests", "perf"]}, 32 | {test_output, "ebin"} 33 | ]}. 34 | -------------------------------------------------------------------------------- /rebar.config.script: -------------------------------------------------------------------------------- 1 | case os:getenv("SMOKE_TEST") of 2 | false -> CONFIG; 3 | [] -> CONFIG; 4 | _ -> 5 | C1 = lists:keystore(escript_emu_args, 1, CONFIG, 6 | {escript_emu_args, "%%! -escript main smoke_test_escript +K true +P 10000 -env ERL_MAX_PORTS 10000\n"}), 7 | lists:keystore(escript_name, 1, C1, {escript_name, smoke_test}) 8 | end. 9 | -------------------------------------------------------------------------------- /report-2i.sh: -------------------------------------------------------------------------------- 1 | priv/reporting/report-2i.sh -------------------------------------------------------------------------------- /report.sh: -------------------------------------------------------------------------------- 1 | priv/reporting/report.sh -------------------------------------------------------------------------------- /results/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | 6 | -------------------------------------------------------------------------------- /riak: -------------------------------------------------------------------------------- 1 | riak-2.0 -------------------------------------------------------------------------------- /run-perf-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp examples/riak_test.config.perf ~/.riak_test.config 4 | make clean 5 | make 6 | 7 | echo "Running the CRDT team benchmark." 8 | ./riak_test -c rtperf -t crdt_team_map -v -- --run-time 10 --ram-size 61440 --name crdt_team_map 9 | 10 | # echo "Running the get/put benchmark." 11 | # ./riak_test -c rtperf -t get_put -v -- --run-time 10 --ram-size 61440 --name get_put 12 | 13 | # echo "Running the consistent get/put benchmark." 14 | # ./riak_test -c rtperf -t consistent_get_put -v -- --run-time 10 --ram-size 61440 --name consistent_get_put 15 | -------------------------------------------------------------------------------- /search-corpus/spam.0.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basho/riak_test/8170137b283061ba94bc85bf42575021e26c929d/search-corpus/spam.0.1.tar.gz -------------------------------------------------------------------------------- /src/riak_test.app.src: -------------------------------------------------------------------------------- 1 | {application, riak_test, 2 | [ 3 | {description, ""}, 4 | {vsn, git}, 5 | {registered, []}, 6 | {applications, [ 7 | kernel, 8 | stdlib, 9 | lager 10 | ]}, 11 | {env, [ 12 | {platform, undefined}, 13 | {rt_scratch_dir, "/tmp/riak_test_scratch"}, 14 | {rt_max_wait_time, 180000}, 15 | {rt_retry_delay, 500}, 16 | {rt_harness, rtdev}, 17 | {java, [{fat_be_url, "http://riak-java-client.s3.amazonaws.com/riak-client-1.4.2-jar-with-dependencies-and-tests.jar"}, 18 | {tests_url, "http://riak-java-client.s3.amazonaws.com/riak-client-1.4.2-tests.jar"} 19 | ]} 20 | ]} 21 | ]}. 22 | -------------------------------------------------------------------------------- /src/riak_test.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2013 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(riak_test). 22 | 23 | %% Define the riak_test behavior 24 | -callback confirm() -> pass | fail. 25 | -------------------------------------------------------------------------------- /src/rt_worker_sup.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(rt_worker_sup). 22 | 23 | -behavior(supervisor). 24 | 25 | %% Helper macro for declaring children of supervisor 26 | -define(CHILD(Id, Mod, Node, Backend, Vsn, ReportPid), { 27 | list_to_atom(atom_to_list(Node) ++ "_loader_" ++ integer_to_list(Id)), 28 | { Mod, 29 | start_link, 30 | [list_to_atom(atom_to_list(Node) ++ "_loader_" ++ integer_to_list(Id)), Node, Backend, Vsn, ReportPid]}, 31 | permanent, 5000, worker, [Mod]}). 32 | 33 | -export([init/1]). 34 | -export([start_link/1]). 35 | 36 | start_link(Props) -> 37 | supervisor:start_link(?MODULE, Props). 38 | 39 | init(Props) -> 40 | WorkersPerNode = proplists:get_value(concurrent, Props), 41 | Node = proplists:get_value(node, Props), 42 | Backend = proplists:get_value(backend, Props), 43 | Vsn = proplists:get_value(version, Props), 44 | ReportPid = proplists:get_value(report_pid, Props), 45 | 46 | ChildSpecs = [ 47 | ?CHILD(Num, loaded_upgrade_worker_sup, Node, Backend, Vsn, ReportPid) 48 | || Num <- lists:seq(1, WorkersPerNode)], 49 | 50 | lager:info("Starting ~p workers to ~p", [WorkersPerNode, Node]), 51 | 52 | {ok, {{one_for_one, 1000, 60}, ChildSpecs}}. 53 | -------------------------------------------------------------------------------- /tests/always_fail_test.erl: -------------------------------------------------------------------------------- 1 | %% @doc A test that always returns `fail'. 2 | -module(always_fail_test). 3 | -export([confirm/0]). 4 | 5 | -spec confirm() -> pass | fail. 6 | confirm() -> 7 | fail. 8 | -------------------------------------------------------------------------------- /tests/always_pass_test.erl: -------------------------------------------------------------------------------- 1 | %% @doc A test that always returns `pass'. 2 | -module(always_pass_test). 3 | -behavior(riak_test). 4 | -export([confirm/0]). 5 | 6 | -spec confirm() -> pass | fail. 7 | confirm() -> 8 | pass. 9 | -------------------------------------------------------------------------------- /tests/cause_bdp.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% cause_bdp - helper module used by verify_busy_dist_port 4 | %% 5 | %% Copyright (c) 2012 Basho Technologies, Inc. 6 | %% 7 | %% This file is provided to you under the Apache License, 8 | %% Version 2.0 (the "License"); you may not use this file 9 | %% except in compliance with the License. You may obtain 10 | %% a copy of the License at 11 | %% 12 | %% http://www.apache.org/licenses/LICENSE-2.0 13 | %% 14 | %% Unless required by applicable law or agreed to in writing, 15 | %% software distributed under the License is distributed on an 16 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | %% KIND, either express or implied. See the License for the 18 | %% specific language governing permissions and limitations 19 | %% under the License. 20 | %% 21 | %% ------------------------------------------------------------------- 22 | 23 | -module(cause_bdp). 24 | -compile(export_all). 25 | 26 | spam_nodes(TargetNodes) -> 27 | [[spawn(?MODULE, spam, [N]) || _ <- lists:seq(1,1000*200)] || N <- TargetNodes]. 28 | 29 | spam(Node) -> 30 | timer:sleep(random:uniform(100)), 31 | catch rpc:call(Node, erlang, whereis, [rex]). 32 | -------------------------------------------------------------------------------- /tests/cuttlefish_configuration.erl: -------------------------------------------------------------------------------- 1 | -module(cuttlefish_configuration). 2 | 3 | -behavior(riak_test). 4 | -export([confirm/0]). 5 | 6 | -include_lib("eunit/include/eunit.hrl"). 7 | 8 | confirm() -> 9 | 10 | CuttlefishConf = [ 11 | {"ring_size", "8"}, 12 | {"leveldb.sync_on_write", "on"} 13 | ], 14 | 15 | [Node] = rt:deploy_nodes(1, {cuttlefish, CuttlefishConf}), 16 | {ok, RingSize} = rt:rpc_get_env(Node, [{riak_core, ring_creation_size}]), 17 | ?assertEqual(8, RingSize), 18 | 19 | %% test leveldb sync typo 20 | {ok, LevelDBSync} = rt:rpc_get_env(Node, [{eleveldb, sync}]), 21 | ?assertEqual(true, LevelDBSync), 22 | 23 | 24 | pass. 25 | -------------------------------------------------------------------------------- /tests/ensemble_basic.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2013-2014 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ensemble_basic). 22 | -export([confirm/0]). 23 | -include_lib("eunit/include/eunit.hrl"). 24 | 25 | confirm() -> 26 | NumNodes = 5, 27 | NVal = 5, 28 | Config = ensemble_util:fast_config(NVal), 29 | lager:info("Building cluster and waiting for ensemble to stablize"), 30 | ensemble_util:build_cluster(NumNodes, Config, NVal), 31 | pass. 32 | -------------------------------------------------------------------------------- /tests/ensemble_start_without_aae.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2013-2014 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ensemble_start_without_aae). 22 | -export([confirm/0]). 23 | -include_lib("eunit/include/eunit.hrl"). 24 | 25 | confirm() -> 26 | 27 | NumNodes = 5, 28 | NVal = 5, 29 | 30 | Config = ensemble_util:fast_config(NVal, false), 31 | lager:info("Building cluster with consensus enabled and AAE disabled. Waiting for ensemble to stablize ..."), 32 | 33 | _ = ensemble_util:build_cluster_without_quorum(NumNodes, Config), 34 | pass. 35 | -------------------------------------------------------------------------------- /tests/gh_riak_core_154.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %% Automated test for issue riak_core#154 22 | %% Hinted handoff does not occur after a node has been restarted in Riak 1.1 23 | -module(gh_riak_core_154). 24 | -behavior(riak_test). 25 | -export([confirm/0]). 26 | -include_lib("eunit/include/eunit.hrl"). 27 | 28 | confirm() -> 29 | %% Increase handoff concurrency on nodes 30 | NewConfig = [{riak_core, [{handoff_concurrency, 1024}]}], 31 | Nodes = rt:build_cluster(2, NewConfig), 32 | ?assertEqual(ok, rt:wait_until_nodes_ready(Nodes)), 33 | [Node1, Node2] = Nodes, 34 | 35 | lager:info("Write data while ~p is offline", [Node2]), 36 | rt:stop(Node2), 37 | rt:wait_until_unpingable(Node2), 38 | ?assertEqual([], rt:systest_write(Node1, 1000, 3)), 39 | 40 | lager:info("Verify that ~p is missing data", [Node2]), 41 | rt:start(Node2), 42 | rt:stop(Node1), 43 | rt:wait_until_unpingable(Node1), 44 | ?assertMatch([{_,{error,notfound}}|_], 45 | rt:systest_read(Node2, 1000, 3)), 46 | 47 | lager:info("Restart ~p and wait for handoff to occur", [Node1]), 48 | rt:start(Node1), 49 | rt:wait_for_service(Node1, riak_kv), 50 | rt:wait_until_transfers_complete([Node1]), 51 | 52 | lager:info("Verify that ~p has all data", [Node2]), 53 | rt:stop(Node1), 54 | ?assertEqual([], rt:systest_read(Node2, 1000, 3)), 55 | 56 | lager:info("gh_riak_core_154: passed"), 57 | pass. 58 | -------------------------------------------------------------------------------- /tests/kv679_uid.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2014 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %%% @copyright (C) 2014, Basho Technologies 21 | %%% @doc 22 | %%% riak_test for kv679-ish bug were vnodes on same node get same ID 23 | %%% 24 | %%% @end 25 | 26 | -module(kv679_uid). 27 | -behavior(riak_test). 28 | -compile([export_all]). 29 | -export([confirm/0]). 30 | 31 | -include_lib("eunit/include/eunit.hrl"). 32 | 33 | -define(BUCKET, <<"kv679">>). 34 | -define(KEY, <<"test">>). 35 | 36 | confirm() -> 37 | [Node] = rt:deploy_nodes(1), 38 | PL = kv679_tombstone:get_preflist(Node), 39 | 40 | %% Get vnodeids for each primary 41 | PartitionIdMap = get_vnodeids(PL, Node), 42 | 43 | lager:info("ids = ~p", [PartitionIdMap]), 44 | %% assert each is unique 45 | {_Idxes, VnodeIds} = lists:unzip(PartitionIdMap), 46 | ?assertEqual(3,length(PartitionIdMap)), 47 | ?assertEqual(3, length(lists:usort(VnodeIds))), 48 | 49 | pass. 50 | 51 | get_vnodeids(PLAnn, Node) -> 52 | PL = [{Idx, N} || {{Idx, N}, Type} <- PLAnn, 53 | Type == primary], 54 | Statuses = rpc:call(Node, riak_kv_vnode, vnode_status, [PL]), 55 | [{Idx, proplists:get_value(vnodeid, Status)} || {Idx, Status} <- Statuses]. 56 | -------------------------------------------------------------------------------- /tests/kv_vnode_requests_upgrade_downgrade.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(kv_vnode_requests_upgrade_downgrade). 21 | 22 | -include_lib("eunit/include/eunit.hrl"). 23 | 24 | -export([confirm/0]). 25 | 26 | -define(NUM_KEYS, 100). 27 | -define(BUCKET, <<"ale">>). 28 | -define(CLUSTER_SIZE, 5). 29 | -define(CONFIG, []). 30 | 31 | confirm() -> 32 | Cluster = [Node| _ ] = rt:build_cluster(lists:duplicate(?CLUSTER_SIZE, {lts, ?CONFIG})), 33 | Clients = [rt:pbc(N) || N <- Cluster], 34 | 35 | lager:info("Writing ~p keys", [?NUM_KEYS]), 36 | rt:systest_write(Node, ?NUM_KEYS, ?BUCKET), 37 | 38 | Before = count_keys(Clients, ?BUCKET), 39 | ExpectedCounts = lists:duplicate(?CLUSTER_SIZE, ?NUM_KEYS), 40 | ?assertEqual(Before, ExpectedCounts), 41 | 42 | perform_upgrade(Cluster, current, 3), 43 | 44 | After = count_keys(Clients, ?BUCKET), 45 | ?assertEqual(Before, After), 46 | pass. 47 | 48 | count_keys(Clients, Bucket) when is_list(Clients) -> 49 | [count_keys(Client, Bucket) || Client <- Clients]; 50 | count_keys(Client, Bucket) -> 51 | {ok, Keys} = riakc_pb_socket:list_keys(Client, Bucket, 5000), 52 | length(Keys). 53 | 54 | perform_upgrade(Node, Version) -> 55 | lager:info("Upgrading node ~p", [Node]), 56 | rt:upgrade(Node, Version), 57 | lager:info("Upgrade finished on node ~p", [Node]), 58 | rt:wait_for_service(Node, riak_kv). 59 | perform_upgrade(Cluster, Version, TakeN) -> 60 | lists:foreach(fun(Node) -> perform_upgrade(Node, Version) end, 61 | lists:sublist(Cluster, TakeN)). 62 | -------------------------------------------------------------------------------- /tests/mapred_verify_rt.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %% @doc Runs the mapred_verify tests from 21 | %% http://github.com/basho/mapred_verify 22 | 23 | -module(mapred_verify_rt). 24 | 25 | -behavior(riak_test). 26 | -export([confirm/0]). 27 | 28 | -define(NODE_COUNT, 3). 29 | 30 | confirm() -> 31 | lager:info("Build ~b node cluster", [?NODE_COUNT]), 32 | Nodes = rt:build_cluster(?NODE_COUNT), 33 | 34 | 35 | %% @todo longer term fix is probably one or more of: 36 | %% 1) add a mapred_veryify section to riak_test.config 37 | %% 2) learn to use this "inclextra" bit of rebar to package tests.def 38 | %% in the escript: https://github.com/basho/rebar/blob/master/src/rebar_escripter.erl#L57 39 | PrivDir = case code:priv_dir(mapred_verify) of 40 | {error, bad_name} -> 41 | erlang:error("Could not determine priv dir for mapred_verify. Make sure that your riak_test.config contains \"deps\""); 42 | PD -> PD 43 | end, 44 | MRVProps = [{node, hd(Nodes)}, 45 | %% don't need 'path' because riak_test does that for us 46 | {keycount, 1000}, 47 | {bodysize, 1}, 48 | {populate, true}, 49 | {runjobs, true}, 50 | {testdef, filename:join(PrivDir, "tests.def")}], 51 | 52 | lager:info("Run mapred_verify"), 53 | 0 = mapred_verify:do_verification(MRVProps), 54 | lager:info("~s: PASS", [atom_to_list(?MODULE)]), 55 | pass. 56 | -------------------------------------------------------------------------------- /tests/pipe_verify_examples.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %% @doc Verify that the riak_pipe example use functions work. 21 | 22 | -module(pipe_verify_examples). 23 | 24 | -export([confirm/0]). 25 | 26 | -include_lib("eunit/include/eunit.hrl"). 27 | 28 | -define(NODE_COUNT, 3). 29 | 30 | confirm() -> 31 | lager:info("Build ~b node cluster", [?NODE_COUNT]), 32 | Nodes = rt:build_cluster(?NODE_COUNT), 33 | 34 | [rt:wait_for_service(Node, riak_pipe) || Node <- Nodes], 35 | 36 | verify_example(Nodes), 37 | verify_example_transform(Nodes), 38 | verify_example_reduce(Nodes), 39 | 40 | rt_pipe:assert_no_zombies(Nodes), 41 | 42 | lager:info("~s: PASS", [atom_to_list(?MODULE)]), 43 | pass. 44 | 45 | verify_example([RN|_]) -> 46 | lager:info("Run riak_pipe:example/0"), 47 | ?assertMatch({eoi, [{empty_pass, "hello"}], _Trc}, 48 | rpc:call(RN, riak_pipe, example, [])). 49 | 50 | verify_example_transform([RN|_]) -> 51 | lager:info("Run riak_pipe:example_transform/0"), 52 | ?assertEqual({eoi, [{"generic transform", 55}], []}, 53 | rpc:call(RN, riak_pipe, example_transform, [])). 54 | 55 | verify_example_reduce([RN|_]) -> 56 | lager:info("Run riak_pipe:example_reduce/0"), 57 | {eoi, Res, []} = rpc:call(RN, riak_pipe, example_reduce, []), 58 | ?assertEqual([{"sum reduce", {a, [55]}}, 59 | {"sum reduce", {b, [155]}}], 60 | lists:sort(Res)). 61 | -------------------------------------------------------------------------------- /tests/repl_handoff_deadlock_aae.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %%% @copyright (C) 2015, Basho Technologies 22 | %%% @doc 23 | %%% riak_test for timing deadlock on riak_repl2_keylist_server:diff_bloom and riak_repl_aae_source:finish_sending_differences 24 | %%% which can occur when the owner VNode is handed off after the original monitor (MonRef) is created. Neither function 25 | %%% handles the {'DOWN', MonRef, process, VNodePid, normal} case (which happens when the node exits after handoff. 26 | %%% Note that this uses code from verify_counter_repl as its tests, as that seemed to be able to evoke the issue, even without intercepts 27 | %%% 28 | %%% Also tests fixes for riak_repl2_fscoordinator which used to cache the owner of an index at replication start, but those could change with handoff. 29 | %%% @end 30 | -module(repl_handoff_deadlock_aae). 31 | -behavior(riak_test). 32 | -export([confirm/0]). 33 | 34 | confirm() -> 35 | repl_handoff_deadlock_common:confirm(aae). -------------------------------------------------------------------------------- /tests/repl_handoff_deadlock_keylist.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %%% @copyright (C) 2015, Basho Technologies 22 | %%% @doc 23 | %%% riak_test for timing deadlock on riak_repl2_keylist_server:diff_bloom and riak_repl_aae_source:finish_sending_differences 24 | %%% which can occur when the owner VNode is handed off after the original monitor (MonRef) is created. Neither function 25 | %%% handles the {'DOWN', MonRef, process, VNodePid, normal} case (which happens when the node exits after handoff. 26 | %%% Note that this uses code from verify_counter_repl as its tests, as that seemed to be able to evoke the issue, even without intercepts 27 | %%% 28 | %%% Also tests fixes for riak_repl2_fscoordinator which used to cache the owner of an index at replication start, but those could change with handoff. 29 | %%% @end 30 | -module(repl_handoff_deadlock_keylist). 31 | -behavior(riak_test). 32 | -export([confirm/0]). 33 | 34 | confirm() -> 35 | repl_handoff_deadlock_common:confirm(keylist). -------------------------------------------------------------------------------- /tests/riak_rex.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2013 Basho Technologies, Inc. 4 | %% 5 | %% ------------------------------------------------------------------- 6 | -module(riak_rex). 7 | -behaviour(riak_test). 8 | -export([confirm/0]). 9 | -compile(export_all). 10 | -include_lib("eunit/include/eunit.hrl"). 11 | 12 | %% @doc riak_test entry point 13 | confirm() -> 14 | SetupData = setup(current), 15 | rex_test(SetupData), 16 | pass. 17 | 18 | setup(Type) -> 19 | deploy_node(Type). 20 | 21 | rex_test(Node) -> 22 | % validated we can get the rex pid on the node 23 | RexPid1 = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]), 24 | ?assertEqual(node(RexPid1), Node), 25 | % kill rex on the node and check that safe_rpc works 26 | kill_rex(Node), 27 | ErrorTuple = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]), 28 | ?assertEqual(ErrorTuple, {badrpc,rpc_process_down}), 29 | % restart rex 30 | supervisor:restart_child({kernel_sup, Node}, rex), 31 | RexPid2 = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]), 32 | ?assertEqual(node(RexPid2), Node). 33 | 34 | 35 | deploy_node(NumNodes, current) -> 36 | rt:deploy_nodes(NumNodes, conf()); 37 | deploy_node(_, mixed) -> 38 | Conf = conf(), 39 | rt:deploy_nodes([{current, Conf}, {previous, Conf}]). 40 | 41 | deploy_node(Type) -> 42 | NumNodes = rt_config:get(num_nodes, 1), 43 | 44 | lager:info("Deploy ~p node", [NumNodes]), 45 | Node = deploy_node(NumNodes, Type), 46 | lager:info("Node: ~p", [Node]), 47 | hd(Node). 48 | 49 | kill_rex(Node) -> 50 | ok = supervisor:terminate_child({kernel_sup, Node}, rex). 51 | 52 | conf() -> 53 | [ 54 | {riak_kv, 55 | [ 56 | {anti_entropy, {off, []}} 57 | ] 58 | } 59 | ]. 60 | -------------------------------------------------------------------------------- /tests/riak_shell_test_connecting.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(riak_shell_test_connecting). 21 | 22 | -behavior(riak_test). 23 | 24 | -include_lib("eunit/include/eunit.hrl"). 25 | 26 | -export([confirm/0]). 27 | 28 | -define(DONT_INCREMENT_PROMPT, false). 29 | 30 | %% we cant run the test in this process as it receives various messages 31 | %% and the running test interprets then as being messages to the shell 32 | confirm() -> 33 | Nodes = riak_shell_test_util:build_cluster(), 34 | lager:info("Built a cluster of ~p~n", [Nodes]), 35 | Self = self(), 36 | _Pid = spawn_link(fun() -> run_test(Self) end), 37 | riak_shell_test_util:loop(). 38 | 39 | run_test(Pid) -> 40 | State = riak_shell_test_util:shell_init(), 41 | lager:info("~n~nStart running the command set-------------------------", []), 42 | Cmds = [ 43 | %% 'connection prompt on' means you need to do unicode printing and stuff 44 | {run, 45 | "connection_prompt off;"}, 46 | {run, 47 | "show_cookie;"}, 48 | {run, 49 | "show_connection;"}, 50 | {run, 51 | "connect 'dev1@127.0.0.1';"}, 52 | {{match, "riak-shell is connected to: 'dev1@127.0.0.1' on port 10017"}, 53 | "show_connection;"} 54 | ], 55 | Result = riak_shell_test_util:run_commands(Cmds, State, 56 | ?DONT_INCREMENT_PROMPT), 57 | lager:info("Result is ~p~n", [Result]), 58 | lager:info("~n~n------------------------------------------------------", []), 59 | Pid ! Result. 60 | -------------------------------------------------------------------------------- /tests/riak_shell_test_connecting_error.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(riak_shell_test_connecting_error). 21 | 22 | -behavior(riak_test). 23 | 24 | -include_lib("eunit/include/eunit.hrl"). 25 | 26 | -export([confirm/0]). 27 | 28 | -define(DONT_INCREMENT_PROMPT, false). 29 | 30 | %% we cant run the test in this process as it receives various messages 31 | %% and the running test interprets then as being messages to the shell 32 | confirm() -> 33 | Nodes = riak_shell_test_util:build_cluster(), 34 | lager:info("Built a cluster of ~p~n", [Nodes]), 35 | Self = self(), 36 | _Pid = spawn_link(fun() -> run_test(Self) end), 37 | riak_shell_test_util:loop(). 38 | 39 | run_test(Pid) -> 40 | State = riak_shell_test_util:shell_init(), 41 | lager:info("~n~nStart running the command set-------------------------", []), 42 | Cmds = [ 43 | %% 'connection prompt on' means you need to do unicode printing and stuff 44 | {run, 45 | "connection_prompt off;"}, 46 | {run, 47 | "show_cookie;"}, 48 | {run, 49 | "show_connection;"}, 50 | {{match, "Connection to 'made up guff' failed"}, 51 | "connect 'made up guff';"} 52 | ], 53 | Result = riak_shell_test_util:run_commands(Cmds, State, 54 | ?DONT_INCREMENT_PROMPT), 55 | lager:info("Result is ~p~n", [Result]), 56 | lager:info("~n~n------------------------------------------------------", []), 57 | Pid ! Result. 58 | -------------------------------------------------------------------------------- /tests/riak_shell_test_reconnecting.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(riak_shell_test_reconnecting). 21 | 22 | -behavior(riak_test). 23 | 24 | -include_lib("eunit/include/eunit.hrl"). 25 | 26 | -export([confirm/0]). 27 | 28 | -define(DONT_INCREMENT_PROMPT, false). 29 | 30 | %% we cant run the test in this process as it receives various messages 31 | %% and the running test interprets then as being messages to the shell 32 | confirm() -> 33 | Nodes = riak_shell_test_util:build_cluster(), 34 | lager:info("Built a cluster of ~p~n", [Nodes]), 35 | Self = self(), 36 | _Pid = spawn_link(fun() -> run_test(Self) end), 37 | riak_shell_test_util:loop(). 38 | 39 | run_test(Pid) -> 40 | State = riak_shell_test_util:shell_init(), 41 | lager:info("~n~nStart running the command set-------------------------", []), 42 | Cmds = [ 43 | %% 'connection prompt on' means you need to do unicode printing and stuff 44 | {run, 45 | "connection_prompt off;"}, 46 | {run, 47 | "show_cookie;"}, 48 | {run, 49 | "show_connection;"}, 50 | {run, 51 | "reconnect;"}, 52 | {{match, "riak-shell is connected to: 'dev1@127.0.0.1' on port 10017"}, 53 | "show_connection;"} 54 | ], 55 | Result = riak_shell_test_util:run_commands(Cmds, State, 56 | ?DONT_INCREMENT_PROMPT), 57 | lager:info("Result is ~p~n", [Result]), 58 | lager:info("~n~n------------------------------------------------------", []), 59 | Pid ! Result. 60 | 61 | -------------------------------------------------------------------------------- /tests/rt_basic_test.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(rt_basic_test). 21 | -behavior(riak_test). 22 | -export([confirm/0]). 23 | 24 | confirm() -> 25 | lager:info("Deploy some nodes"), 26 | Nodes = rt:deploy_nodes(2), 27 | lager:info("Stop the nodes"), 28 | [rt:stop(Node) || Node <- Nodes], 29 | pass. 30 | -------------------------------------------------------------------------------- /tests/test_cluster.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(test_cluster). 21 | -behavior(riak_test). 22 | -export([confirm/0]). 23 | -include_lib("eunit/include/eunit.hrl"). 24 | 25 | confirm() -> 26 | Config = [{riak_search, [{enabled, true}]}], 27 | rt:build_cluster(4, Config), 28 | ?assert(false), 29 | fail. -------------------------------------------------------------------------------- /tests/ts.README: -------------------------------------------------------------------------------- 1 | Time Series tests are organised in sets 2 | ts_simple 3 | ts_cluster 4 | ts_degraded 5 | etc, etc 6 | 7 | Basically, if a ts_simple type test fails then there SHOULD also be failures 8 | in ts_cluster, ts_degraded series tests as well 9 | 10 | Basically fix the ts_simple tests first, and that 'should' fix a lot of 11 | ts_cluster, ts_degraded etc tests 12 | 13 | If you have a failure in say a ts_cluster test, but no failures in ts_degraded that 14 | indicates you might not have enough ts_degraded, ts_etc tests written, consider 15 | extending the test suite -------------------------------------------------------------------------------- /tests/ts_cluster_activate_table_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_cluster_activate_table_pass_1). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = ts_data:get_ddl(), 31 | Expected = ok, 32 | Cluster = ts_setup:start_cluster(3), 33 | Table = ts_data:get_default_bucket(), 34 | {ok, _} = ts_setup:create_bucket_type(Cluster, DDL, Table), 35 | Got = ts_setup:activate_bucket_type(Cluster, Table), 36 | ?assertEqual(Expected, Got), 37 | pass. 38 | -------------------------------------------------------------------------------- /tests/ts_cluster_aggregation.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_cluster_aggregation). 22 | 23 | -export([confirm/0]). 24 | 25 | % Test basic aggregation functionality on larger and broken clusters 26 | 27 | confirm() -> 28 | ts_simple_aggregation:verify_aggregation(multiple), 29 | pass. -------------------------------------------------------------------------------- /tests/ts_cluster_create_table_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_cluster_create_table_pass_1). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = ts_data:get_ddl(), 31 | Expected = ok, 32 | Cluster = ts_setup:start_cluster(3), 33 | Table = ts_data:get_default_bucket(), 34 | {Got, _} = ts_setup:create_bucket_type(Cluster, DDL, Table), 35 | ?assertEqual(Expected, Got), 36 | pass. 37 | -------------------------------------------------------------------------------- /tests/ts_cluster_put_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_cluster_put_pass_1). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | confirm() -> 30 | 31 | Table = ts_data:get_default_bucket(), 32 | DDL = ts_data:get_ddl(), 33 | Obj = [ts_data:get_valid_obj()], 34 | Cluster = ts_setup:start_cluster(3), 35 | {ok, _} = ts_setup:create_bucket_type(Cluster, DDL, Table), 36 | ok = ts_setup:activate_bucket_type(Cluster, Table), 37 | Expected = ok, 38 | Got = ts_ops:put(Cluster, Table, Obj), 39 | ?assertEqual(Expected, Got), 40 | pass. 41 | 42 | -------------------------------------------------------------------------------- /tests/ts_cluster_riak_shell_regression_log.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(ts_cluster_riak_shell_regression_log). 21 | 22 | -behavior(riak_test). 23 | 24 | -include_lib("eunit/include/eunit.hrl"). 25 | 26 | -export([confirm/0]). 27 | 28 | -define(DONT_INCREMENT_PROMPT, false). 29 | -define(LOG_FILE, "priv/riak_shell/riak_shell_regression1.log"). 30 | 31 | %% we cant run the test in this process as it receives various messages 32 | %% and the running test interprets then as being messages to the shell 33 | confirm() -> 34 | Nodes = ts_setup:start_cluster(3), 35 | _Conn = ts_setup:conn(Nodes), 36 | lager:info("Built a cluster of ~p~n", [Nodes]), 37 | Self = self(), 38 | _Pid = spawn_link(fun() -> load_log_file(Self) end), 39 | Got1 = riak_shell_test_util:loop(), 40 | Result = ts_data:assert("Regression Log", pass, Got1), 41 | ts_data:results([ 42 | Result 43 | ]), 44 | pass. 45 | 46 | load_log_file(Pid) -> 47 | State = riak_shell_test_util:shell_init(), 48 | lager:info("~n~nLoad the log -------------------------", []), 49 | Cmds = [ 50 | {{match, "No Regression Errors."}, 51 | ts_data:flat_format("regression_log \"~s\";", [?LOG_FILE])} 52 | ], 53 | Result = riak_shell_test_util:run_commands(Cmds, State, 54 | ?DONT_INCREMENT_PROMPT), 55 | lager:info("~n~n------------------------------------------------------", []), 56 | Pid ! Result. 57 | -------------------------------------------------------------------------------- /tests/ts_cluster_select_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_cluster_select_pass_1). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | 31 | DDL = ts_data:get_ddl(), 32 | Data = ts_data:get_valid_select_data(), 33 | Qry = ts_data:get_valid_qry(), 34 | Expected = {ok, { 35 | ts_data:get_cols(), 36 | ts_data:exclusive_result_from_data(Data, 2, 9)}}, 37 | 38 | Cluster = ts_setup:start_cluster(3), 39 | Table = ts_data:get_default_bucket(), 40 | ts_setup:create_bucket_type(Cluster, DDL, Table), 41 | ts_setup:activate_bucket_type(Cluster, Table), 42 | ok = ts_ops:put(Cluster, Table, Data), 43 | Got = ts_ops:query(Cluster, Qry), 44 | ?assertEqual(Expected, Got), 45 | pass. 46 | -------------------------------------------------------------------------------- /tests/ts_cluster_select_pass_2.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %% @doc A module to test riak_ts basic create bucket/put/select cycle, 21 | %% spanning time quanta. 22 | 23 | -module(ts_cluster_select_pass_2). 24 | 25 | -behavior(riak_test). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | -export([confirm/0]). 30 | 31 | confirm() -> 32 | DDL = ts_data:get_ddl(), 33 | Data = ts_data:get_valid_select_data_spanning_quanta(), 34 | Qry = ts_data:get_valid_qry_spanning_quanta(), 35 | Expected = {ok, { 36 | ts_data:get_cols(), 37 | ts_data:exclusive_result_from_data(Data, 1, 10)}}, 38 | Cluster = ts_setup:start_cluster(3), 39 | Table = ts_data:get_default_bucket(), 40 | ts_setup:create_bucket_type(Cluster, DDL, Table), 41 | ts_setup:activate_bucket_type(Cluster, Table), 42 | ok = ts_ops:put(Cluster, Table, Data), 43 | Got = ts_ops:query(Cluster, Qry), 44 | ?assertEqual(Expected, Got), 45 | pass. 46 | -------------------------------------------------------------------------------- /tests/ts_cluster_select_pass_3_sorted_on_key.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %%% This test asserts that results for small queries are 22 | %%% returned in key-sorted order 23 | 24 | -module(ts_cluster_select_pass_3_sorted_on_key). 25 | 26 | -behavior(riak_test). 27 | 28 | -include_lib("eunit/include/eunit.hrl"). 29 | 30 | -export([confirm/0]). 31 | 32 | confirm() -> 33 | 34 | DDL = ts_data:get_ddl(), 35 | Data = ts_data:get_valid_select_data(), 36 | ShuffledData = shuffle_list(Data), 37 | Qry = ts_data:get_valid_qry(), 38 | Expected = {ok, { 39 | ts_data:get_cols(), 40 | ts_data:exclusive_result_from_data(Data, 2, 9)}}, 41 | % write the shuffled TS records but expect the 42 | % unshuffled records 43 | Cluster = ts_setup:start_cluster(3), 44 | Table = ts_data:get_default_bucket(), 45 | ts_setup:create_bucket_type(Cluster, DDL, Table), 46 | ts_setup:activate_bucket_type(Cluster, Table), 47 | ok = ts_ops:put(Cluster, Table, ShuffledData), 48 | Got = ts_ops:query(Cluster, Qry), 49 | 50 | ?assertEqual(Expected, Got), 51 | pass. 52 | 53 | %% 54 | shuffle_list(List) -> 55 | random:seed(), 56 | RSeqd1 = [{random:uniform(), E} || E <- List], 57 | RSeqd2 = lists:sort(RSeqd1), 58 | [E || {_, E} <- RSeqd2]. 59 | -------------------------------------------------------------------------------- /tests/ts_cluster_unicode.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %% @doc A module to test riak_ts basic create bucket/put/select cycle 21 | %% with UTF-8 values 22 | 23 | -module(ts_cluster_unicode). 24 | -behavior(riak_test). 25 | -export([confirm/0]). 26 | -include_lib("eunit/include/eunit.hrl"). 27 | 28 | -define(PVAL_P1, <<"Αισθητήρας"/utf8>>). 29 | -define(PVAL_P2, <<"¡™£¢∞§¶•ªº"/utf8>>). 30 | 31 | confirm() -> 32 | ts_cluster_comprehensive:run_tests(?PVAL_P1, ?PVAL_P2). 33 | -------------------------------------------------------------------------------- /tests/ts_degraded_activate_table_fail_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %% @doc A module to test riak_ts try to create a bucket type when one 21 | %% node is down. 22 | 23 | -module(ts_degraded_activate_table_fail_1). 24 | 25 | -behavior(riak_test). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | -export([confirm/0]). 30 | 31 | confirm() -> 32 | DDL = ts_data:get_ddl(), 33 | Expected = {ok, "GeoCheckin has been created but cannot be activated yet\n"}, 34 | 35 | [_Node|Rest]= Cluster = ts_setup:start_cluster(3), 36 | ok = rt:stop(hd(tl(Rest))), 37 | Table = ts_data:get_default_bucket(), 38 | {ok,_} = ts_setup:create_bucket_type(Cluster, DDL, Table), 39 | Got = ts_setup:activate_bucket_type(Cluster, Table), 40 | ?assertEqual(Expected, Got), 41 | pass. 42 | -------------------------------------------------------------------------------- /tests/ts_degraded_aggregation.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_degraded_aggregation). 22 | 23 | -export([confirm/0]). 24 | 25 | % Test basic aggregation functionality on larger and broken clusters 26 | 27 | confirm() -> 28 | ts_simple_aggregation:verify_aggregation(delayed_one_down), 29 | pass. 30 | -------------------------------------------------------------------------------- /tests/ts_degraded_select_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %% @doc A module to test riak_ts basic create bucket/put/select cycle, 21 | %% with a node down. 22 | 23 | -module(ts_degraded_select_pass_1). 24 | 25 | -behavior(riak_test). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | -export([confirm/0]). 30 | 31 | confirm() -> 32 | OrigCluster = rt:deploy_nodes(3), 33 | OrigClients = [rt:pbc(Node) || Node <- OrigCluster], 34 | OrigCCNN = lists:zip(OrigCluster, OrigClients), 35 | ok = rt:join_cluster(OrigCluster), 36 | 37 | DDL = ts_data:get_ddl(), 38 | ?assertEqual({ok, {[], []}}, riakc_ts:query(hd(OrigClients), DDL)), 39 | 40 | Table = ts_data:get_default_bucket(), 41 | Data = ts_data:get_valid_select_data(), 42 | ?assertEqual(ok, riakc_ts:put(hd(OrigClients), Table, Data)), 43 | 44 | Qry = ts_data:get_valid_qry(0, 11), 45 | 46 | ok = check_data(OrigCCNN, Qry, Data), 47 | 48 | {NodeOut, _} = lists:nth(2, OrigCCNN), 49 | ok = rt:leave(NodeOut), 50 | DegradedCluster = OrigCluster -- [NodeOut], 51 | DegradedCCNN = lists:keydelete(NodeOut, 1, OrigCCNN), 52 | ok = rt:wait_until_no_pending_changes(DegradedCluster), 53 | ok = check_data(DegradedCCNN, Qry, Data), 54 | 55 | pass. 56 | 57 | check_data(CCNN, Qry, Expected) -> 58 | lists:foreach( 59 | fun({Node, Client}) -> 60 | {ok, {_Cols, GotRows0}} = riakc_ts:query(Client, Qry), 61 | GotRows = lists:sort(GotRows0), 62 | io:format("Got ~b records at ~p\n", [length(GotRows), Node]), 63 | ?assertEqual(Expected, GotRows) 64 | end, 65 | CCNN). 66 | -------------------------------------------------------------------------------- /tests/ts_qbuf_util.hrl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -define(TABLE, "t1"). 22 | -define(TIMEBASE, (5*1000*1000)). 23 | -define(LIFESPAN, 500). 24 | -define(LIFESPAN_EXTRA, 510). 25 | -define(WHERE_FILTER_A, <<"A00001">>). 26 | -define(WHERE_FILTER_B, <<"B">>). 27 | -define(ORDBY_COLS, ["a", "b", "c", "d", "e", undefined]). 28 | 29 | %% error codes as defined in riak_kv_ts_svc.erl 30 | -define(E_SUBMIT, 1001). 31 | -define(E_SELECT_RESULT_TOO_BIG, 1022). 32 | -define(E_QBUF_CREATE_ERROR, 1023). 33 | -define(E_QBUF_LDB_ERROR, 1024). 34 | -define(E_QUANTA_LIMIT, 1025). 35 | -define(E_QBUF_INTERNAL_ERROR, 1027). 36 | -------------------------------------------------------------------------------- /tests/ts_simple_activate_table_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_activate_table_pass_1). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = ts_data:get_ddl(), 31 | Expected = ok, 32 | Cluster = ts_setup:start_cluster(1), 33 | Table = ts_data:get_default_bucket(), 34 | {ok,_} = ts_setup:create_bucket_type(Cluster, DDL, Table), 35 | Got = ts_setup:activate_bucket_type(Cluster, Table), 36 | ?assertEqual(Expected, Got), 37 | pass. 38 | -------------------------------------------------------------------------------- /tests/ts_simple_blob.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_blob). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | get_ddl(Table) -> 30 | "CREATE TABLE " ++ Table ++ " (" 31 | " name varchar not null," 32 | " firmware blob not null," 33 | " version sint64 not null," 34 | " time timestamp not null," 35 | " weather varchar," 36 | " PRIMARY KEY ((name, firmware, version, quantum(time, 15, 'm')), " 37 | " name, firmware, version, time))". 38 | 39 | confirm() -> 40 | Table = "MyBlob", 41 | DDL = get_ddl(Table), 42 | Data = [{<<"fred">>, <<0, 1, 2, 34>>, 5, 1, <<"rainy">>}, 43 | {<<"fred">>, <<0, 1, 2, 34>>, 5, 3, <<"snowy">>}, 44 | {<<"fred">>, <<0, 1, 2, 34>>, 5, 9, <<"generically wet">>}], 45 | Headers = [{<<"name">>, varchar}, 46 | {<<"firmware">>, blob}, 47 | {<<"version">>, sint64}, 48 | {<<"time">>, timestamp}, 49 | {<<"weather">>, varchar}], 50 | 51 | Qry = "select * from " ++ Table ++ " where time > 0 and time < 50 and name = 'fred' and version = 5 and firmware = 0x00010222", 52 | Expected = 53 | {ok, {Headers, Data}}, 54 | 55 | Cluster = ts_setup:start_cluster(1), 56 | ts_setup:create_bucket_type(Cluster, DDL, Table), 57 | ts_setup:activate_bucket_type(Cluster, Table), 58 | ts_ops:put(Cluster, Table, Data), 59 | Got = ts_ops:query(Cluster, Qry, [{datatypes, true}]), 60 | ?assertEqual(Expected, Got), 61 | pass. 62 | -------------------------------------------------------------------------------- /tests/ts_simple_create_table_already_created.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_create_table_already_created). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | %% 30 | %% should error if you try and create a table twice 31 | %% 32 | 33 | confirm() -> 34 | DDL = ts_data:get_ddl(), 35 | Cluster = ts_setup:start_cluster(1), 36 | Expected1 = ok, 37 | Table = ts_data:get_default_bucket(), 38 | {ok,_} = ts_setup:create_bucket_type(Cluster, DDL, Table), 39 | Got1 = ts_setup:activate_bucket_type(Cluster, Table), 40 | ?assertEqual(Expected1, Got1), 41 | 42 | Expected2 = 43 | {ok, 44 | "Error creating bucket type GeoCheckin:\n" 45 | "already_active\n"}, 46 | Got2 = ts_setup:create_bucket_type(Cluster, DDL, Table), 47 | ?assertEqual(Expected2, Got2), 48 | pass. 49 | -------------------------------------------------------------------------------- /tests/ts_simple_create_table_dup_primary_key.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_create_table_dup_primary_key). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = 31 | "CREATE TABLE GeoCheckin (" 32 | " myfamily varchar not null," 33 | " myseries varchar not null," 34 | " time timestamp not null," 35 | " weather varchar not null," 36 | " temperature double," 37 | " PRIMARY KEY ((myfamily, myfamily, quantum(time, 15, 'm'))," 38 | " myfamily, myfamily, time))", 39 | Table = ts_data:get_default_bucket(), 40 | Cluster = ts_setup:start_cluster(1), 41 | {ok, Got} = ts_setup:create_bucket_type(Cluster, DDL, Table), 42 | ?assertNotEqual(0, string:str(Got, "Primary key has duplicate fields")), 43 | pass. 44 | -------------------------------------------------------------------------------- /tests/ts_simple_create_table_no_primary_key.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_create_table_no_primary_key). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = 32 | "CREATE TABLE GeoCheckin (" 33 | " myfamily varchar not null," 34 | " myseries varchar not null," 35 | " time timestamp not null," 36 | " weather varchar not null," 37 | " temperature double)", 38 | Cluster = ts_setup:start_cluster(1), 39 | {ok, Got} = ts_setup:create_bucket_type(Cluster, DDL, Table), 40 | ?assertNotEqual(0, string:str(Got, "Missing primary key")), 41 | pass. 42 | -------------------------------------------------------------------------------- /tests/ts_simple_create_table_not_null_pk_fields.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_create_table_not_null_pk_fields). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = 32 | "CREATE TABLE GeoCheckin (" 33 | " myfamily varchar not null," 34 | " myseries varchar ," 35 | " time timestamp not null," 36 | " weather varchar not null," 37 | " temperature double," 38 | " PRIMARY KEY ((myfamily, myseries, quantum(time, 15, 'm'))," 39 | " myfamily, myseries, time))", 40 | Cluster = ts_setup:start_cluster(1), 41 | {ok, Got} = ts_setup:create_bucket_type(Cluster, DDL, Table), 42 | ?assertNotEqual(0, string:str(Got, "Primary key has 'null' fields")), 43 | pass. 44 | -------------------------------------------------------------------------------- /tests/ts_simple_create_table_pass_1.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_create_table_pass_1). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Expected = 33 | {ok, 34 | "GeoCheckin created\n" 35 | "\n" 36 | "WARNING: After activating GeoCheckin, nodes in this cluster\n" 37 | "can no longer be downgraded to a version of Riak prior to 2.0\n"}, 38 | 39 | Cluster = ts_setup:start_cluster(1), 40 | Got = ts_setup:create_bucket_type(Cluster, DDL, Table), 41 | ?assertEqual(Expected, Got), 42 | pass. 43 | -------------------------------------------------------------------------------- /tests/ts_simple_create_table_split_key.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_create_table_split_key). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = 31 | "CREATE TABLE GeoCheckin (" 32 | " myfamily varchar not null," 33 | " myseries varchar not null," 34 | " time timestamp not null," 35 | " weather varchar not null," 36 | " temperature double," 37 | " PRIMARY KEY ((myfamily, myseries, quantum(time, 15, 'm'))," 38 | " time, myfamily, myseries, temperature))", 39 | Table = ts_data:get_default_bucket(), 40 | Cluster = ts_setup:start_cluster(1), 41 | {ok, Got} = ts_setup:create_bucket_type(Cluster, DDL, Table), 42 | ?assertNotEqual(0, string:str(Got, "Local key does not match primary key")), 43 | pass. 44 | -------------------------------------------------------------------------------- /tests/ts_simple_describe_table.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_describe_table). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | %% Test basic table description 30 | 31 | confirm() -> 32 | Table = ts_data:get_default_bucket(), 33 | DDL = ts_data:get_ddl(), 34 | Qry = "DESCRIBE " ++ Table, 35 | Expected = 36 | {ok, {[<<"Column">>,<<"Type">>,<<"Nullable">>,<<"Partition Key">>, <<"Local Key">>, <<"Interval">>, <<"Unit">>, <<"Sort Order">>], 37 | [{<<"myfamily">>, <<"varchar">>, false, 1, 1, [], [], []}, 38 | {<<"myseries">>, <<"varchar">>, false, 2, 2, [], [], []}, 39 | {<<"time">>, <<"timestamp">>, false, 3, 3, 15, <<"m">>, []}, 40 | {<<"weather">>, <<"varchar">>, false, [], [], [], [], []}, 41 | {<<"temperature">>,<<"double">>, true, [], [], [], [], []}]}}, 42 | 43 | Cluster = ts_setup:start_cluster(1), 44 | ts_setup:create_bucket_type(Cluster, DDL, Table), 45 | ts_setup:activate_bucket_type(Cluster, Table), 46 | Got = ts_ops:query(Cluster, Qry), 47 | 48 | ?assertEqual(Expected, Got), 49 | pass. 50 | -------------------------------------------------------------------------------- /tests/ts_simple_get.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_get). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | %% Test gets which return no data, i.e., not found. 30 | 31 | confirm() -> 32 | Table = ts_data:get_default_bucket(), 33 | DDL = ts_data:get_ddl(), 34 | Data = ts_data:get_valid_select_data(), 35 | DataRow = hd(Data), 36 | 37 | Cluster = ts_setup:start_cluster(1), 38 | ts_setup:create_bucket_type(Cluster, DDL, Table), 39 | ts_setup:activate_bucket_type(Cluster, Table), 40 | ts_ops:put(Cluster, Table, Data), 41 | Key = lists:sublist(tuple_to_list(DataRow), 3), 42 | Expected = {ts_data:get_cols(),[DataRow]}, 43 | {ok, Got} = ts_ops:get(Cluster, Table, Key), 44 | ?assertEqual(Expected, Got), 45 | pass. 46 | 47 | -------------------------------------------------------------------------------- /tests/ts_simple_get_not_found.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_get_not_found). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | %% Test gets which return no data, i.e., not found. 30 | 31 | confirm() -> 32 | Table = ts_data:get_default_bucket(), 33 | DDL = ts_data:get_ddl(), 34 | Expected = {[],[]}, 35 | Cluster = ts_setup:start_cluster(1), 36 | ts_setup:create_bucket_type(Cluster, DDL, Table), 37 | ts_setup:activate_bucket_type(Cluster, Table), 38 | {ok, Got} = ts_ops:get(Cluster, Table, [<<"nada">>, <<"nope">>, 10]), 39 | ?assertEqual(Expected, Got), 40 | pass. 41 | -------------------------------------------------------------------------------- /tests/ts_simple_insert_incorrect_columns.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_insert_incorrect_columns). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Data = ts_data:get_valid_select_data(), 33 | TooMuchData = [list_to_tuple(tuple_to_list(Row) ++ [<<"rubbish">>]) || Row <- Data], 34 | %% remove the last 2 columns to chomp into a not null field because it is 35 | %% completely valid to drop the final 1 column that is nullable. 36 | TooLittleData = [list_to_tuple(lists:reverse(tl(tl(lists:reverse(tuple_to_list(Row)))))) || Row <- Data], 37 | WrongColumns = TooMuchData ++ TooLittleData, 38 | Columns = ts_data:get_cols(), 39 | 40 | Cluster = ts_setup:start_cluster(1), 41 | ?assertEqual({ok, {[], []}}, ts_ops:query(Cluster, DDL)), 42 | 43 | Fn = fun(Datum, Acc) -> 44 | [ts_ops:insert(Cluster, Table, Columns, Datum) | Acc] 45 | end, 46 | Got2 = lists:reverse(lists:foldl(Fn, [], WrongColumns)), 47 | ?assertEqual( 48 | lists:duplicate(length(TooMuchData), 49 | {error,{1018,<<"too many values in row index(es) 1">>}}) ++ 50 | lists:duplicate(length(TooLittleData), 51 | {error,{1003,<<"Invalid data found at row index(es) 1">>}}), 52 | Got2 53 | ), 54 | pass. 55 | -------------------------------------------------------------------------------- /tests/ts_simple_latin1_create_table_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %% Test for creating a latin1 table name. This should fail 22 | %% because of mochijson decoding. 23 | 24 | -module(ts_simple_latin1_create_table_not_allowed). 25 | 26 | -behavior(riak_test). 27 | 28 | -export([confirm/0]). 29 | 30 | confirm() -> 31 | TableDef = 32 | "CREATE TABLE mytãble (" 33 | "family VARCHAR NOT NULL, " 34 | "series VARCHAR NOT NULL, " 35 | "time TIMESTAMP NOT NULL, " 36 | "PRIMARY KEY ((family, series, quantum(time, 15, 's')), family, series, time))", 37 | 38 | Cluster = ts_setup:start_cluster(1), 39 | {ok, Out} = ts_setup:create_bucket_type(Cluster, TableDef, "mytãble"), 40 | case binary:match(list_to_binary(Out), <<"invalid json">>) of 41 | nomatch -> 42 | {error, "Expecting this to fail, check implications for riak_ql"}; 43 | _ -> 44 | pass 45 | end. 46 | -------------------------------------------------------------------------------- /tests/ts_simple_put.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_put). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Obj = [ts_data:get_valid_obj()], 33 | 34 | Cluster = ts_setup:start_cluster(1), 35 | ts_setup:create_bucket_type(Cluster, DDL, Table), 36 | ts_setup:activate_bucket_type(Cluster, Table), 37 | Got = ts_ops:put(Cluster, Table, Obj), 38 | ?assertEqual(ok, Got), 39 | pass. 40 | -------------------------------------------------------------------------------- /tests/ts_simple_put_all_datatypes.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_put_all_datatypes). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(big), 32 | N = 10, 33 | Data = ts_data:get_valid_big_data(N), 34 | 35 | Cluster = ts_setup:start_cluster(1), 36 | ts_setup:create_bucket_type(Cluster, DDL, Table), 37 | ts_setup:activate_bucket_type(Cluster, Table), 38 | Got = ts_ops:put(Cluster, Table, Data), 39 | ?assertEqual(ok, Got), 40 | pass. 41 | 42 | -------------------------------------------------------------------------------- /tests/ts_simple_put_bad_date.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_put_bad_date). 22 | 23 | -behavior(riak_test). 24 | 25 | -export([confirm/0]). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Obj = 33 | [{ts_data:get_varchar(), 34 | ts_data:get_varchar(), 35 | <<"abc">>, 36 | ts_data:get_varchar(), 37 | ts_data:get_float()}], 38 | Expected = {error, {1003, <<"Invalid data found at row index(es) 1">>}}, 39 | 40 | Cluster = ts_setup:start_cluster(1), 41 | ts_setup:create_bucket_type(Cluster, DDL, Table), 42 | ts_setup:activate_bucket_type(Cluster, Table), 43 | Got = ts_ops:put(Cluster, Table, Obj), 44 | ?assertEqual(Expected, Got), 45 | pass. 46 | -------------------------------------------------------------------------------- /tests/ts_simple_put_invalid_data.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_put_invalid_data). 22 | 23 | %% 24 | %% this test tries to write well structured data that doesn't 25 | %% meet the criteria defined in the DDL into a bucket 26 | %% 27 | 28 | -behavior(riak_test). 29 | 30 | -export([confirm/0]). 31 | 32 | -include_lib("eunit/include/eunit.hrl"). 33 | 34 | confirm() -> 35 | Table = ts_data:get_default_bucket(), 36 | DDL = ts_data:get_ddl(), 37 | 38 | Cluster = ts_setup:start_cluster(1), 39 | Conn = ts_setup:conn(Cluster), 40 | ts_setup:create_bucket_type(Cluster, DDL, Table), 41 | ts_setup:activate_bucket_type(Cluster, Table), 42 | 43 | ValidObj = ts_data:get_valid_obj(), 44 | InvalidObj = ts_data:get_invalid_obj(), 45 | ShortObj = ts_data:get_short_obj(), 46 | LongObj = ts_data:get_long_obj(), 47 | 48 | Expected1 = {error, {1003, <<"Invalid data found at row index(es) 1">>}}, 49 | Expected2 = {error, {1003, <<"Invalid data found at row index(es) 2">>}}, 50 | Got = riakc_ts:put(Conn, Table, [InvalidObj]), 51 | ?assertEqual(Expected1, Got), 52 | 53 | Got2 = riakc_ts:put(Conn, Table, [ShortObj]), 54 | ?assertEqual(Expected1, Got2), 55 | 56 | Got3 = riakc_ts:put(Conn, Table, [LongObj]), 57 | ?assertEqual(Expected1, Got3), 58 | 59 | Got4 = riakc_ts:put(Conn, Table, [ValidObj, InvalidObj]), 60 | ?assertEqual(Expected2, Got4), 61 | 62 | Got5 = riakc_ts:put(Conn, Table, [ValidObj, ShortObj]), 63 | ?assertEqual(Expected2, Got5), 64 | 65 | Got6 = riakc_ts:put(Conn, Table, [ValidObj, LongObj]), 66 | ?assertEqual(Expected2, Got6), 67 | pass. 68 | -------------------------------------------------------------------------------- /tests/ts_simple_put_non_existent_bucket.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_put_non_existent_bucket). 22 | 23 | %% 24 | %% this test tries to write to a non-existent bucket 25 | %% 26 | 27 | -behavior(riak_test). 28 | 29 | -export([confirm/0]). 30 | 31 | -include_lib("eunit/include/eunit.hrl"). 32 | 33 | confirm() -> 34 | Table = ts_data:get_default_bucket(), 35 | Obj = [ts_data:get_invalid_obj()], 36 | 37 | Cluster = ts_setup:start_cluster(1), 38 | 39 | Got = ts_ops:put(Cluster, Table, Obj), 40 | ?assertMatch({error, _}, Got), 41 | pass. 42 | 43 | 44 | -------------------------------------------------------------------------------- /tests/ts_simple_select.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Data = ts_data:get_valid_select_data(), 33 | Qry = ts_data:get_valid_qry(), 34 | Expected = 35 | {ok, {ts_data:get_cols(small), 36 | ts_data:exclusive_result_from_data(Data, 2, 9)}}, 37 | 38 | Cluster = ts_setup:start_cluster(1), 39 | ts_setup:create_bucket_type(Cluster, DDL, Table), 40 | ts_setup:activate_bucket_type(Cluster, Table), 41 | ts_ops:put(Cluster, Table, Data), 42 | Got = ts_ops:query(Cluster, Qry), 43 | ?assertEqual(Expected, Got), 44 | pass. 45 | -------------------------------------------------------------------------------- /tests/ts_simple_select_compare_two_fields_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_compare_two_fields_not_allowed). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | %%% Comparing fields should yield an error message. 30 | %%% FIXME failing because of RTS-388 31 | 32 | confirm() -> 33 | Table = ts_data:get_default_bucket(), 34 | DDL = ts_data:get_ddl(), 35 | Data = ts_data:get_valid_select_data(), 36 | Qry = 37 | "SELECT * FROM GeoCheckin " 38 | "WHERE time > 1 and time < 10 " 39 | "AND myfamily = 'fa2mily1' " 40 | "AND myseries ='seriesX' " 41 | "AND weather = myseries", 42 | Expected = 43 | {error, {1001, "Comparing or otherwise operating on two fields is not supported"}}, 44 | 45 | Cluster = ts_setup:start_cluster(1), 46 | ts_setup:create_bucket_type(Cluster, DDL, Table), 47 | ts_setup:activate_bucket_type(Cluster, Table), 48 | ts_ops:put(Cluster, Table, Data), 49 | Got = ts_ops:query(Cluster, Qry), 50 | ts_data:assert_error_regex("No upper bound", Expected, Got). 51 | 52 | -------------------------------------------------------------------------------- /tests/ts_simple_select_double_in_key.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_double_in_key). 22 | -behavior(riak_test). 23 | 24 | -include_lib("eunit/include/eunit.hrl"). 25 | 26 | -export([confirm/0]). 27 | 28 | %% 29 | confirm() -> 30 | TableDef = 31 | "CREATE TABLE GeoCheckin (" 32 | " myfamily double not null," 33 | " myseries varchar not null," 34 | " time timestamp not null," 35 | " PRIMARY KEY ((myfamily, myseries, quantum(time, 15, 'm')), " 36 | " myfamily, myseries, time))", 37 | Query = 38 | "SELECT * FROM GeoCheckin " 39 | "WHERE time >= 1 AND time <= 10 " 40 | "AND myseries = 'series' " 41 | "AND myfamily = 13.777744543543500002342342342342342340000000017777445435435000023423423423423423400000000177774454354350000234234234234234234000000001", 42 | Table = ts_data:get_default_bucket(), 43 | Data = input_data(), 44 | Expected = {ok, {[<<"myfamily">>, <<"myseries">>, <<"time">>], input_data()}}, 45 | 46 | Cluster = ts_setup:start_cluster(1), 47 | ts_setup:create_bucket_type(Cluster, TableDef, Table), 48 | ts_setup:activate_bucket_type(Cluster, Table), 49 | ts_ops:put(Cluster, Table, Data), 50 | Got = ts_ops:query(Cluster, Query), 51 | ?assertEqual(Expected, Got), 52 | pass. 53 | 54 | %% 55 | input_data() -> 56 | Times = lists:seq(1, 10), 57 | [{13.777744543543500002342342342342342340000000017777445435435000023423423423423423400000000177774454354350000234234234234234234000000001, <<"series">>, T} || T <- Times]. 58 | 59 | -------------------------------------------------------------------------------- /tests/ts_simple_select_incompatible_type_float_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_incompatible_type_float_not_allowed). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Data = ts_data:get_valid_select_data(), 33 | Qry = 34 | "SELECT * FROM GeoCheckin " 35 | "WHERE time > 1 AND time < 10 " 36 | "AND myfamily = 'family1' " 37 | "AND myseries = 1.0", % error, should be a varchar 38 | Expected = 39 | {error, 40 | {1001, 41 | <<".*incompatible_type: field myseries with type varchar cannot be compared to type float in where clause.">>}}, 42 | 43 | Cluster = ts_setup:start_cluster(1), 44 | ts_setup:create_bucket_type(Cluster, DDL, Table), 45 | ts_setup:activate_bucket_type(Cluster, Table), 46 | ts_ops:put(Cluster, Table, Data), 47 | Got = ts_ops:query(Cluster, Qry), 48 | ts_data:assert_error_regex("Incompatible types", Expected, Got). 49 | -------------------------------------------------------------------------------- /tests/ts_simple_select_incompatible_type_integer_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | %%% Test the if a varchar matches an integer 21 | %%% is not allowed. 22 | 23 | -module(ts_simple_select_incompatible_type_integer_not_allowed). 24 | 25 | -behavior(riak_test). 26 | 27 | -include_lib("eunit/include/eunit.hrl"). 28 | 29 | -export([confirm/0]). 30 | 31 | confirm() -> 32 | Table = ts_data:get_default_bucket(), 33 | DDL = ts_data:get_ddl(), 34 | Data = ts_data:get_valid_select_data(), 35 | Qry = 36 | "select * from GeoCheckin " 37 | "where time > 1 and time < 10 " 38 | "and myfamily = 'family1' " 39 | "and myseries = 10 ", 40 | Expected = 41 | {error, 42 | {1001, 43 | <<".*incompatible_type: field myseries with type varchar cannot be compared to type integer in where clause.">>}}, 44 | 45 | Cluster = ts_setup:start_cluster(1), 46 | ts_setup:create_bucket_type(Cluster, DDL, Table), 47 | ts_setup:activate_bucket_type(Cluster, Table), 48 | ts_ops:put(Cluster, Table, Data), 49 | Got = ts_ops:query(Cluster, Qry), 50 | ts_data:assert_error_regex("Incompatible type", Expected, Got). 51 | -------------------------------------------------------------------------------- /tests/ts_simple_select_missing_field_in_pk_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %%% Execute a query where the primary key is not covered 22 | %%% in the where clause. 23 | 24 | -module(ts_simple_select_missing_field_in_pk_not_allowed). 25 | 26 | -behavior(riak_test). 27 | 28 | -include_lib("eunit/include/eunit.hrl"). 29 | 30 | -export([confirm/0]). 31 | 32 | confirm() -> 33 | Table = ts_data:get_default_bucket(), 34 | DDL = ts_data:get_ddl(), 35 | Data = ts_data:get_valid_select_data(), 36 | Qry = 37 | "select * from GeoCheckin " 38 | "where time > 1 and time < 10", 39 | Expected = 40 | {error, 41 | {1001, 42 | <<"The 'myfamily' parameter is part the primary key but not specified in the where clause.">>}}, 43 | 44 | Cluster = ts_setup:start_cluster(1), 45 | ts_setup:create_bucket_type(Cluster, DDL, Table), 46 | ts_setup:activate_bucket_type(Cluster, Table), 47 | ts_ops:put(Cluster, Table, Data), 48 | Got = ts_ops:query(Cluster, Qry), 49 | ?assertEqual(Expected, Got), 50 | pass. 51 | -------------------------------------------------------------------------------- /tests/ts_simple_select_not_found.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_not_found). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | %% Test selects over fields which are not in the 30 | %% primary key. 31 | 32 | confirm() -> 33 | Table = ts_data:get_default_bucket(), 34 | DDL = ts_data:get_ddl(), 35 | Data = ts_data:get_valid_select_data(), 36 | % weather is not part of the primary key, it is 37 | % randomly generated data so this should return 38 | % zero results 39 | Qry = 40 | "SELECT * FROM GeoCheckin " 41 | "WHERE time > 1 AND time < 10 " 42 | "AND myfamily = 'family1' " 43 | "AND myseries = 'seriesX' " 44 | "AND weather = 'summer rain'", 45 | Expected = {ok, {[], []}}, 46 | 47 | Cluster = ts_setup:start_cluster(1), 48 | ts_setup:create_bucket_type(Cluster, DDL, Table), 49 | ts_setup:activate_bucket_type(Cluster, Table), 50 | ts_ops:put(Cluster, Table, Data), 51 | Got = ts_ops:query(Cluster, Qry), 52 | ?assertEqual(Expected, Got), 53 | pass. 54 | -------------------------------------------------------------------------------- /tests/ts_simple_select_table_not_existing.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015-2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_table_not_existing). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Qry = 31 | "SELECT * FROM dne " 32 | "WHERE time > 1 AND time < 10", 33 | Expected = {error,{1019,<<"dne is not an active table">>}}, 34 | 35 | Cluster = ts_setup:start_cluster(1), 36 | Got = ts_ops:query(Cluster, Qry), 37 | ?assertEqual(Expected, Got), 38 | pass. 39 | -------------------------------------------------------------------------------- /tests/ts_simple_select_unexpected_token_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_unexpected_token_not_allowed). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Table = ts_data:get_default_bucket(), 31 | DDL = ts_data:get_ddl(), 32 | Data = ts_data:get_valid_select_data(), 33 | Qry = 34 | "selectah * from GeoCheckin " 35 | "Where time > 1 and time < 10", 36 | Cluster = ts_setup:start_cluster(1), 37 | ts_setup:create_bucket_type(Cluster, DDL, Table), 38 | ts_setup:activate_bucket_type(Cluster, Table), 39 | ts_ops:put(Cluster, Table, Data), 40 | Got = ts_ops:query(Cluster, Qry), 41 | ts_data:assert_error_regex("Unexpected Token", {error, {1020, <<".*Unexpected token.*">>}}, Got). 42 | -------------------------------------------------------------------------------- /tests/ts_simple_select_where_has_no_lower_bounds_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_where_has_no_lower_bounds_not_allowed). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = ts_data:get_ddl(), 31 | Qry = "select * from GeoCheckin " 32 | "where time < 10 " 33 | "and myfamily = 'family1' " 34 | "and myseries ='seriesX' ", 35 | Expected = 36 | {error, {1001, <<"Where clause has no lower bound.">>}}, 37 | Cluster = ts_setup:start_cluster(1), 38 | Table = ts_data:get_default_bucket(), 39 | {ok, _} = ts_setup:create_bucket_type(Cluster, DDL, Table), 40 | ok = ts_setup:activate_bucket_type(Cluster, Table), 41 | Got = ts_ops:query(Cluster, Qry), 42 | ts_data:assert_error_regex("No lower bound", Expected, Got). 43 | -------------------------------------------------------------------------------- /tests/ts_simple_select_where_has_no_upper_bounds_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_select_where_has_no_upper_bounds_not_allowed). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | DDL = ts_data:get_ddl(), 31 | Qry = "select * from GeoCheckin " 32 | "where time > 10 " 33 | "and myfamily = 'family1' " 34 | "and myseries ='seriesX' ", 35 | Expected = 36 | {error, {1001, <<"Where clause has no upper bound.">>}}, 37 | Cluster = ts_setup:start_cluster(1), 38 | Table = ts_data:get_default_bucket(), 39 | {ok, _} = ts_setup:create_bucket_type(Cluster, DDL, Table), 40 | ok = ts_setup:activate_bucket_type(Cluster, Table), 41 | Got = ts_ops:query(Cluster, Qry), 42 | ts_data:assert_error_regex("No upper bound", Expected, Got). 43 | -------------------------------------------------------------------------------- /tests/ts_simple_show_tables.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(ts_simple_show_tables). 22 | 23 | -behavior(riak_test). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | 27 | -export([confirm/0]). 28 | 29 | confirm() -> 30 | Cluster = ts_setup:start_cluster(1), 31 | 32 | %% First test no tables 33 | Got = ts_ops:query(Cluster, "SHOW TABLES"), 34 | ?assertEqual( 35 | {ok, {[], []}}, 36 | Got 37 | ), 38 | 39 | %% Now create a bunch of tables 40 | Tables = [{<<"Alpha">>}, {<<"Beta">>}, {<<"Gamma">>}, {<<"Delta">>}], 41 | Create = 42 | "CREATE TABLE ~s (" 43 | " frequency timestamp not null," 44 | " PRIMARY KEY ((quantum(frequency, 15, 'm'))," 45 | " frequency))", 46 | lists:foreach(fun({Table}) -> 47 | SQL = ts_data:flat_format(Create, [Table]), 48 | {ok, _} = ts_setup:create_bucket_type(Cluster, SQL, Table), 49 | ok = ts_setup:activate_bucket_type(Cluster, Table) 50 | end, 51 | Tables), 52 | Got1 = ts_ops:query(Cluster, "SHOW TABLES"), 53 | ExpectedRows = [{TableName, <<"Active">>} || 54 | {TableName} <- lists:sort(Tables) ], 55 | ?assertEqual( 56 | {ok, {[<<"Table">>, <<"Status">>], ExpectedRows}}, 57 | Got1 58 | ), 59 | pass. 60 | -------------------------------------------------------------------------------- /tests/ts_simple_unicode_create_table_not_allowed.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2015 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | %% Test for creating a utf8 table name. This should fail 22 | %% because of mochijson decoding. 23 | 24 | -module(ts_simple_unicode_create_table_not_allowed). 25 | 26 | -behavior(riak_test). 27 | 28 | -export([confirm/0]). 29 | 30 | confirm() -> 31 | TableDef = 32 | "CREATE TABLE Αισθητήρας (" 33 | "family VARCHAR NOT NULL, " 34 | "series VARCHAR NOT NULL, " 35 | "time TIMESTAMP NOT NULL, " 36 | "PRIMARY KEY ((family, series, quantum(time, 15, 's')), family, series, time))", 37 | 38 | Cluster = ts_setup:start_cluster(1), 39 | {ok, Out} = ts_setup:create_bucket_type(Cluster, TableDef, "Αισθητήρας"), 40 | case binary:match(list_to_binary(Out), <<"invalid json">>) of 41 | nomatch -> 42 | {error, "Expecting this to fail, check implications for riak_ql"}; 43 | _ -> 44 | pass 45 | end. 46 | -------------------------------------------------------------------------------- /tests/ts_updowngrade_test.part: -------------------------------------------------------------------------------- 1 | %% -*- Mode: Erlang -*- 2 | %% ------------------------------------------------------------------- 3 | %% 4 | %% Copyright (c) 2016 Basho Technologies, Inc. 5 | %% 6 | %% This file is provided to you under the Apache License, 7 | %% Version 2.0 (the "License"); you may not use this file 8 | %% except in compliance with the License. You may obtain 9 | %% a copy of the License at 10 | %% 11 | %% http://www.apache.org/licenses/LICENSE-2.0 12 | %% 13 | %% Unless required by applicable law or agreed to in writing, 14 | %% software distributed under the License is distributed on an 15 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | %% KIND, either express or implied. See the License for the 17 | %% specific language governing permissions and limitations 18 | %% under the License. 19 | %% 20 | %% ------------------------------------------------------------------- 21 | -export([ 22 | suite/0, 23 | init_per_suite/1, 24 | end_per_suite/1, 25 | all/0, 26 | run_this_test/1 27 | ]). 28 | 29 | -include_lib("common_test/include/ct.hrl"). 30 | -include("ts_updown_util.hrl"). 31 | 32 | %% Callbacks 33 | 34 | suite() -> 35 | [{timetrap, {seconds, 9000}}]. 36 | 37 | all() -> 38 | [ 39 | run_this_test 40 | ]. 41 | 42 | init_per_suite(Config) -> 43 | lists:foldl( 44 | fun(Fun, Cfg) -> Fun(Cfg) end, 45 | Config, 46 | [fun make_initial_config/1, 47 | fun ts_updown_util:setup/1, 48 | fun make_scenario_invariants/1]). 49 | 50 | end_per_suite(Config) -> 51 | ts_updown_util:maybe_shutdown_client_node(Config). 52 | 53 | run_this_test(Config) -> 54 | case ts_updown_util:run_scenarios(Config, make_scenarios()) of 55 | [] -> 56 | pass; 57 | Errors -> 58 | ct:fail("There were failing queries~n~p", [Errors]) 59 | end. 60 | 61 | -------------------------------------------------------------------------------- /tests/verify_asis_put.erl: -------------------------------------------------------------------------------- 1 | -module(verify_asis_put). 2 | -include_lib("eunit/include/eunit.hrl"). 3 | -export([confirm/0]). 4 | 5 | confirm() -> 6 | %% 1. Deploy two nodes 7 | [Node1, Node2] = rt:deploy_nodes(2), 8 | %% 2. With PBC 9 | lager:info("Put new object in ~p via PBC.", [Node1]), 10 | PB1 = rt:pbc(Node1), 11 | PB2 = rt:pbc(Node2), 12 | Obj1 = riakc_obj:new(<<"verify_asis_put">>, <<"1">>, <<"test">>, "text/plain"), 13 | %% a. put in node 1 14 | %% b. fetch from node 1 for vclock 15 | {ok, Obj1a} = riakc_pb_socket:put(PB1, Obj1, [return_body]), 16 | %% c. put asis in node 2 17 | %% d. fetch from node 2, check vclock is same 18 | lager:info("Put object asis in ~p via PBC.", [Node2]), 19 | {ok, Obj1b} = riakc_pb_socket:put(PB2, Obj1a, [asis, return_body]), 20 | lager:info("Check vclock equality after asis put (PBC)."), 21 | ?assertEqual({vclock_equal, riakc_obj:vclock(Obj1a)}, 22 | {vclock_equal, riakc_obj:vclock(Obj1b)}), 23 | 24 | %% 3. Repeat with HTTP, nodes reversed 25 | lager:info("Put new object in ~p via HTTP.", [Node2]), 26 | HTTP1 = rt:httpc(Node1), 27 | HTTP2 = rt:httpc(Node2), 28 | Obj2 = riakc_obj:new(<<"verify_asis_put">>, <<"2">>, <<"test">>, "text/plain"), 29 | %% a. put in node 2 30 | %% b. fetch from node 2 for vclock 31 | {ok, Obj2a} = rhc:put(HTTP2, Obj2, [return_body]), 32 | %% c. put asis in node 1 33 | %% d. fetch from node 1, check vclock is same 34 | lager:info("Put object asis in ~p via PBC.", [Node1]), 35 | {ok, Obj2b} = rhc:put(HTTP1, Obj2a, [asis, return_body]), 36 | lager:info("Check vclock equality after asis put (HTTP)."), 37 | ?assertEqual({vclock_equal, riakc_obj:vclock(Obj2a)}, 38 | {vclock_equal, riakc_obj:vclock(Obj2b)}), 39 | 40 | pass. 41 | -------------------------------------------------------------------------------- /tests/verify_basic_upgrade.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(verify_basic_upgrade). 21 | -behavior(riak_test). 22 | -export([confirm/0]). 23 | -include_lib("eunit/include/eunit.hrl"). 24 | 25 | confirm() -> 26 | TestMetaData = riak_test_runner:metadata(), 27 | OldVsn = proplists:get_value(upgrade_version, TestMetaData, previous), 28 | 29 | Nodes = [Node1|_] = rt:build_cluster([OldVsn, OldVsn, OldVsn, OldVsn]), 30 | 31 | lager:info("Writing 100 keys to ~p", [Node1]), 32 | rt:systest_write(Node1, 100, 3), 33 | ?assertEqual([], rt:systest_read(Node1, 100, 1)), 34 | 35 | [upgrade(Node, current) || Node <- Nodes], 36 | 37 | %% Umm.. technically, it'd downgrade 38 | [upgrade(Node, OldVsn) || Node <- Nodes], 39 | pass. 40 | 41 | upgrade(Node, NewVsn) -> 42 | lager:info("Upgrading ~p to ~p", [Node, NewVsn]), 43 | rt:upgrade(Node, NewVsn), 44 | rt:wait_for_service(Node, riak_kv), 45 | lager:info("Ensuring keys still exist"), 46 | rt:systest_read(Node, 100, 1), 47 | ?assertEqual([], rt:systest_read(Node, 100, 1)), 48 | ok. 49 | -------------------------------------------------------------------------------- /tests/verify_build_cluster_caps_race.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(verify_build_cluster_caps_race). 21 | -behavior(riak_test). 22 | -export([confirm/0]). 23 | -include_lib("eunit/include/eunit.hrl"). 24 | 25 | staged_join(InitiatingNode, DestinationNode) -> 26 | rpc:call(InitiatingNode, riak_core, staged_join, 27 | [DestinationNode]). 28 | 29 | confirm() -> 30 | %% Deploy a set of new nodes 31 | lager:info("Deploying nodes"), 32 | 33 | [Node1, Node2] = rt:deploy_nodes(2), 34 | 35 | configure_intercept(Node2), 36 | 37 | lager:info("joining Node 2 to the cluster..."), 38 | ?assertMatch({error, _}, staged_join(Node2, Node1)), 39 | pass. 40 | 41 | %% init must return `starting' status for join to fail 42 | configure_intercept(Node) -> 43 | lager:info("Doing unspeakably evil things to the VM"), 44 | rt_intercept:add(Node, {init, 45 | [{{get_status,0}, get_status}]}). 46 | -------------------------------------------------------------------------------- /tests/verify_cluster_converge.erl: -------------------------------------------------------------------------------- 1 | -module(verify_cluster_converge). 2 | 3 | -behavior(riak_test). 4 | -export([confirm/0]). 5 | 6 | -include_lib("eunit/include/eunit.hrl"). 7 | -include_lib("riakc/include/riakc.hrl"). 8 | 9 | -define(assertDenied(Op), ?assertMatch({error, <<"Permission",_/binary>>}, Op)). 10 | 11 | confirm() -> 12 | lager:info("Deploy & cluster some nodes"), 13 | 14 | _Nodes = rt:build_cluster(4), 15 | pass. -------------------------------------------------------------------------------- /tests/verify_job_switch_defaults.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(verify_job_switch_defaults). 22 | 23 | -behavior(riak_test). 24 | -export([confirm/0]). 25 | 26 | -include_lib("eunit/include/eunit.hrl"). 27 | -include("job_enable_common.hrl"). 28 | 29 | %% =================================================================== 30 | %% Test API 31 | %% =================================================================== 32 | 33 | confirm() -> 34 | Configs = [{current, {cuttlefish, ?COMMON_CONFIG}}], 35 | lager:info("Deploying ~b nodes ...", [erlang:length(Configs)]), 36 | [Node | _] = Nodes = rt:deploy_nodes(Configs), 37 | 38 | job_enable_common:setup_cluster(Nodes), 39 | job_enable_common:setup_yokozuna(Nodes), 40 | 41 | [test_job_switch(Node, Class, Enabled) 42 | || {Class, Enabled} <- ?JOB_CLASS_DEFAULTS], 43 | 44 | pass. 45 | 46 | %% =================================================================== 47 | %% Internal 48 | %% =================================================================== 49 | 50 | test_job_switch(Node, Class, Enabled) -> 51 | lager:info("verifying ~p default ~s", 52 | [Class, job_enable_common:enabled_string(Enabled)]), 53 | ?assertEqual(Enabled, job_enable_common:get_enabled(Node, Class)), 54 | ?assertEqual(ok, job_enable_common:set_enabled(Node, Class, not Enabled)), 55 | ?assertEqual(not Enabled, job_enable_common:get_enabled(Node, Class)). 56 | -------------------------------------------------------------------------------- /tests/verify_no_writes_on_read.erl: -------------------------------------------------------------------------------- 1 | -module(verify_no_writes_on_read). 2 | -behaviour(riak_test). 3 | -export([confirm/0]). 4 | -compile(export_all). 5 | -include_lib("eunit/include/eunit.hrl"). 6 | 7 | -define(NUM_NODES, 3). 8 | -define(BUCKET, <<"bucket">>). 9 | 10 | confirm() -> 11 | Backend = proplists:get_value(backend, riak_test_runner:metadata()), 12 | lager:info("Running with backend ~p", [Backend]), 13 | ?assertEqual(bitcask, Backend), 14 | [Node1 | _Rest] = _Nodes = rt:build_cluster(?NUM_NODES), 15 | PBC = rt:pbc(Node1), 16 | lager:info("Setting last write wins on bucket"), 17 | B = ?BUCKET, 18 | ?assertMatch(ok, rpc:call(Node1, riak_core_bucket, set_bucket, [B, [{last_write_wins, true}]])), 19 | BProps = rpc:call(Node1, riak_core_bucket, get_bucket, [B]), 20 | lager:info("Bucket properties ~p", [BProps]), 21 | K = <<"Key">>, 22 | V = <<"Value">>, 23 | Obj = riakc_obj:new(B, K, V), 24 | lager:info("Writing a simple object"), 25 | riakc_pb_socket:put(PBC,Obj), 26 | lager:info("Waiting some time to let the stats update"), 27 | timer:sleep(10000), 28 | OrigStats = get_write_stats(Node1), 29 | lager:info("Stats are now ~p", [OrigStats]), 30 | Read1 = fun(_N) -> 31 | ?assertMatch({ok,_O}, riakc_pb_socket:get(PBC, B, K)) 32 | end, 33 | lager:info("Repeatedly read that object. There should be no writes"), 34 | lists:foreach(Read1, lists:seq(1,100)), 35 | lager:info("Waiting some time to let the stats update"), 36 | timer:sleep(10000), 37 | Stats = get_write_stats(Node1), 38 | lager:info("Stats are now ~p", [Stats]), 39 | ?assertEqual(OrigStats, Stats), 40 | riakc_pb_socket:stop(PBC), 41 | pass. 42 | 43 | 44 | get_write_stats(Node) -> 45 | Stats = rpc:call(Node, riak_kv_stat, get_stats, []), 46 | Puts = proplists:get_value(vnode_puts, Stats), 47 | ReadRepairs = proplists:get_value(read_repairs, Stats), 48 | [{puts, Puts}, {read_repairs, ReadRepairs}]. 49 | 50 | -------------------------------------------------------------------------------- /tests/verify_removed_capability.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2016 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(verify_removed_capability). 21 | -behavior(riak_test). 22 | -export([confirm/0]). 23 | -include_lib("eunit/include/eunit.hrl"). 24 | 25 | %% Start 3 nodes, create a capability and join them into a cluster 26 | %% 27 | %% Stop one node then restart it again, it joins the cluster without the 28 | %% capability defined. 29 | %% 30 | %% The capability on the two nodes which have not been shut down should be 31 | %% renegotiated to be the default value. 32 | confirm() -> 33 | [Node_A, Node_B, Node_C] = rt:deploy_nodes(3), 34 | Cap_name = {rt, cap_1}, 35 | V1 = 1, 36 | V2 = 2, 37 | ok = rpc:call(Node_A, riak_core_capability, register, [Cap_name, [V2,V1], V1, V1]), 38 | ok = rpc:call(Node_B, riak_core_capability, register, [Cap_name, [V2,V1], V1, V1]), 39 | ok = rpc:call(Node_C, riak_core_capability, register, [Cap_name, [V2,V1], V1, V1]), 40 | ok = rt:join_cluster([Node_A,Node_B,Node_C]), 41 | ok = rt:wait_until_ring_converged([Node_A,Node_B,Node_C]), 42 | ok = rt:wait_until_capability(Node_A, Cap_name, V2), 43 | ok = rt:wait_until_capability(Node_B, Cap_name, V2), 44 | ok = rt:wait_until_capability(Node_C, Cap_name, V2), 45 | rt:stop(Node_B), 46 | rt:start(Node_B), 47 | ok = rt:wait_until_capability(Node_A, Cap_name, V1), 48 | ok = rt:wait_until_capability(Node_C, Cap_name, V1), 49 | pass. 50 | -------------------------------------------------------------------------------- /tests/verify_riak_lager.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(verify_riak_lager). 21 | 22 | -behavior(riak_test). 23 | -export([confirm/0]). 24 | 25 | -include_lib("eunit/include/eunit.hrl"). 26 | -include_lib("kernel/include/file.hrl"). 27 | 28 | -define(UNIX_RW_R__R__, 8#100644). 29 | 30 | confirm() -> 31 | lager:info("Staring a node"), 32 | Nodes = [Node] = rt:deploy_nodes(1), 33 | ?assertEqual(ok, rt:wait_until_nodes_ready(Nodes)), 34 | 35 | lager:info("Stopping that node"), 36 | rt:stop(Node), 37 | 38 | rt:start(Node), 39 | lager:info("Checking for log files"), 40 | 41 | {ok, LagerHandlers} = rt:rpc_get_env(Node, [{lager, handlers}]), 42 | 43 | Files = [proplists:get_value(file, Config) || {Backend, Config} <- LagerHandlers, 44 | Backend == lager_file_backend ], 45 | 46 | lager:info("Checking for files: ~p", [Files]), 47 | [?assert(rpc:call(Node, filelib, is_file, [File])) || File <- Files], 48 | 49 | FileInfos = [ FileInfo || {ok, FileInfo} <- [rpc:call(Node, file, read_file_info, [File]) || File <- Files]], 50 | 51 | [?assertEqual(?UNIX_RW_R__R__, ?UNIX_RW_R__R__ band FileInfo#file_info.mode) || FileInfo <- FileInfos], 52 | pass. 53 | 54 | -------------------------------------------------------------------------------- /tests/verify_vclock_encoding_upgrade.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2012 Basho Technologies, Inc. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | -module(verify_vclock_encoding_upgrade). 21 | -behavior(riak_test). 22 | -export([confirm/0]). 23 | 24 | confirm() -> 25 | lager:info("Deploying previous cluster"), 26 | [Prev, Current] = rt:build_cluster([previous, current]), 27 | PrevClient = rt:pbc(Prev), 28 | CurrentClient = rt:pbc(Current), 29 | K = <<"key">>, 30 | B = <<"bucket">>, 31 | V = <<"value">>, 32 | lager:info("Putting object in previous version node"), 33 | riakc_pb_socket:put(PrevClient, riakc_obj:new(B, K, V)), 34 | lager:info("Fetching object from previous version node"), 35 | {ok, O} = riakc_pb_socket:get(PrevClient, B, K), 36 | O2 = riakc_obj:update_value(O, <<"value2">>), 37 | lager:info("Putting updated object in current version node"), 38 | ok = riakc_pb_socket:put(CurrentClient, O2), 39 | lager:info("Fetching again from current version node"), 40 | {ok, O3} = riakc_pb_socket:get(CurrentClient, B, K), 41 | O4 = riakc_obj:update_value(O3, <<"value2">>), 42 | lager:info("Putting updated object back in previous version node"), 43 | ok = riakc_pb_socket:put(PrevClient, O4), 44 | lager:info("Eso es todo amigos!"), 45 | pass. 46 | -------------------------------------------------------------------------------- /utils/riak_test.bash: -------------------------------------------------------------------------------- 1 | # bash_completion for riak_test 2 | _riak_test() 3 | { 4 | local cur prev tests 5 | if type _get_comp_words_by_ref &>/dev/null; then 6 | _get_comp_words_by_ref cur prev 7 | else 8 | for i in ${!COMP_WORDS[*]}; do 9 | prev=$cur 10 | cur=${COMP_WORDS[$i]} 11 | done 12 | fi 13 | 14 | case $prev in 15 | riak_test|*/riak_test) 16 | COMPREPLY=( $(compgen -W "-h -c -t -s -d -x -v -o -b -u -r -F \ 17 | --help --conf --tests --suites \ 18 | --dir --skip --verbose --outdir --backend \ 19 | --upgrade --report --file" -- "$cur") ) 20 | ;; 21 | -t|--tests) 22 | tests=$(grep -l confirm/0 ./tests/*.erl 2>/dev/null \ 23 | | xargs basename -s .erl) 24 | COMPREPLY=( $(compgen -W "$tests" -- "$cur") ) 25 | ;; 26 | esac 27 | } 28 | complete -F _riak_test riak_test ./riak_test 29 | -------------------------------------------------------------------------------- /utils/riak_test.zsh: -------------------------------------------------------------------------------- 1 | #compdef riak_test 2 | 3 | _riak_test() { 4 | local curcontext="$curcontext" state line 5 | typeset -A opt_args 6 | 7 | TESTS=$(ls ./tests/*.erl | xargs basename -s .erl | tr '\n' ' ') 8 | CONFIGS=$(cat ~/.riak_test.config | grep \^{ | sed s/{// | tr ', [\n' ' ') 9 | 10 | _arguments \ 11 | "(-t -c -s -d -v -o -b -r)-h[print usage page]" \ 12 | "-c+[specify the project configuraiton file]:config:($CONFIGS)" \ 13 | "-t+[specify which tests to run]:tests:($TESTS)" 14 | } 15 | 16 | _riak_test "$@" 17 | --------------------------------------------------------------------------------