Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jredmondson/madara
Browse files Browse the repository at this point in the history
  • Loading branch information
dskyle-shieldai committed Jun 22, 2018
2 parents 2b56707 + 7a47213 commit 717e8ae
Show file tree
Hide file tree
Showing 25 changed files with 856 additions and 159 deletions.
21 changes: 20 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +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_key_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
76 changes: 63 additions & 13 deletions include/madara/knowledge/containers/FlexMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,44 +214,94 @@ const std::vector <double> & value)


madara::knowledge::KnowledgeRecord
madara::knowledge::containers::FlexMap::to_record (void) const
madara::knowledge::containers::FlexMap::to_record (
const KnowledgeRecord & default_value) const
{
knowledge::KnowledgeRecord result;

if (context_)
{
ContextGuard context_guard (*context_);
MADARA_GUARD_TYPE guard (mutex_);

KnowledgeUpdateSettings keep_local (true);

if (!variable_.is_valid ())
{
this->update_variable ();
}

result = context_->get (variable_, settings_);
if (context_->exists (variable_))
{
return context_->get (variable_, settings_);
}
}

return result;
return default_value;
}

madara::knowledge::KnowledgeRecord::Integer
madara::knowledge::containers::FlexMap::to_integer (void) const
madara::knowledge::containers::FlexMap::to_integer (
KnowledgeRecord::Integer default_value) const
{
return to_record ().to_integer ();
if (context_)
{
ContextGuard context_guard (*context_);
MADARA_GUARD_TYPE guard (mutex_);

if (!variable_.is_valid ())
{
this->update_variable ();
}

if (context_->exists (variable_))
{
return context_->get (variable_, settings_).to_integer ();
}
}

return default_value;
}

double
madara::knowledge::containers::FlexMap::to_double (void) const
madara::knowledge::containers::FlexMap::to_double (double default_value) const
{
return to_record ().to_double ();
if (context_)
{
ContextGuard context_guard (*context_);
MADARA_GUARD_TYPE guard (mutex_);

if (!variable_.is_valid ())
{
this->update_variable ();
}

if (context_->exists (variable_))
{
return context_->get (variable_, settings_).to_double ();
}
}

return default_value;
}

std::string
madara::knowledge::containers::FlexMap::to_string (void) const
madara::knowledge::containers::FlexMap::to_string (
const std::string & default_value) const
{
return to_record ().to_string ();
if (context_)
{
ContextGuard context_guard (*context_);
MADARA_GUARD_TYPE guard (mutex_);

if (!variable_.is_valid ())
{
this->update_variable ();
}

if (context_->exists (variable_))
{
return context_->get (variable_, settings_).to_string ();
}
}

return default_value;
}


Expand Down
18 changes: 14 additions & 4 deletions include/madara/knowledge/containers/FlexMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ namespace madara

/**
* Retrieves a copy of the record from the current location
* @param default_value if map location does not exist in KB,
* return this value instead
* @return the value of the entry. Modifications to this will
* not be reflected in the context. This is a local copy.
**/
knowledge::KnowledgeRecord to_record (void) const;
knowledge::KnowledgeRecord to_record (
const KnowledgeRecord & default_value = KnowledgeRecord(0)) const;

/**
* Fills a BufferVector container with all subkeys
Expand Down Expand Up @@ -204,21 +207,28 @@ namespace madara

/**
* Returns the value at the location as an integer
* @param default_value if map location does not exist in KB,
* return this value instead
* @return the value at the location
**/
knowledge::KnowledgeRecord::Integer to_integer (void) const;
knowledge::KnowledgeRecord::Integer to_integer (
KnowledgeRecord::Integer default_value = 0) const;

/**
* Returns the value at the location as a double
* @param default_value if map location does not exist in KB,
* return this value instead
* @return the value at the location
**/
double to_double (void) const;
double to_double (double default_value = 0.0) const;

/**
* Returns the value at the location as a string
* @param default_value if map location does not exist in KB,
* return this value instead
* @return the value at the location
**/
std::string to_string (void) const;
std::string to_string (const std::string & default_value = "") const;

/**
* Returns the size of the map
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

0 comments on commit 717e8ae

Please sign in to comment.