From 4c0c937431a6c4f68eea4a98cd6e9db86be4520b Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Tue, 21 Jul 2020 17:04:19 -0400 Subject: [PATCH] Test attributes added per step --- .../engine/staging-common/CMakeLists.txt | 2 +- .../adios2/engine/staging-common/ParseArgs.h | 5 ++++ .../staging-common/TestCommonClient.cpp | 27 +++++++++++++++++++ .../engine/staging-common/TestCommonRead.cpp | 27 +++++++++++++++++++ .../staging-common/TestCommonServer.cpp | 7 +++++ .../engine/staging-common/TestCommonWrite.cpp | 7 +++++ .../engine/staging-common/TestSupp.cmake | 3 +++ 7 files changed, 77 insertions(+), 1 deletion(-) diff --git a/testing/adios2/engine/staging-common/CMakeLists.txt b/testing/adios2/engine/staging-common/CMakeLists.txt index 7d7053b63f..a2b8d343d6 100644 --- a/testing/adios2/engine/staging-common/CMakeLists.txt +++ b/testing/adios2/engine/staging-common/CMakeLists.txt @@ -94,7 +94,7 @@ if(ADIOS2_HAVE_MPI AND MPIEXEC_EXECUTABLE) endforeach() endif() -set (SIMPLE_TESTS "1x1;NoReaderNoWait;TimeoutOnOpen;1x1.NoData;1x1.Modes;1x1.Attrs;1x1.Local;1x1.SharedNothing;1x1.SharedIO;1x1.SharedVar;1x1.SharedNothingSync;1x1.SharedIOSync;1x1.SharedVarSync;1x1EarlyExit") +set (SIMPLE_TESTS "1x1;NoReaderNoWait;TimeoutOnOpen;1x1.NoData;1x1.Modes;1x1.Attrs;1x1.Local;1x1.SharedNothing;1x1.SharedIO;1x1.SharedVar;1x1.SharedNothingSync;1x1.SharedIOSync;1x1.SharedVarSync;1x1EarlyExit;CumulativeAttr.1x1") set (SIMPLE_FORTRAN_TESTS "") if(ADIOS2_HAVE_Fortran) diff --git a/testing/adios2/engine/staging-common/ParseArgs.h b/testing/adios2/engine/staging-common/ParseArgs.h index 9a1f0e37f3..eb66abd102 100644 --- a/testing/adios2/engine/staging-common/ParseArgs.h +++ b/testing/adios2/engine/staging-common/ParseArgs.h @@ -33,6 +33,7 @@ int LongFirstDelay = 0; int FirstTimestepMustBeZero = 0; int LockGeometry = 0; bool VaryingDataSize = false; +bool AdvancingAttrs = false; int NoData = 0; int NoDataNode = -1; int EarlyExit = 0; @@ -218,6 +219,10 @@ static void ParseArgs(int argc, char **argv) { VaryingDataSize = true; } + else if (std::string(argv[1]) == "--advancing_attributes") + { + AdvancingAttrs = true; + } else if (std::string(argv[1]) == "--long_first_delay") { LongFirstDelay = 1; diff --git a/testing/adios2/engine/staging-common/TestCommonClient.cpp b/testing/adios2/engine/staging-common/TestCommonClient.cpp index 2fb4513e1c..14e7d379b8 100644 --- a/testing/adios2/engine/staging-common/TestCommonClient.cpp +++ b/testing/adios2/engine/staging-common/TestCommonClient.cpp @@ -287,6 +287,31 @@ TEST_F(SstReadTest, ADIOS2SstRead) EXPECT_EQ(validateCommonTestData(myStart, myLength, currentStep, 0), 0); write_times.push_back(write_time); + if (AdvancingAttrs) + { + /* we only succeed if every attribute from every prior step is + * there, but not the next few */ + for (int step = 0; step <= currentStep + 2; step++) + { + const std::string r64_Single = + std::string("r64_PerStep_") + std::to_string(step); + auto attr_r64 = io.InquireAttribute(r64_Single); + std::cout << "Testing for attribute " << r64_Single + << std::endl; + if (step <= currentStep) + { + EXPECT_TRUE(attr_r64); + ASSERT_EQ(attr_r64.Data().size() == 1, true); + ASSERT_EQ(attr_r64.Type(), adios2::GetType()); + ASSERT_EQ(attr_r64.Data().front(), + (double)(step * 10.0)); + } + else + { + EXPECT_FALSE(attr_r64); + } + } + } } catch (...) { @@ -305,6 +330,8 @@ TEST_F(SstReadTest, ADIOS2SstRead) break; } } + std::cout << "Reader finished with step " << ExpectedStep - 1 + << std::endl; if (IncreasingDelay && !DelayWhileHoldingStep) { std::this_thread::sleep_for(std::chrono::milliseconds( diff --git a/testing/adios2/engine/staging-common/TestCommonRead.cpp b/testing/adios2/engine/staging-common/TestCommonRead.cpp index 1afb5e1fde..9524b5e7aa 100644 --- a/testing/adios2/engine/staging-common/TestCommonRead.cpp +++ b/testing/adios2/engine/staging-common/TestCommonRead.cpp @@ -367,6 +367,33 @@ TEST_F(CommonReadTest, ADIOS2CommonRead1D8) << " timestep " << t << std::endl; } EXPECT_EQ(result, 0); + if (AdvancingAttrs) + { + /* we only succeed if every attribute from every prior step is + * there, but not the next few */ + for (int step = 0; step <= currentStep + 2; step++) + { + const std::string r64_Single = + std::string("r64_PerStep_") + std::to_string(step); + auto attr_r64 = io.InquireAttribute(r64_Single); + std::cout << "Testing for attribute " << r64_Single + << std::endl; + if (step <= currentStep) + { + EXPECT_TRUE(attr_r64); + ASSERT_EQ(attr_r64.Data().size() == 1, true); + ASSERT_EQ(attr_r64.Type(), adios2::GetType()); + ASSERT_EQ(attr_r64.Data().front(), + (double)(step * 10.0)); + } + else + { + // The file engines let attributes appear early, so only + // enforce non-appearance if that changes. + // EXPECT_FALSE(attr_r64); + } + } + } write_times.push_back(write_time); } else diff --git a/testing/adios2/engine/staging-common/TestCommonServer.cpp b/testing/adios2/engine/staging-common/TestCommonServer.cpp index b8cdf5d9fc..a85bddbc04 100644 --- a/testing/adios2/engine/staging-common/TestCommonServer.cpp +++ b/testing/adios2/engine/staging-common/TestCommonServer.cpp @@ -158,7 +158,14 @@ TEST_F(CommonServerTest, ADIOS2CommonServer) // we'll never change our data decomposition engine.LockWriterDefinitions(); } + if (AdvancingAttrs) + { + const std::string r64_Single = + std::string("r64_PerStep_") + std::to_string(step); + io.DefineAttribute(r64_Single, (double)(step * 10.0)); + } engine.EndStep(); + std::cout << "Writer finished step " << step << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds( DelayMS)); /* sleep for DelayMS milliseconds */ step++; diff --git a/testing/adios2/engine/staging-common/TestCommonWrite.cpp b/testing/adios2/engine/staging-common/TestCommonWrite.cpp index 4983d374f6..f5ee2985ca 100644 --- a/testing/adios2/engine/staging-common/TestCommonWrite.cpp +++ b/testing/adios2/engine/staging-common/TestCommonWrite.cpp @@ -224,6 +224,13 @@ TEST_F(CommonWriteTest, ADIOS2CommonWrite) // we'll never change our data decomposition engine.LockWriterDefinitions(); } + if (AdvancingAttrs) + { + const std::string r64_Single = + std::string("r64_PerStep_") + std::to_string(step); + io.DefineAttribute(r64_Single, (double)(step * 10.0)); + std::cout << "Dumping attribute " << r64_Single << std::endl; + } engine.EndStep(); std::this_thread::sleep_for(std::chrono::milliseconds( DelayMS)); /* sleep for DelayMS milliseconds */ diff --git a/testing/adios2/engine/staging-common/TestSupp.cmake b/testing/adios2/engine/staging-common/TestSupp.cmake index a518aae7be..20628fcdb2 100644 --- a/testing/adios2/engine/staging-common/TestSupp.cmake +++ b/testing/adios2/engine/staging-common/TestSupp.cmake @@ -163,6 +163,9 @@ set (LatestReaderHold.1x1_CMD "run_test.py.$ --test_protocol one_client # A faster writer and a queue policy that will cause timesteps to be discarded set (DiscardWriter.1x1_CMD "run_test.py.$ --test_protocol one_client -nw 1 -nr 1 --warg=--engine_params --warg=QueueLimit=1,QueueFullPolicy=discard,WENGINE_PARAMS --warg=--ms_delay --warg=250 --rarg=--discard") +# Readers using Advancing attributes +set (CumulativeAttr.1x1_CMD "run_test.py.$ -nw 1 -nr 1 --warg=--advancing_attributes --rarg=--advancing_attributes") + function(remove_engine_params_placeholder dst_str src_str ) string(REGEX REPLACE "([^ ]*),WENGINE_PARAMS" "\\1" src_str "${src_str}") string(REGEX REPLACE "([^ ]*),RENGINE_PARAMS" "\\1" src_str "${src_str}")