You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/09/04 15:08:03 UTC

[GitHub] [inlong] ciscozhou opened a new pull request, #5777: [INLONG-5775][Manager] Add unit tests for the Inlong Consume

ciscozhou opened a new pull request, #5777:
URL: https://github.com/apache/inlong/pull/5777

   ### Prepare a Pull Request
   
   - Fixes #5775 
   
   ### Motivation
   
   *There is no unit test for the Inlong Consume.*
   
   ### Modifications
   
   *Add unit tests for the Inlong Consume.*
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
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: commits-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow merged pull request #5777: [INLONG-5775][Manager] Add unit tests for the Inlong Consume

Posted by GitBox <gi...@apache.org>.
healchow merged PR #5777:
URL: https://github.com/apache/inlong/pull/5777


-- 
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: commits-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow commented on a diff in pull request #5777: [INLONG-5775][Manager] Add unit tests for the Inlong Consume

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #5777:
URL: https://github.com/apache/inlong/pull/5777#discussion_r962331934


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/consume/InlongConsumeServiceTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.inlong.manager.service.core.consume;
+
+import org.apache.inlong.manager.common.consts.MQType;
+import org.apache.inlong.manager.pojo.consume.InlongConsumeInfo;
+import org.apache.inlong.manager.pojo.consume.pulsar.ConsumePulsarRequest;
+import org.apache.inlong.manager.service.consume.InlongConsumeService;
+import org.apache.inlong.manager.service.core.impl.InlongStreamServiceTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.TestComponent;
+
+/**
+ * Inlong consume service test
+ */
+@TestComponent
+public class InlongConsumeServiceTest {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(InlongConsumeServiceTest.class);
+
+    String groupId = "consume_service_test_group";
+    String streamId = "consume_service_test_stream";
+    String consumerGroup = "test_consumer_group";
+    String operator = "admin";
+
+    @Autowired
+    private InlongStreamServiceTest streamServiceTest;
+    @Autowired
+    private InlongConsumeService consumeService;
+
+    /**
+     * Test save inlong consume
+     */
+    public Integer saveInlongConsume(Integer consumeId, String groupId, String streamId, String operator) {
+        try {
+            InlongConsumeInfo consumeInfo = consumeService.get(consumeId);
+            if (consumeInfo != null) {
+                return consumeInfo.getId();
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+
+        streamServiceTest.saveInlongStream(groupId, streamId, operator);
+
+        ConsumePulsarRequest request = new ConsumePulsarRequest();
+        request.setInlongGroupId(groupId);
+        request.setInlongStreamId(streamId);
+        request.setMqType(MQType.PULSAR);
+        request.setConsumerGroup(consumerGroup);
+        request.setInCharges("admin");
+        request.setIsDlq(1);
+        request.setDeadLetterTopic("test_dlp");
+        request.setIsRlq(0);
+
+        return consumeService.save(request, operator);
+    }
+
+    // @Test
+    public void testSaveAndDelete() {
+        Integer consumeId = 1;
+        Integer id = this.saveInlongConsume(consumeId, streamId, groupId, operator);
+        Assertions.assertNotNull(id);
+
+        boolean result = consumeService.delete(id, operator);
+        Assertions.assertTrue(result);
+    }
+
+    @Test
+    public void test() {
+        LOGGER.info("If you don't add test, UnusedImports: Unused import: org.junit.Test.");

Review Comment:
   A unit test should execute some specific business logic, just printing a log seems not good.



-- 
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: commits-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow commented on a diff in pull request #5777: [INLONG-5775][Manager] Add unit tests for the Inlong Consume

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #5777:
URL: https://github.com/apache/inlong/pull/5777#discussion_r962331608


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/consume/InlongConsumeServiceTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.inlong.manager.service.core.consume;
+
+import org.apache.inlong.manager.common.consts.MQType;
+import org.apache.inlong.manager.pojo.consume.InlongConsumeInfo;
+import org.apache.inlong.manager.pojo.consume.pulsar.ConsumePulsarRequest;
+import org.apache.inlong.manager.service.consume.InlongConsumeService;
+import org.apache.inlong.manager.service.core.impl.InlongStreamServiceTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.TestComponent;
+
+/**
+ * Inlong consume service test
+ */
+@TestComponent
+public class InlongConsumeServiceTest {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(InlongConsumeServiceTest.class);
+
+    String groupId = "consume_service_test_group";
+    String streamId = "consume_service_test_stream";
+    String consumerGroup = "test_consumer_group";
+    String operator = "admin";
+
+    @Autowired
+    private InlongStreamServiceTest streamServiceTest;
+    @Autowired
+    private InlongConsumeService consumeService;
+
+    /**
+     * Test save inlong consume
+     */
+    public Integer saveInlongConsume(Integer consumeId, String groupId, String streamId, String operator) {
+        try {
+            InlongConsumeInfo consumeInfo = consumeService.get(consumeId);
+            if (consumeInfo != null) {
+                return consumeInfo.getId();
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+
+        streamServiceTest.saveInlongStream(groupId, streamId, operator);
+
+        ConsumePulsarRequest request = new ConsumePulsarRequest();
+        request.setInlongGroupId(groupId);
+        request.setInlongStreamId(streamId);
+        request.setMqType(MQType.PULSAR);
+        request.setConsumerGroup(consumerGroup);
+        request.setInCharges("admin");
+        request.setIsDlq(1);
+        request.setDeadLetterTopic("test_dlp");
+        request.setIsRlq(0);
+
+        return consumeService.save(request, operator);
+    }
+
+    // @Test

Review Comment:
   Why comment this out?



-- 
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: commits-unsubscribe@inlong.apache.org

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