Skip to content

Commit

Permalink
Sleep longer in ES tests
Browse files Browse the repository at this point in the history
By default, Elasticsearch periodically refreshes indices every second. So we sleep 2 seconds before checking the results.
  • Loading branch information
abitmore authored May 5, 2020
1 parent ec7373b commit 7b7d9f7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/elasticsearch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) {

// delete all first
auto delete_account_history = graphene::utilities::deleteAll(es);
fc::usleep(fc::milliseconds(1000)); // this is because index.refresh_interval, nothing to worry
fc::usleep(fc::milliseconds(2000)); // this is because index.refresh_interval, nothing to worry

if(delete_account_history) { // all records deleted

Expand All @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) {
auto bob = create_account("bob");

generate_block();
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

// for later use
//int asset_create_op_id = operation::tag<asset_create_operation>::value;
Expand All @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) {
auto willie = create_account("willie");
generate_block();

fc::usleep(fc::milliseconds(1000)); // index.refresh_interval
fc::usleep(fc::milliseconds(2000)); // index.refresh_interval

es.endpoint = es.index_prefix + "*/data/_count";
res = graphene::utilities::simpleQuery(es);
Expand All @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) {
transfer(account_id_type()(db), bob, asset(300));

generate_block();
fc::usleep(fc::milliseconds(1000)); // index.refresh_interval
fc::usleep(fc::milliseconds(2000)); // index.refresh_interval

res = graphene::utilities::simpleQuery(es);
j = fc::json::from_string(res);
Expand Down Expand Up @@ -145,14 +145,14 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) {
auto delete_objects = graphene::utilities::deleteAll(es);

generate_block();
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

if(delete_objects) { // all records deleted

// asset and bitasset
create_bitasset("USD", account_id_type());
generate_block();
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
es.endpoint = es.index_prefix + "*/data/_count";
Expand Down Expand Up @@ -195,10 +195,10 @@ BOOST_AUTO_TEST_CASE(elasticsearch_suite) {
es.elasticsearch_url = "http://localhost:9200/";
es.index_prefix = "bitshares-";
auto delete_account_history = graphene::utilities::deleteAll(es);
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));
es.index_prefix = "objects-";
auto delete_objects = graphene::utilities::deleteAll(es);
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

if(delete_account_history && delete_objects) { // all records deleted

Expand All @@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
auto delete_account_history = graphene::utilities::deleteAll(es);

generate_block();
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

if(delete_account_history) {

Expand All @@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
create_bitasset("OIL", dan.id); // create op 6

generate_block();
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

graphene::app::history_api hist_api(app);
app.enable_plugin("elasticsearch");
Expand Down Expand Up @@ -506,7 +506,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) {
create_account("alice");

generate_block();
fc::usleep(fc::milliseconds(1000));
fc::usleep(fc::milliseconds(2000));

// f(C, 0, 4, 10) = { 7 }
histories = hist_api.get_account_history("alice", operation_history_id_type(0), 4, operation_history_id_type(10));
Expand Down

0 comments on commit 7b7d9f7

Please sign in to comment.