You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/11/11 15:04:12 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #920: MINIFICPP-1296 - All tests should use volatile state storage

szaszm commented on a change in pull request #920:
URL: https://github.com/apache/nifi-minifi-cpp/pull/920#discussion_r521406606



##########
File path: libminifi/test/keyvalue-tests/UnorderedMapKeyValueStoreServiceTest.cpp
##########
@@ -0,0 +1,173 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define CATCH_CONFIG_RUNNER
+#include <string>
+#include "../TestBase.h"
+#include "core/controller/ControllerService.h"
+#include "core/ProcessGroup.h"
+#include "core/yaml/YamlConfiguration.h"
+
+#include "catch.hpp"
+
+namespace {
+  std::string config_yaml; // NOLINT
+
+  void configYamlHandler(Catch::ConfigData&, const std::string& path) {
+    config_yaml = path;
+  }
+}
+
+int main(int argc, char* argv[]) {
+  Catch::Session session;
+
+  auto& cli = const_cast<Catch::Clara::CommandLine<Catch::ConfigData>&>(session.cli());
+  cli["--config-yaml"]
+          .describe("path to the config.yaml containing the UnorderedMapKeyValueStoreServiceTest controller service configuration")
+          .bind(&configYamlHandler, "path");
+
+  int ret = session.applyCommandLine(argc, argv);
+  if (ret != 0) {
+    return ret;
+  }
+
+  if (config_yaml.empty()) {
+    std::cerr << "Missing --config-yaml <path>. It must contain the path to the config.yaml containing the UnorderedMapKeyValueStoreServiceTest controller service configuration." << std::endl;
+    return -1;
+  }
+
+  return session.run();
+}
+
+class UnorderedMapKeyValueStoreServiceTestFixture {

Review comment:
       Minor, optional:
   Since `UnorderedMapKeyValueStoreService` just became a `PersistableKeyValueStoreService`, I would add a test that you can actually treat it as persistable. A simple
   
   ```
   static_assert(std::is_convertible<UnorderedMapKeyValueStoreService*, PersistableKeyValueStoreService*>::value, "UnorderedMapKeyValueStoreService is a PersistableKeyValueStoreService");
   ```
   
   should do the trick. Or check that `unorderedMapKeyValueStoreService->persist()` is a valid boolean expression.

##########
File path: libminifi/test/TestBase.h
##########
@@ -282,18 +274,10 @@ class TestPlan {
     return prov_repo_;
   }
 
-  std::shared_ptr<core::ContentRepository> getContentRepo() {
-    return content_repo_;
-  }
-
   std::shared_ptr<logging::Logger> getLogger() const {
     return logger_;
   }
 
-  std::string getStateDir() {
-    return state_dir_;
-  }
-

Review comment:
       ```
   /home/szaszm/nifi-minifi-cpp-2/extensions/sftp/tests/ListSFTPTests.cpp: In member function ‘void ListSFTPTestsFixture::createPlan(org::apache::nifi::minifi::utils::Identifier*)’:
   /home/szaszm/nifi-minifi-cpp-2/extensions/sftp/tests/ListSFTPTests.cpp:92:64: error: ‘using element_type = class TestPlan’ {aka ‘class TestPlan’} has no member named ‘getStateDir’
   92 |     const std::string state_dir = plan == nullptr ? "" : plan->getStateDir();
   |                                                                ^~~~~~~~~~~
   make[2]: *** [extensions/sftp/tests/CMakeFiles/ListSFTPTests.dir/build.make:82: extensions/sftp/tests/CMakeFiles/ListSFTPTests.dir/ListSFTPTests.cpp.o] Error 1
   make[1]: *** [CMakeFiles/Makefile2:8318: extensions/sftp/tests/CMakeFiles/ListSFTPTests.dir/all] Error 2
   make[1]: *** Waiting for unfinished jobs....
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org