Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-8147

Detect invalid syntax in cppsuite configs

    • 3
    • Storage - Ra 2021-10-18

      The framework currently does not detect invalid configurations due to syntax errors.

      Reproducing the issue:

      Introduce a syntax error:

      diff --git a/test/cppsuite/configs/base_test_default.txt b/test/cppsuite/configs/base_test_default.txt
      index 986dd1937..0a689b8c2 100644
      --- a/test/cppsuite/configs/base_test_default.txt
      +++ b/test/cppsuite/configs/base_test_default.txt
      @@ -25,7 +25,7 @@ runtime_monitor=
       timestamp_manager=
       (
           enabled=true,
      -    oldest_lag=2,
      +    oldest_lag=2
           op_rate=500ms,
           stable_lag=2 

      Run the test:

      ./run -t base_test -l 2 

      You should see the configuration in the log and especially this bit:

      timestamp_manager=(enabled=true,oldest_lag=1,op_rate=1s,stable_lag=1) 

      The oldest_lag is set to its default value of 1 second instead of the user-defined 2 seconds.

      By adding more traces in the code, especially in the split_config function, I could see the following during the parsing of the configuration:

      enabled=true,oldest_lag=2op_rate=500ms,stable_lag=2 

      Suggested fixes:

      Exit the test by telling the user there is a syntax issue

      diff --git a/test/cppsuite/test_harness/core/configuration.cxx b/test/cppsuite/test_harness/core/configuration.cxx
      index b6c533979..ffb146091 100644
      --- a/test/cppsuite/test_harness/core/configuration.cxx
      +++ b/test/cppsuite/test_harness/core/configuration.cxx
      @@ -258,6 +258,8 @@ configuration::split_config(const std::string &config)
                   in_subconfig = !parens.empty();
               }
               if (cut_config[i] == '=' && !in_subconfig) {
      +            testutil_assert(expect_value == false);
      +            testutil_assert(len > 0);
                   expect_value = true;
                   key = cut_config.substr(start, len);
                   start += len + 1; 

       

      Definition of done:

      Make sure the framework is robust against syntax errors in the configuration files. More changes in the parsing function might be required.

            Assignee:
            alison.felizzi@mongodb.com Alison Felizzi (Inactive)
            Reporter:
            etienne.petrel@mongodb.com Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: