Skip to content

Commit

Permalink
* Updating core MADARA tests to return number of failures
Browse files Browse the repository at this point in the history
* Adding core MADARA tests to Travis CI
  • Loading branch information
jredmondson committed Jun 21, 2018
1 parent fd09798 commit 0205081
Show file tree
Hide file tree
Showing 22 changed files with 694 additions and 110 deletions.
20 changes: 19 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,29 @@ script:
- ls $TRAVIS_BUILD_DIR
- echo $GAMS_ROOT/scripts/$OS/base_build.sh prereqs $CLANG madara tests $SSL $JAVA $ZMQ $SIMTIME
- $GAMS_ROOT/scripts/$OS/base_build.sh prereqs $CLANG madara tests $SSL $JAVA $ZMQ $SIMTIME
# now run a couple of tests
# now run functionality unit tests
- echo "Testing basic functionality..."
- $MADARA_ROOT/bin/test_bandwidth_monitor
- $MADARA_ROOT/bin/test_basic_reasoning
- $MADARA_ROOT/bin/test_checkpointing
- $MADARA_ROOT/bin/test_context_copy
- $MADARA_ROOT/bin/test_encoding
- $MADARA_ROOT/bin/test_filters
- $MADARA_ROOT/bin/test_fragmentation
- $MADARA_ROOT/bin/test_karl_containers
- $MADARA_ROOT/bin/test_karl_exceptions
- $MADARA_ROOT/bin/test_kb_destructions
- $MADARA_ROOT/bin/test_kb_expansion
- $MADARA_ROOT/bin/test_packet_scheduler
- $MADARA_ROOT/bin/test_periodic_wait
- $MADARA_ROOT/bin/test_prefix_to_map
- $MADARA_ROOT/bin/test_print_statement
- $MADARA_ROOT/bin/test_save_modifieds
- $MADARA_ROOT/bin/test_shared_record
- if [[ "$SIMTIME" == "simtime" ]]; then $MADARA_ROOT/bin/test_simtime ; fi
- $MADARA_ROOT/bin/test_system_calls
- $MADARA_ROOT/bin/test_timed_wait
- $MADARA_ROOT/bin/test_utility
# performance test (useful to see if we've regressed in performance)
- echo "Testing reasoning throughput..."
- $MADARA_ROOT/bin/test_reasoning_throughput
Expand Down
19 changes: 19 additions & 0 deletions Tests.mpc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ project (Test_Counter) : using_madara, no_karl, no_xml, null_lock, using_simtime
}
}

project (Test_Fragmentation) : using_madara, no_karl, no_xml, null_lock, using_simtime {
exeout = $(MADARA_ROOT)/bin
exename = test_fragmentation


requires += tests


Documentation_Files {
}

Header_Files {
}

Source_Files {
tests/test_fragmentation.cpp
}
}

project (Test_Threader_Queue_Perf) : using_madara, no_karl, no_xml, null_lock, using_simtime {
exeout = $(MADARA_ROOT)/bin
exename = test_threader_queue_perf
Expand Down
52 changes: 52 additions & 0 deletions include/madara/transport/Fragmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,26 +649,78 @@ madara::transport::is_complete (const char * originator, uint64_t clock,

if (orig_map != map.end ())
{
madara_logger_ptr_log (logger::global_logger.get(), logger::LOG_MINOR,
"transport::is_complete:" \
" %s was found.\n",
originator);

ClockFragmentMap & clock_map (orig_map->second);
ClockFragmentMap::iterator clock_found = clock_map.find (clock);

if (clock_found != clock_map.end ())
{
madara_logger_ptr_log (logger::global_logger.get(), logger::LOG_MINOR,
"transport::is_complete:" \
" %s:%" PRIu64 " was found.\n",
originator, clock);

uint64_t size = clock_found->second.size ();
FragmentMap::iterator i = clock_found->second.find (0);

if (i != clock_found->second.end ())
{
madara_logger_ptr_log (logger::global_logger.get(), logger::LOG_MINOR,
"transport::is_complete:" \
" %s:%" PRIu64 ": 0 == fragmap.end.\n",
originator, clock);

if (FragmentMessageHeader::get_updates (i->second) == size)
{
madara_logger_ptr_log (
logger::global_logger.get(), logger::LOG_MAJOR,
"transport::is_complete:" \
" %s:%" PRIu64 ": size == %" PRIu64
", updates == %" PRIu32 ". COMPLETE\n",
originator, clock, size,
FragmentMessageHeader::get_updates (i->second));

result = true;
}
else
{
madara_logger_ptr_log (
logger::global_logger.get(), logger::LOG_MAJOR,
"transport::is_complete:" \
" %s:%" PRIu64 ": size == %" PRIu64
", updates == %" PRIu32 ". INCOMPLETE\n",
originator, clock, size,
FragmentMessageHeader::get_updates (i->second));
}
}
else if (size == 0)
{
madara_logger_ptr_log (logger::global_logger.get(), logger::LOG_MAJOR,
"transport::is_complete:" \
" %s:%" PRIu64 ": size == 0 and i == 0. COMPLETE\n",
originator, clock);

result = true;
}
}
else
{
madara_logger_ptr_log (logger::global_logger.get(), logger::LOG_MAJOR,
"transport::is_complete:" \
" %s:%" PRIu64 " was not found.\n",
originator, clock);
}
}
else
{
madara_logger_ptr_log (logger::global_logger.get(), logger::LOG_MAJOR,
"transport::is_complete:" \
" %s was not found.\n",
originator);
}

return result;
Expand Down
26 changes: 24 additions & 2 deletions tests/test_bandwidth_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace logger = madara::logger;

int num_fails = 0;

// command line arguments
int parse_args (int argc, char * argv[]);

Expand All @@ -33,7 +35,10 @@ int main (int argc, char * argv[])
if (monitor.get_bytes_per_second () >= 100)
std::cerr << "Bandwidth check results in SUCCESS\n\n";
else
{
std::cerr << "Bandwidth check results in FAIL\n\n";
++num_fails;
}



Expand All @@ -45,7 +50,10 @@ int main (int argc, char * argv[])
if (monitor.get_bytes_per_second () >= 60)
std::cerr << "Bandwidth check results in SUCCESS\n\n";
else
{
std::cerr << "Bandwidth check results in FAIL\n\n";
++num_fails;
}

std::cerr << "Sleeping for 3 seconds...\n";
madara::utility::sleep (3);
Expand All @@ -55,7 +63,10 @@ int main (int argc, char * argv[])
if (monitor.get_bytes_per_second () >= 15)
std::cerr << "Bandwidth check results in SUCCESS\n\n";
else
{
std::cerr << "Bandwidth check results in FAIL\n\n";
++num_fails;
}

monitor.clear ();

Expand All @@ -80,10 +91,21 @@ int main (int argc, char * argv[])
if (monitor.get_bytes_per_second () >= 3000)
std::cerr << "Bandwidth check results in SUCCESS\n\n";
else
{
std::cerr << "Bandwidth check results in FAIL\n\n";

++num_fails;
}

return 0;
if (num_fails > 0)
{
std::cerr << "OVERALL: FAIL. " << num_fails << " tests failed.\n";
}
else
{
std::cerr << "OVERALL: SUCCESS.\n";
}

return num_fails;
}


Expand Down
43 changes: 39 additions & 4 deletions tests/test_checkpointing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace containers = knowledge::containers;

#define BUFFER_SIZE 1000

int num_fails = 0;

void test_checkpoint_settings (void)
{

Expand Down Expand Up @@ -76,6 +78,7 @@ void test_checkpoint_settings (void)
else
{
std::cerr << "FAIL. Knowledge was:\n";
++num_fails;
loader.print ();
}

Expand All @@ -88,6 +91,7 @@ void test_checkpoint_settings (void)
else
{
std::cerr << "FAIL\n";
++num_fails;
std::cerr << " Expected clocks (2001:2001) but got (" <<
settings.initial_lamport_clock << ":" << settings.last_lamport_clock <<
")\n";
Expand Down Expand Up @@ -126,6 +130,7 @@ void test_checkpoint_settings (void)
else
{
std::cerr << "FAIL. Knowledge was:\n";
++num_fails;
loader.print ();
}

Expand All @@ -140,6 +145,7 @@ void test_checkpoint_settings (void)
else
{
std::cerr << "FAIL\n";
++num_fails;
std::cerr << " Expected clocks (7:7) but got (" <<
settings.initial_lamport_clock << ":" << settings.last_lamport_clock <<
")\n";
Expand Down Expand Up @@ -174,6 +180,7 @@ void test_checkpoint_settings (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Should be garbled but is the same. " << buffer << "\n";
}

Expand All @@ -189,6 +196,7 @@ void test_checkpoint_settings (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Should be same but is garbled. " << buffer << "\n";
}

Expand Down Expand Up @@ -231,6 +239,7 @@ void test_checkpoint_settings (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand Down Expand Up @@ -258,6 +267,7 @@ void test_checkpoint_settings (void)
}
else
{
++num_fails;
std::cerr << "FAIL Knowledge was:\n";
loader.print ();
}
Expand Down Expand Up @@ -288,6 +298,7 @@ void test_checkpoint_settings (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand Down Expand Up @@ -347,6 +358,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand All @@ -368,6 +380,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand Down Expand Up @@ -401,6 +414,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand Down Expand Up @@ -447,6 +461,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand All @@ -466,6 +481,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand All @@ -485,6 +501,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand All @@ -504,6 +521,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand All @@ -523,6 +541,7 @@ void test_checkpoints_diff (void)
}
else
{
++num_fails;
std::cerr << "FAIL. Knowledge was:\n";
loader.print ();
}
Expand Down Expand Up @@ -611,13 +630,29 @@ int main (int argc, char * argv[])
std::cerr << "Test 4: decoded dest_header is equal to source_header? " <<
(header_decoded ? "true" : "false") << std::endl;

std::cerr << "\nEncoding results were " <<
(header_decoded ?
"SUCCESS\n" : "FAIL\n");
std::cerr << "\nEncoding results were ";
if (header_decoded)
{
std::cerr << "SUCCESS\n";
}
else
{
std::cerr << "FAIL\n";
++num_fails;
}

test_checkpoint_settings ();

test_checkpoints_diff ();

return 0;
if (num_fails > 0)
{
std::cerr << "OVERALL: FAIL. " << num_fails << " tests failed.\n";
}
else
{
std::cerr << "OVERALL: SUCCESS.\n";
}

return num_fails;
}

0 comments on commit 0205081

Please sign in to comment.