You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/08/08 06:15:29 UTC

[incubator-linkis] branch dev-1.2.0 updated: add test case for shell engine (#2620)

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
     new af2eef66c add test case for shell engine (#2620)
af2eef66c is described below

commit af2eef66c1581d9d0b89f90023d71d808af3115e
Author: QuintinTao <72...@users.noreply.github.com>
AuthorDate: Mon Aug 8 14:15:24 2022 +0800

    add test case for shell engine (#2620)
    
    * add test case for shell engine
    
    * modify the application name of the test case
---
 .../shell/TestShellEngineConnPlugin.scala          | 30 +++++++++++++
 .../common/TestShellEngineConnPluginConst.scala    | 27 ++++++++++++
 .../exception/TestNoCorrectUserException.scala     | 34 +++++++++++++++
 .../executor/TestShellEngineConnExecutor.scala     | 51 ++++++++++++++++++++++
 4 files changed, 142 insertions(+)

diff --git a/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/TestShellEngineConnPlugin.scala b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/TestShellEngineConnPlugin.scala
new file mode 100644
index 000000000..d79432f7f
--- /dev/null
+++ b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/TestShellEngineConnPlugin.scala
@@ -0,0 +1,30 @@
+/*
+ * 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.linkis.manager.engineplugin.shell
+
+import org.junit.jupiter.api.{Assertions, Test}
+
+class TestShellEngineConnPlugin {
+  @Test
+  def testShellEngineConnExecutor: Unit = {
+      val shellEngineConnPlugin = new ShellEngineConnPlugin
+    Assertions.assertNotNull(shellEngineConnPlugin.getEngineConnFactory)
+    Assertions.assertNotNull(shellEngineConnPlugin.getEngineConnLaunchBuilder)
+    Assertions.assertNotNull(shellEngineConnPlugin.getEngineResourceFactory)
+    Assertions.assertNotNull(shellEngineConnPlugin.getDefaultLabels)
+  }
+}
diff --git a/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/common/TestShellEngineConnPluginConst.scala b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/common/TestShellEngineConnPluginConst.scala
new file mode 100644
index 000000000..c371b79ec
--- /dev/null
+++ b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/common/TestShellEngineConnPluginConst.scala
@@ -0,0 +1,27 @@
+/*
+ * 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.linkis.manager.engineplugin.shell.common
+
+import org.junit.jupiter.api.{Assertions, Test}
+
+class TestShellEngineConnPluginConst {
+  @Test
+  def testShellEngineConnPluginConst: Unit = {
+    Assertions.assertEquals("extraArguments", ShellEngineConnPluginConst.RUNTIME_ARGS_KEY)
+    Assertions.assertEquals("wds.linkis.shell.runtime.working.directory", ShellEngineConnPluginConst.SHELL_RUNTIME_WORKING_DIRECTORY)
+  }
+}
diff --git a/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/exception/TestNoCorrectUserException.scala b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/exception/TestNoCorrectUserException.scala
new file mode 100644
index 000000000..6dd1da977
--- /dev/null
+++ b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/exception/TestNoCorrectUserException.scala
@@ -0,0 +1,34 @@
+/*
+ * 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.linkis.manager.engineplugin.shell.exception
+
+import org.junit.jupiter.api.{Assertions, Test}
+
+class TestNoCorrectUserException {
+  @Test
+  def testNoCorrectUserException: Unit = {
+
+    val exception = NoCorrectUserException
+    Assertions.assertNotNull(exception)
+  }
+  @Test
+  def testShellCodeErrorException: Unit = {
+
+    val exception = ShellCodeErrorException
+    Assertions.assertNotNull(exception)
+  }
+}
diff --git a/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/executor/TestShellEngineConnExecutor.scala b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/executor/TestShellEngineConnExecutor.scala
new file mode 100644
index 000000000..14876fc65
--- /dev/null
+++ b/linkis-engineconn-plugins/shell/src/test/scala/org/apache/linkis/manager/engineplugin/shell/executor/TestShellEngineConnExecutor.scala
@@ -0,0 +1,51 @@
+/*
+ * 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.linkis.manager.engineplugin.shell.executor
+import org.apache.linkis.DataWorkCloudApplication
+import org.apache.linkis.common.conf.DWCArgumentsParser
+import org.apache.linkis.common.utils.Utils
+import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext
+import org.junit.jupiter.api.{Assertions, Test}
+import scala.collection.mutable
+
+class TestShellEngineConnExecutor {
+  @Test
+  def testShellEngineConnExecutor: Unit = {
+    val isWindows = System.getProperty("os.name").startsWith("Windows")
+
+    System.setProperty("wds.linkis.server.version", "v1")
+    System.setProperty("wds.linkis.engineconn.plugin.default.class", "org.apache.linkis.manager.engineplugin.shell.ShellEngineConnPlugin")
+    val map = new mutable.HashMap[String, String]()
+    map.put("spring.mvc.servlet.path", "/api/rest_j/v1")
+    map.put("server.port", "26380")
+    map.put("spring.application.name", "shellEngineExecutor")
+    map.put("eureka.client.register-with-eureka", "false")
+    map.put("eureka.client.fetch-registry", "false")
+    DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(map.toMap))
+    val shellEngineConnExecutor = new ShellEngineConnExecutor(1)
+    shellEngineConnExecutor.init()
+    Assertions.assertTrue(shellEngineConnExecutor.isEngineInitialized)
+    if(!isWindows) {
+
+      val engineExecutionContext = new EngineExecutionContext(shellEngineConnExecutor, Utils.getJvmUser)
+      val response = shellEngineConnExecutor.executeLine(engineExecutionContext, "id")
+      Assertions.assertNotNull(response)
+      shellEngineConnExecutor.close()
+    }
+
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org