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 2022/10/06 00:45:53 UTC
[GitHub] [nifi] MikeThomsen commented on a diff in pull request #6487: NIFI-10437 Converted the Elasticsearch client service tests from Groovy to Java and added Testcontainers integration
MikeThomsen commented on code in PR #6487:
URL: https://github.com/apache/nifi/pull/6487#discussion_r988459943
##########
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/test/java/org/apache/nifi/elasticsearch/integration/ElasticSearchLookupService_IT.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * 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.
+ */
+
+package org.apache.nifi.elasticsearch.integration;
+
+import org.apache.nifi.elasticsearch.ElasticSearchClientService;
+import org.apache.nifi.elasticsearch.ElasticSearchClientServiceImpl;
+import org.apache.nifi.elasticsearch.ElasticSearchLookupService;
+import org.apache.nifi.elasticsearch.TestControllerServiceProcessor;
+import org.apache.nifi.elasticsearch.TestSchemaRegistry;
+import org.apache.nifi.lookup.LookupFailureException;
+import org.apache.nifi.record.path.RecordPath;
+import org.apache.nifi.record.path.RecordPathResult;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.schemaregistry.services.SchemaRegistry;
+import org.apache.nifi.serialization.record.MapRecord;
+import org.apache.nifi.serialization.record.Record;
+import org.apache.nifi.serialization.record.RecordSchema;
+import org.apache.nifi.serialization.record.type.RecordDataType;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ElasticSearchLookupService_IT extends AbstractElasticsearchIT {
+ private TestRunner runner;
+ private ElasticSearchClientService service;
+ private ElasticSearchLookupService lookupService;
+
+ @BeforeAll
+ public static void beforeAll() throws IOException {
+ setupTestData();
+ }
+
+ @BeforeEach
+ void before() throws Exception {
+ runner = TestRunners.newTestRunner(TestControllerServiceProcessor.class);
+ service = new ElasticSearchClientServiceImpl();
+ lookupService = new ElasticSearchLookupService();
+ runner.addControllerService("Client Service", service);
+ runner.addControllerService("Lookup Service", lookupService);
+ runner.setProperty(service, ElasticSearchClientService.HTTP_HOSTS, String.format("http://%s", ELASTICSEARCH_CONTAINER.getHttpHostAddress()));
+ runner.setProperty(service, ElasticSearchClientService.CONNECT_TIMEOUT, "10000");
+ runner.setProperty(service, ElasticSearchClientService.SOCKET_TIMEOUT, "60000");
+ runner.setProperty(service, ElasticSearchClientService.USERNAME, "elastic");
+ runner.setProperty(service, ElasticSearchClientService.PASSWORD, "s3cret");
+ runner.setProperty(TestControllerServiceProcessor.CLIENT_SERVICE, "Client Service");
+ runner.setProperty(TestControllerServiceProcessor.LOOKUP_SERVICE, "Lookup Service");
+ runner.setProperty(lookupService, ElasticSearchLookupService.CLIENT_SERVICE, "Client Service");
+ runner.setProperty(lookupService, ElasticSearchLookupService.INDEX, "user_details");
+ setTypeOnLookupService();
+
+ try {
+ runner.enableControllerService(service);
+ runner.enableControllerService(lookupService);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+
+ service.refresh(null, null);
+ }
+
+ void setTypeOnLookupService() {
+ if (getElasticMajorVersion() == 6) {
Review Comment:
I think we're going to start deprecating test coverage for 5 given it doesn't seem to work with Testcontainers and is so old.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org