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/05/25 03:21:25 UTC

[GitHub] [incubator-inlong] LvJiancheng commented on a diff in pull request #4343: [INLONG-4228][Manager] Adaptive File System Load Node

LvJiancheng commented on code in PR #4343:
URL: https://github.com/apache/incubator-inlong/pull/4343#discussion_r881181805


##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/sink/HdfsStreamSinkServiceTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.sink;
+
+import org.apache.inlong.manager.common.enums.GlobalConstants;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.sink.SinkResponse;
+import org.apache.inlong.manager.common.pojo.sink.hdfs.HdfsSinkRequest;
+import org.apache.inlong.manager.common.pojo.sink.hdfs.HdfsSinkResponse;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.service.ServiceBaseTest;
+import org.apache.inlong.manager.service.core.impl.InlongStreamServiceTest;
+import org.apache.inlong.manager.service.sink.StreamSinkService;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class HdfsStreamSinkServiceTest extends ServiceBaseTest {
+
+    private static final String globalGroupId = "b_group_hdfs";
+    private static final String globalStreamId = "stream1_hdfs";
+    private static final String globalOperator = "admin";
+    private static final String fileFormat = "TextFile";
+    private static final String dataPath = "hdfs://ip:port/usr/hive/warehouse/test.db";
+    private static final String serverTimeZone = "GMT%2b8";
+
+    @Autowired
+    private StreamSinkService sinkService;
+    @Autowired
+    private InlongStreamServiceTest streamServiceTest;
+
+    /**
+     * Save sink info.
+     */
+    public Integer saveSink(String sinkName) {
+        streamServiceTest.saveInlongStream(globalGroupId, globalStreamId, globalOperator);
+
+        HdfsSinkRequest hdfsSinkRequest = new HdfsSinkRequest();
+        hdfsSinkRequest.setInlongGroupId(globalGroupId);
+        hdfsSinkRequest.setInlongStreamId(globalStreamId);
+        hdfsSinkRequest.setSinkType(SinkType.SINK_HDFS);
+        hdfsSinkRequest.setEnableCreateResource(GlobalConstants.DISABLE_CREATE_RESOURCE);
+        hdfsSinkRequest.setSinkName(sinkName);
+        hdfsSinkRequest.setFileFormat(fileFormat);
+        hdfsSinkRequest.setDataPath(dataPath);
+        hdfsSinkRequest.setServerTimeZone(serverTimeZone);
+        return sinkService.save(hdfsSinkRequest, globalOperator);
+    }
+
+    /**
+     * Delete Hdfs sink info by sink id.
+     */
+    public void deleteHdfsSink(Integer hdfsSinkId) {
+        boolean result = sinkService.delete(hdfsSinkId, globalOperator);
+        Assert.assertTrue(result);
+    }
+
+    @Test
+    public void testListByIdentifier() {
+        Integer hdfsSinkId = this.saveSink("default_hdfs");
+        SinkResponse sink = sinkService.get(hdfsSinkId);
+        Assert.assertEquals(globalGroupId, sink.getInlongGroupId());
+        deleteHdfsSink(hdfsSinkId);
+    }
+

Review Comment:
   done



##########
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/sink/HdfsStreamSinkServiceTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.sink;
+
+import org.apache.inlong.manager.common.enums.GlobalConstants;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.sink.SinkResponse;
+import org.apache.inlong.manager.common.pojo.sink.hdfs.HdfsSinkRequest;
+import org.apache.inlong.manager.common.pojo.sink.hdfs.HdfsSinkResponse;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.service.ServiceBaseTest;
+import org.apache.inlong.manager.service.core.impl.InlongStreamServiceTest;
+import org.apache.inlong.manager.service.sink.StreamSinkService;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class HdfsStreamSinkServiceTest extends ServiceBaseTest {
+
+    private static final String globalGroupId = "b_group_hdfs";
+    private static final String globalStreamId = "stream1_hdfs";
+    private static final String globalOperator = "admin";
+    private static final String fileFormat = "TextFile";
+    private static final String dataPath = "hdfs://ip:port/usr/hive/warehouse/test.db";
+    private static final String serverTimeZone = "GMT%2b8";
+
+    @Autowired
+    private StreamSinkService sinkService;
+    @Autowired
+    private InlongStreamServiceTest streamServiceTest;
+
+    /**
+     * Save sink info.
+     */
+    public Integer saveSink(String sinkName) {
+        streamServiceTest.saveInlongStream(globalGroupId, globalStreamId, globalOperator);
+
+        HdfsSinkRequest hdfsSinkRequest = new HdfsSinkRequest();
+        hdfsSinkRequest.setInlongGroupId(globalGroupId);
+        hdfsSinkRequest.setInlongStreamId(globalStreamId);
+        hdfsSinkRequest.setSinkType(SinkType.SINK_HDFS);
+        hdfsSinkRequest.setEnableCreateResource(GlobalConstants.DISABLE_CREATE_RESOURCE);
+        hdfsSinkRequest.setSinkName(sinkName);
+        hdfsSinkRequest.setFileFormat(fileFormat);
+        hdfsSinkRequest.setDataPath(dataPath);
+        hdfsSinkRequest.setServerTimeZone(serverTimeZone);
+        return sinkService.save(hdfsSinkRequest, globalOperator);
+    }
+
+    /**
+     * Delete Hdfs sink info by sink id.
+     */
+    public void deleteHdfsSink(Integer hdfsSinkId) {
+        boolean result = sinkService.delete(hdfsSinkId, globalOperator);
+        Assert.assertTrue(result);
+    }
+
+    @Test

Review Comment:
   done



-- 
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