Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Launcher tests #5476

Merged
merged 5 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/history_plugin/history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ namespace eosio {
if( options.count( "filter-on" )) {
auto fo = options.at( "filter-on" ).as<vector<string>>();
for( auto& s : fo ) {
if( s == "*" ) {
if( s == "*" || s == "\"*\"" ) {
my->bypass_filter = true;
wlog( "--filter-on * enabled. This can fill shared_mem, causing nodeos to stop." );
break;
Expand Down
60 changes: 35 additions & 25 deletions programs/eosio-launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma GCC diagnostic ignored "-Wunused-result"
#include <boost/process/child.hpp>
#pragma GCC diagnostic pop
#include <boost/process/env.hpp>
#include <boost/process/system.hpp>
#include <boost/process/io.hpp>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -162,7 +163,7 @@ class host_def {
return base_http_port - 100;
}

bool is_local( ) {
bool is_local( ) const {
return local_id.contains( host_name );
}

Expand Down Expand Up @@ -457,6 +458,7 @@ struct launcher_def {
void make_custom ();
void write_dot_file ();
void format_ssh (const string &cmd, const string &host_name, string &ssh_cmd_line);
void do_command(const host_def& host, const string& name, vector<pair<string, string>> env_pairs, const string& cmd);
bool do_ssh (const string &cmd, const string &host_name);
void prep_remote_config_dir (eosd_def &node, host_def *host);
void launch (eosd_def &node, string &gts);
Expand Down Expand Up @@ -1643,22 +1645,40 @@ launcher_def::get_nodes(const string& node_number_list) {
return node_list;
}

void
launcher_def::do_command(const host_def& host, const string& name,
vector<pair<string, string>> env_pairs, const string& cmd) {
if (!host.is_local()) {
string rcmd = "cd " + host.eosio_home + "; ";
for (auto& env_pair : env_pairs) {
rcmd += "export " + env_pair.first + "=" + env_pair.second + "; ";
}
rcmd += cmd;
if (!do_ssh(rcmd, host.host_name)) {
cerr << "Remote command failed for " << name << endl;
exit (-1);
}
}
else {
bp::environment e;
for (auto& env_pair : env_pairs) {
e.emplace(env_pair.first, env_pair.second);
}
bp::child c(cmd, e);
c.wait();
}
}

void
launcher_def::bounce (const string& node_numbers) {
auto node_list = get_nodes(node_numbers);
for (auto node_pair: node_list) {
const host_def& host = node_pair.first;
const eosd_def& node = node_pair.second;
string node_num = node.name.substr( node.name.length() - 2 );
string cmd = "cd " + host.eosio_home + "; "
+ "export EOSIO_HOME=" + host.eosio_home + string("; ")
+ "export EOSIO_NODE=" + node_num + "; "
+ "./scripts/eosio-tn_bounce.sh " + eosd_extra_args;
cout << "Bouncing " << node.name << endl;
if (!do_ssh(cmd, host.host_name)) {
cerr << "Unable to bounce " << node.name << endl;
exit (-1);
}
string cmd = "./scripts/eosio-tn_bounce.sh " + eosd_extra_args;
do_command(host, node.name, { { "EOSIO_HOME", host.eosio_home }, { "EOSIO_NODE", node_num } }, cmd);
}
}

Expand All @@ -1669,16 +1689,11 @@ launcher_def::down (const string& node_numbers) {
const host_def& host = node_pair.first;
const eosd_def& node = node_pair.second;
string node_num = node.name.substr( node.name.length() - 2 );
string cmd = "cd " + host.eosio_home + "; "
+ "export EOSIO_HOME=" + host.eosio_home + "; "
+ "export EOSIO_NODE=" + node_num + "; "
+ "export EOSIO_TN_RESTART_CONFIG_DIR=" + node.config_dir_name + "; "
+ "./scripts/eosio-tn_down.sh";
cout << "Taking down " << node.name << endl;
if (!do_ssh(cmd, host.host_name)) {
cerr << "Unable to down " << node.name << endl;
exit (-1);
}
string cmd = "./scripts/eosio-tn_down.sh ";
do_command(host, node.name,
{ { "EOSIO_HOME", host.eosio_home }, { "EOSIO_NODE", node_num }, { "EOSIO_TN_RESTART_CONFIG_DIR", node.config_dir_name } },
cmd);
}
}

Expand All @@ -1689,13 +1704,8 @@ launcher_def::roll (const string& host_names) {
for (string host_name: hosts) {
cout << "Rolling " << host_name << endl;
auto host = find_host_by_name_or_address(host_name);
string cmd = "cd " + host->eosio_home + "; "
+ "export EOSIO_HOME=" + host->eosio_home + "; "
+ "./scripts/eosio-tn_roll.sh";
if (!do_ssh(cmd, host_name)) {
cerr << "Unable to roll " << host << endl;
exit (-1);
}
string cmd = "./scripts/eosio-tn_roll.sh ";
do_command(*host, host_name, { { "EOSIO_HOME", host->eosio_home } }, cmd);
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/eosio-tn_bounce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ else
fi

bash $EOSIO_HOME/scripts/eosio-tn_down.sh
bash $EOSIO_HOME/scripts/eosio-tn_up.sh $*
bash $EOSIO_HOME/scripts/eosio-tn_up.sh "$*"
4 changes: 2 additions & 2 deletions scripts/eosio-tn_roll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ cp $SDIR/$RD/$prog $RD/$prog

if [ $DD = "all" ]; then
for EOSIO_RESTART_DATA_DIR in `ls -d var/lib/node_??`; do
bash $EOSIO_HOME/scripts/eosio-tn_up.sh $*
bash $EOSIO_HOME/scripts/eosio-tn_up.sh "$*"
done
else
bash $EOSIO_HOME/scripts/eosio-tn_up.sh $*
bash $EOSIO_HOME/scripts/eosio-tn_up.sh "$*"
fi
unset EOSIO_RESTART_DATA_DIR

Expand Down
12 changes: 7 additions & 5 deletions scripts/eosio-tn_up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ connected="0"
rundir=programs/nodeos
prog=nodeos

# Quote any args that are "*", so they are not expanded
qargs=`echo "$*" | sed -e 's/ \* / "*" /' -e 's/ \*$/ "*"/'`

if [ "$PWD" != "$EOSIO_HOME" ]; then
echo $0 must only be run from $EOSIO_HOME
Expand All @@ -33,8 +35,8 @@ rm $datadir/stderr.txt
ln -s $log $datadir/stderr.txt

relaunch() {
echo "$rundir/$prog $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $datadir/$log "
nohup $rundir/$prog $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $datadir/$log &
echo "$rundir/$prog $qargs $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $datadir/$log "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not run into the same issues with the * exploding to all the files in the current directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because I have added quotes around the * argument. This is not a very general solution but works for --filter-on *.

nohup $rundir/$prog $qargs $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $datadir/$log &
pid=$!
echo pid = $pid
echo $pid > $datadir/$prog.pid
Expand All @@ -56,7 +58,7 @@ relaunch() {

if [ -z "$EOSIO_LEVEL" ]; then
echo starting with no modifiers
relaunch $*
relaunch
if [ "$connected" -eq 0 ]; then
EOSIO_LEVEL=replay
else
Expand All @@ -66,7 +68,7 @@ fi

if [ "$EOSIO_LEVEL" == replay ]; then
echo starting with replay
relaunch $* --hard-replay-blockchain
relaunch --hard-replay-blockchain
if [ "$connected" -eq 0 ]; then
EOSIO_LEVEL=resync
else
Expand All @@ -75,5 +77,5 @@ if [ "$EOSIO_LEVEL" == replay ]; then
fi
if [ "$EOSIO_LEVEL" == resync ]; then
echo starting with delete-all-blocks
relaunch $* --delete-all-blocks
relaunch --delete-all-blocks
fi
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_under_min_avail_ram.py ${CMAKE
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_voting_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_voting_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/consensus-validation-malicious-producers.py ${CMAKE_CURRENT_BINARY_DIR}/consensus-validation-malicious-producers.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/validate-dirty-db.py ${CMAKE_CURRENT_BINARY_DIR}/validate-dirty-db.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/launcher_test.py ${CMAKE_CURRENT_BINARY_DIR}/launcher_test.py COPYONLY)

#To run plugin_test with all log from blockchain displayed, put --verbose after --, i.e. plugin_test -- --verbose
add_test(NAME plugin_test COMMAND plugin_test --report_level=detailed --color_output)
Expand All @@ -59,6 +60,7 @@ add_test(NAME restart-scenarios-test-hard_replay COMMAND tests/restart-scenarios
add_test(NAME restart-scenarios-test-none COMMAND tests/restart-scenarios-test.py -c none --kill-sig term -p4 -v --clean-run --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME consensus-validation-malicious-producers COMMAND tests/consensus-validation-malicious-producers.py -w 80 --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME validate_dirty_db_test COMMAND tests/validate-dirty-db.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME launcher_test COMMAND tests/launcher_test.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# Long running tests
add_test(NAME nodeos_sanity_lr_test COMMAND tests/nodeos_run_test.py -v --sanity-test --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down
Loading