Skip to content

Commit b53b254

Browse files
committed
(temp) moved test to standard bench and removed es tests
1 parent c0f3def commit b53b254

File tree

2 files changed

+105
-111
lines changed

2 files changed

+105
-111
lines changed

tests/CMakeLists.txt

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ file(GLOB UNIT_TESTS "tests/*.cpp")
1010
add_executable( chain_test ${COMMON_SOURCES} ${UNIT_TESTS} )
1111
target_link_libraries( chain_test
1212
graphene_chain graphene_app graphene_witness graphene_account_history graphene_elasticsearch
13-
graphene_es_objects graphene_egenesis_none graphene_api_helper_indexes
13+
graphene_es_objects graphene_egenesis_none graphene_api_helper_indexes graphene_voting_stat
1414
fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} )
1515
if(MSVC)
1616
set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
@@ -52,8 +52,4 @@ target_link_libraries( es_test
5252
graphene_es_objects graphene_egenesis_none graphene_api_helper_indexes
5353
fc ${PLATFORM_SPECIFIC_LIBS} )
5454

55-
file( GLOB VOTING_STAT_SOURCES "voting_stat/*.cpp" )
56-
add_executable( voting_stat_test ${COMMON_SOURCES} ${VOTING_STAT_SOURCES} )
57-
target_link_libraries( voting_stat_test graphene_chain graphene_app graphene_voting_stat graphene_elasticsearch graphene_es_objects graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
58-
5955
add_subdirectory( generate_empty_blocks )

tests/voting_stat/main.cpp renamed to tests/tests/voting_stat_tests.cpp

+104-106
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,52 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24+
#include <boost/test/unit_test.hpp>
2425
#include <boost/program_options.hpp>
2526
#include <boost/range.hpp>
2627
#include <boost/tuple/tuple.hpp>
2728

2829
#include <fc/optional.hpp>
2930

3031
#include <graphene/voting_stat/voting_stat_plugin.hpp>
31-
#include <graphene/es_objects/es_objects.hpp>
32-
#include <graphene/utilities/elasticsearch.hpp>
32+
//#include <graphene/es_objects/es_objects.hpp>
33+
//#include <graphene/utilities/elasticsearch.hpp>
3334

3435
#include <graphene/app/api.hpp>
3536

3637
#include <graphene/protocol/account.hpp>
3738

38-
#include <graphene/chain/voting_statistics_object.hpp>
39-
#include <graphene/chain/voteable_statistics_object.hpp>
39+
#include <graphene/voting_stat/voting_statistics_object.hpp>
40+
#include <graphene/voting_stat/voteable_statistics_object.hpp>
4041

4142
#include "../common/database_fixture.hpp"
4243

43-
#define BOOST_TEST_MODULE Voting Statistics Plugin Test
44-
#include <boost/test/included/unit_test.hpp>
45-
4644
using namespace fc;
4745
using namespace graphene::app;
4846
using namespace graphene::chain;
4947
using namespace graphene::chain::test;
5048
using namespace graphene::voting_stat;
51-
using namespace graphene::es_objects;
49+
//using namespace graphene::es_objects;
5250
using namespace graphene::utilities;
5351
namespace bpo = boost::program_options;
5452

5553
struct voting_stat_fixture : public database_fixture
5654
{
5755
vote_id_type default_vote_id;
58-
CURL *_curl;
59-
ES _es;
56+
// CURL *_curl;
57+
// ES _es;
6058

6159
voting_stat_fixture()
6260
{
6361
try
6462
{
65-
_curl = curl_easy_init();
66-
_es.curl = _curl;
67-
_es.elasticsearch_url = "http://localhost:9200/";
68-
_es.index_prefix = "objects-";
63+
// _curl = curl_easy_init();
64+
// _es.curl = _curl;
65+
// _es.elasticsearch_url = "http://localhost:9200/";
66+
// _es.index_prefix = "objects-";
6967

7068
app.register_plugin<voting_stat_plugin>( true );
71-
app.register_plugin<es_objects_plugin>( true );
69+
//app.register_plugin<es_objects_plugin>( true );
7270
}
7371
catch(fc::exception &e)
7472
{
@@ -181,8 +179,8 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_delete_after_interval )
181179
auto voting_stat = app.get_plugin<voting_stat_plugin>("voting_stat");
182180
voting_stat->plugin_set_program_options( cli_vs, cfg );
183181

184-
auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
185-
es_objects->plugin_set_program_options( cli_es, cfg );
182+
//auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
183+
//es_objects->plugin_set_program_options( cli_es, cfg );
186184

187185
const char* const plugin_argv[]{ "voting_stat",
188186
"--voting-stat-track-every-x-maint", "1",
@@ -191,24 +189,24 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_delete_after_interval )
191189
"--voting-stat-track-committee-votes", "false",
192190
"--voting-stat-track-worker-votes", "false",
193191

194-
"--es-objects-bulk-replay", "1",
195-
"--es-objects-proposals", "false",
196-
"--es-objects-accounts", "false",
197-
"--es-objects-assets", "false",
198-
"--es-objects-balances", "false",
199-
"--es-objects-limit-orders", "false",
200-
"--es-objects-asset-bitasset", "false",
201-
"--es-objects-keep-only-current", "true",
192+
// "--es-objects-bulk-replay", "1",
193+
// "--es-objects-proposals", "false",
194+
// "--es-objects-accounts", "false",
195+
// "--es-objects-assets", "false",
196+
// "--es-objects-balances", "false",
197+
// "--es-objects-limit-orders", "false",
198+
// "--es-objects-asset-bitasset", "false",
199+
// "--es-objects-keep-only-current", "true",
202200
};
203201
int plugin_argc = sizeof(plugin_argv)/sizeof(char*);
204202

205203
bpo::variables_map var_map;
206204
bpo::store( bpo::parse_command_line( plugin_argc, plugin_argv, cfg ), var_map );
207205
app.initialize_plugins( var_map );
208206

209-
auto objects_deleted = graphene::utilities::deleteAll(_es);
210-
if( !objects_deleted )
211-
BOOST_FAIL( "elastic search DB could not be deleted" );
207+
// auto objects_deleted = graphene::utilities::deleteAll(_es);
208+
// if( !objects_deleted )
209+
// BOOST_FAIL( "elastic search DB could not be deleted" );
212210

213211

214212
ACTORS( (alice)(bob)(charlie) );
@@ -313,13 +311,13 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_delete_after_interval )
313311
BOOST_CHECK( charlie_stat.get_total_voting_stake() == 222 );
314312
}
315313

316-
fc::usleep(fc::milliseconds(2000));
317-
string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
318-
_es.endpoint = _es.index_prefix + "*/data/_count";
319-
_es.query = query;
320-
auto res = graphene::utilities::simpleQuery(_es);
321-
variant j = fc::json::from_string(res);
322-
BOOST_CHECK( j["count"].as_int64() == 12 );
314+
// fc::usleep(fc::milliseconds(2000));
315+
// string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
316+
// _es.endpoint = _es.index_prefix + "*/data/_count";
317+
// _es.query = query;
318+
// auto res = graphene::utilities::simpleQuery(_es);
319+
// variant j = fc::json::from_string(res);
320+
// BOOST_CHECK( j["count"].as_int64() == 12 );
323321

324322
} FC_LOG_AND_RETHROW() }
325323

@@ -335,8 +333,8 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_keep_after_interval )
335333
auto voting_stat = app.get_plugin<voting_stat_plugin>("voting_stat");
336334
voting_stat->plugin_set_program_options( cli_vs, cfg );
337335

338-
auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
339-
es_objects->plugin_set_program_options( cli_es, cfg );
336+
//auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
337+
//es_objects->plugin_set_program_options( cli_es, cfg );
340338

341339
const char* const plugin_argv[]{ "voting_stat",
342340
"--voting-stat-track-every-x-maint", "1",
@@ -345,24 +343,24 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_keep_after_interval )
345343
"--voting-stat-track-committee-votes", "false",
346344
"--voting-stat-track-worker-votes", "false",
347345

348-
"--es-objects-bulk-replay", "1",
349-
"--es-objects-proposals", "false",
350-
"--es-objects-accounts", "false",
351-
"--es-objects-assets", "false",
352-
"--es-objects-balances", "false",
353-
"--es-objects-limit-orders", "false",
354-
"--es-objects-asset-bitasset", "false",
355-
"--es-objects-keep-only-current", "true",
346+
// "--es-objects-bulk-replay", "1",
347+
// "--es-objects-proposals", "false",
348+
// "--es-objects-accounts", "false",
349+
// "--es-objects-assets", "false",
350+
// "--es-objects-balances", "false",
351+
// "--es-objects-limit-orders", "false",
352+
// "--es-objects-asset-bitasset", "false",
353+
// "--es-objects-keep-only-current", "true",
356354
};
357355
int plugin_argc = sizeof(plugin_argv)/sizeof(char*);
358356

359357
bpo::variables_map var_map;
360358
bpo::store( bpo::parse_command_line( plugin_argc, plugin_argv, cfg ), var_map );
361359
app.initialize_plugins( var_map );
362360

363-
auto objects_deleted = graphene::utilities::deleteAll(_es);
364-
if( !objects_deleted )
365-
BOOST_FAIL( "elastic search DB could not be deleted" );
361+
// auto objects_deleted = graphene::utilities::deleteAll(_es);
362+
// if( !objects_deleted )
363+
// BOOST_FAIL( "elastic search DB could not be deleted" );
366364

367365

368366
ACTORS( (alice)(bob)(charlie) );
@@ -467,13 +465,13 @@ BOOST_AUTO_TEST_CASE( test_voting_statistics_with_proxy_keep_after_interval )
467465
BOOST_CHECK( charlie_stat.get_total_voting_stake() == 222 );
468466
}
469467

470-
fc::usleep(fc::milliseconds(2000));
471-
string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
472-
_es.endpoint = _es.index_prefix + "*/data/_count";
473-
_es.query = query;
474-
auto res = graphene::utilities::simpleQuery(_es);
475-
variant j = fc::json::from_string(res);
476-
BOOST_CHECK( j["count"].as_int64() == 12 );
468+
// fc::usleep(fc::milliseconds(2000));
469+
// string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
470+
// _es.endpoint = _es.index_prefix + "*/data/_count";
471+
// _es.query = query;
472+
// auto res = graphene::utilities::simpleQuery(_es);
473+
// variant j = fc::json::from_string(res);
474+
// BOOST_CHECK( j["count"].as_int64() == 12 );
477475

478476
} FC_LOG_AND_RETHROW() }
479477

@@ -487,8 +485,8 @@ BOOST_AUTO_TEST_CASE( test_voteable_objects_tracking_with_es )
487485
auto voting_stat = app.get_plugin<voting_stat_plugin>("voting_stat");
488486
voting_stat->plugin_set_program_options( cli_vs, cfg );
489487

490-
auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
491-
es_objects->plugin_set_program_options( cli_es, cfg );
488+
// auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
489+
// es_objects->plugin_set_program_options( cli_es, cfg );
492490

493491
const char* const plugin_argv[]{ "voting_stat",
494492
"--voting-stat-track-every-x-maint", "1",
@@ -497,28 +495,28 @@ BOOST_AUTO_TEST_CASE( test_voteable_objects_tracking_with_es )
497495
"--voting-stat-track-witness-votes", "true",
498496
"--voting-stat-track-committee-votes", "true",
499497

500-
"--es-objects-voting-statistics", "true",
501-
"--es-objects-voteable-statistics", "true",
502-
"--es-objects-statistics-delete-allowed", "false",
503-
504-
"--es-objects-bulk-replay", "1",
505-
"--es-objects-proposals", "false",
506-
"--es-objects-accounts", "false",
507-
"--es-objects-assets", "false",
508-
"--es-objects-balances", "false",
509-
"--es-objects-limit-orders", "false",
510-
"--es-objects-asset-bitasset", "false",
511-
"--es-objects-keep-only-current", "true",
498+
// "--es-objects-voting-statistics", "true",
499+
// "--es-objects-voteable-statistics", "true",
500+
// "--es-objects-statistics-delete-allowed", "false",
501+
502+
// "--es-objects-bulk-replay", "1",
503+
// "--es-objects-proposals", "false",
504+
// "--es-objects-accounts", "false",
505+
// "--es-objects-assets", "false",
506+
// "--es-objects-balances", "false",
507+
// "--es-objects-limit-orders", "false",
508+
// "--es-objects-asset-bitasset", "false",
509+
// "--es-objects-keep-only-current", "true",
512510
};
513511
int plugin_argc = sizeof(plugin_argv)/sizeof(char*);
514512

515513
bpo::variables_map var_map;
516514
bpo::store( bpo::parse_command_line( plugin_argc, plugin_argv, cfg ), var_map );
517515
app.initialize_plugins( var_map );
518516

519-
auto objects_deleted = graphene::utilities::deleteAll(_es);
520-
if( !objects_deleted )
521-
BOOST_FAIL( "elastic search DB could not be deleted" );
517+
// auto objects_deleted = graphene::utilities::deleteAll(_es);
518+
// if( !objects_deleted )
519+
// BOOST_FAIL( "elastic search DB could not be deleted" );
522520

523521

524522
ACTOR( alice );
@@ -553,16 +551,16 @@ BOOST_AUTO_TEST_CASE( test_voteable_objects_tracking_with_es )
553551
BOOST_CHECK( voteable_idx.size() == expected_voteables );
554552

555553

556-
auto expected_objs_in_es = 2*(expected_voteables + 1);
554+
// auto expected_objs_in_es = 2*(expected_voteables + 1);
557555

558-
fc::usleep(fc::milliseconds(2000));
559-
string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
560-
_es.endpoint = _es.index_prefix + "*/data/_count";
561-
_es.query = query;
562-
auto res = graphene::utilities::simpleQuery(_es);
563-
variant j = fc::json::from_string(res);
564-
uint64_t obj_count = j["count"].as_uint64();
565-
BOOST_CHECK( obj_count == expected_objs_in_es );
556+
// fc::usleep(fc::milliseconds(2000));
557+
// string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
558+
// _es.endpoint = _es.index_prefix + "*/data/_count";
559+
// _es.query = query;
560+
// auto res = graphene::utilities::simpleQuery(_es);
561+
// variant j = fc::json::from_string(res);
562+
// uint64_t obj_count = j["count"].as_uint64();
563+
// BOOST_CHECK( obj_count == expected_objs_in_es );
566564

567565
} FC_LOG_AND_RETHROW() }
568566

@@ -621,35 +619,35 @@ BOOST_AUTO_TEST_CASE( test_delete_after_interval_and_pushed_to_es )
621619
auto voting_stat = app.get_plugin<voting_stat_plugin>("voting_stat");
622620
voting_stat->plugin_set_program_options( cli_vs, cfg );
623621

624-
auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
625-
es_objects->plugin_set_program_options( cli_es, cfg );
622+
//auto es_objects = app.get_plugin<es_objects_plugin>("es_objects");
623+
//es_objects->plugin_set_program_options( cli_es, cfg );
626624

627625
const char* const plugin_argv[]{ "voting_stat",
628626
"--voting-stat-track-every-x-maint", "1",
629627
"--voting-stat-keep-objects-in-db", "false",
630628

631-
"--es-objects-voting-statistics", "true",
632-
"--es-objects-voteable-statistics", "false",
633-
"--es-objects-statistics-delete-allowed", "false",
634-
635-
"--es-objects-bulk-replay", "1",
636-
"--es-objects-proposals", "false",
637-
"--es-objects-accounts", "false",
638-
"--es-objects-assets", "false",
639-
"--es-objects-balances", "false",
640-
"--es-objects-limit-orders", "false",
641-
"--es-objects-asset-bitasset", "false",
642-
"--es-objects-keep-only-current", "true",
629+
// "--es-objects-voting-statistics", "true",
630+
// "--es-objects-voteable-statistics", "false",
631+
// "--es-objects-statistics-delete-allowed", "false",
632+
633+
// "--es-objects-bulk-replay", "1",
634+
// "--es-objects-proposals", "false",
635+
// "--es-objects-accounts", "false",
636+
// "--es-objects-assets", "false",
637+
// "--es-objects-balances", "false",
638+
// "--es-objects-limit-orders", "false",
639+
// "--es-objects-asset-bitasset", "false",
640+
// "--es-objects-keep-only-current", "true",
643641
};
644642
int plugin_argc = sizeof(plugin_argv)/sizeof(char*);
645643

646644
bpo::variables_map var_map;
647645
bpo::store( bpo::parse_command_line( plugin_argc, plugin_argv, cfg ), var_map );
648646
app.initialize_plugins( var_map );
649647

650-
auto objects_deleted = graphene::utilities::deleteAll(_es);
651-
if( !objects_deleted )
652-
BOOST_FAIL( "elastic search DB could not be deleted" );
648+
// auto objects_deleted = graphene::utilities::deleteAll(_es);
649+
// if( !objects_deleted )
650+
// BOOST_FAIL( "elastic search DB could not be deleted" );
653651

654652

655653
const auto& idx = db.get_index_type<voting_statistics_index>().indices().get<by_block_number>();
@@ -672,14 +670,14 @@ BOOST_AUTO_TEST_CASE( test_delete_after_interval_and_pushed_to_es )
672670
BOOST_CHECK( idx.size() == 1 );
673671

674672

675-
fc::usleep(fc::milliseconds(2000));
676-
string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
677-
_es.endpoint = _es.index_prefix + "*/data/_count";
678-
_es.query = query;
679-
auto res = graphene::utilities::simpleQuery(_es);
680-
variant j = fc::json::from_string(res);
681-
int64_t obj_count = j["count"].as_int64();
682-
BOOST_CHECK( obj_count == 3 );
673+
// fc::usleep(fc::milliseconds(2000));
674+
// string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }";
675+
// _es.endpoint = _es.index_prefix + "*/data/_count";
676+
// _es.query = query;
677+
// auto res = graphene::utilities::simpleQuery(_es);
678+
// variant j = fc::json::from_string(res);
679+
// int64_t obj_count = j["count"].as_int64();
680+
// BOOST_CHECK( obj_count == 3 );
683681

684682
} FC_LOG_AND_RETHROW() }
685683

0 commit comments

Comments
 (0)