You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by GitBox <gi...@apache.org> on 2022/07/13 12:03:14 UTC

[GitHub] [incubator-linkis] QuintinTao opened a new pull request, #2464: Dev 1.2.0

QuintinTao opened a new pull request, #2464:
URL: https://github.com/apache/incubator-linkis/pull/2464

   - Added tests for spark engine
   
   In order to run test case I modified pom file.please check it.


-- 
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: notifications-unsubscribe@linkis.apache.org

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


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


[GitHub] [incubator-linkis] CCweixiao closed pull request #2464: Add test for sprak engine

Posted by GitBox <gi...@apache.org>.
CCweixiao closed pull request #2464: Add test for sprak engine
URL: https://github.com/apache/incubator-linkis/pull/2464


-- 
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: notifications-unsubscribe@linkis.apache.org

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


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


[GitHub] [incubator-linkis] peacewong commented on a diff in pull request #2464: Add test for sprak engine

Posted by GitBox <gi...@apache.org>.
peacewong commented on code in PR #2464:
URL: https://github.com/apache/incubator-linkis/pull/2464#discussion_r921751979


##########
linkis-engineconn-plugins/spark/pom.xml:
##########
@@ -349,9 +370,29 @@
                     <groupId>log4j</groupId>
                     <artifactId>apache-log4j-extras</artifactId>
                 </exclusion>
+                <exclusion>
+                    <artifactId>commons-compiler</artifactId>
+                    <groupId>org.codehaus.janino</groupId>
+                </exclusion>
+
+                <exclusion>
+                    <artifactId>janino</artifactId>
+                    <groupId>org.codehaus.janino</groupId>
+                </exclusion>
             </exclusions>
         </dependency>
-
+        <dependency>
+            <artifactId>janino</artifactId>
+            <groupId>org.codehaus.janino</groupId>
+            <version>3.0.9</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.linkis</groupId>
+            <artifactId>linkis-engineplugin-hive</artifactId>
+            <version>1.1.3</version>

Review Comment:
   should to remove hive ec dependency



##########
linkis-engineconn-plugins/spark/src/test/scala/org/apache/linkis/engineplugin/spark/executor/TestSparkSqlExecutor.scala:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.engineplugin.spark.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.apache.linkis.engineplugin.spark.entity.SparkEngineSession
+import org.apache.linkis.engineplugin.spark.factory.SparkEngineConnFactory
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+import org.junit.jupiter.api.{Assertions, Test}
+
+import scala.collection.mutable
+
+class TestSparkSqlExecutor{
+  @Test
+  def testCreateContext: Unit = {
+    System.setProperty("wds.linkis.server.version", "v1")
+    val map = new mutable.HashMap[String, String]()
+    map.put("spring.mvc.servlet.path", "/api/rest_j/v1")
+    map.put("server.port", "26378")
+    map.put("spring.application.name", "SparkSqlExecutor")
+    map.put("eureka.client.register-with-eureka", "false")
+    DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(map.toMap))
+    val engineFactory = new SparkEngineConnFactory
+    val sparkConf = new SparkConf(true)
+    System.setProperty("java.io.tmpdir", "./")
+    val sparkSession = SparkSession.builder()
+      .master("local[*]")
+      .appName("testSparkSqlExecutor").getOrCreate()
+    val outputDir = engineFactory.createOutputDir(sparkConf)
+    val sparkEngineSession = SparkEngineSession(sparkSession.sparkContext, sparkSession.sqlContext, sparkSession, outputDir)
+    val sparkSqlExecutor = new SparkSqlExecutor(sparkEngineSession, 1L)
+    Assertions.assertFalse(sparkSqlExecutor.isEngineInitialized)
+    sparkSqlExecutor.init()
+    Assertions.assertTrue(sparkSqlExecutor.isEngineInitialized)
+    val engineExecutionContext = new EngineExecutionContext(sparkSqlExecutor, Utils.getJvmUser)
+    val code = " val spark = SparkSession.builder().appName(\"Test extract\")\n      " +
+      ".config(\"spark.some.config.option\", \"some-value\").master(\"local[*]\").getOrCreate()\n    " +
+      "val dataFrame = spark.createDataFrame(Seq(\n      " +
+      "(\"ming\", 20, 15552211521L),\n      " +
+      "(\"hong\", 19, 13287994007L),\n      " +
+      "(\"zhi\", 21, 15552211523L)\n    )).toDF(\"name\", \"age\", \"phone\") \n" +
+      "dataFrame.show()\n"
+    val response = sparkSqlExecutor.executeLine(engineExecutionContext, code)

Review Comment:
   should execute sql



##########
linkis-engineconn-plugins/spark/src/test/scala/org/apache/linkis/engineplugin/spark/executor/TestSparkScalaExecutor.scala:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.engineplugin.spark.executor
+
+import org.apache.linkis.common.utils.Utils
+import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext
+import org.apache.linkis.engineplugin.spark.entity.SparkEngineSession
+import org.apache.linkis.engineplugin.spark.factory.{SparkEngineConnFactory}
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+import org.junit.jupiter.api.{Assertions,Test}
+
+
+class TestSparkScalaExecutor {
+
+  @Test
+  def testCreateContext: Unit = {
+    val engineFactory = new SparkEngineConnFactory
+    val sparkConf: SparkConf = new SparkConf(true)
+     System.setProperty("java.io.tmpdir", "./")
+    val sparkSession = SparkSession.builder()
+        .master("local[*]")
+        .appName("test").getOrCreate()
+    val outputDir = engineFactory.createOutputDir(sparkConf)
+    val sparkEngineSession = SparkEngineSession(sparkSession.sparkContext, sparkSession.sqlContext, sparkSession, outputDir)
+    val sparkScalaExecutor = new SparkScalaExecutor(sparkEngineSession, 1L)
+    Assertions.assertFalse(sparkScalaExecutor.isEngineInitialized)
+    sparkScalaExecutor.init()
+    Assertions.assertTrue(sparkScalaExecutor.isEngineInitialized)
+  val engineExecutionContext = new EngineExecutionContext(sparkScalaExecutor, Utils.getJvmUser)
+  val code = " val spark = SparkSession.builder().appName(\"Test extract\")\n      " +

Review Comment:
   can remove sparkSession builder



-- 
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: notifications-unsubscribe@linkis.apache.org

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


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


[GitHub] [incubator-linkis] codecov[bot] commented on pull request #2464: Add test for sprak engine

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #2464:
URL: https://github.com/apache/incubator-linkis/pull/2464#issuecomment-1184156052

   # [Codecov](https://codecov.io/gh/apache/incubator-linkis/pull/2464?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2464](https://codecov.io/gh/apache/incubator-linkis/pull/2464?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5bb93aa) into [dev-1.2.0](https://codecov.io/gh/apache/incubator-linkis/commit/b4627300e2dc80ff3031a5d8140cb34c26941cba?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b462730) will **decrease** coverage by `1.34%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@               Coverage Diff               @@
   ##             dev-1.2.0    #2464      +/-   ##
   ===============================================
   - Coverage        17.83%   16.49%   -1.35%     
   - Complexity        1077     1175      +98     
   ===============================================
     Files              595      700     +105     
     Lines            17667    21871    +4204     
     Branches          2635     3227     +592     
   ===============================================
   + Hits              3151     3607     +456     
   - Misses           14092    17755    +3663     
   - Partials           424      509      +85     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-linkis/pull/2464?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...engineplugin/spark/config/SparkConfiguration.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWVuZ2luZWNvbm4tcGx1Z2lucy9zcGFyay9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9lbmdpbmVwbHVnaW4vc3BhcmsvY29uZmlnL1NwYXJrQ29uZmlndXJhdGlvbi5zY2FsYQ==) | `90.24% <100.00%> (ø)` | |
   | [...apache/linkis/scheduler/future/BDPFutureTask.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWNvbW1vbnMvbGlua2lzLXNjaGVkdWxlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9zY2hlZHVsZXIvZnV0dXJlL0JEUEZ1dHVyZVRhc2suc2NhbGE=) | `70.00% <0.00%> (-5.00%)` | :arrow_down: |
   | [...s/scheduler/queue/fifoqueue/FIFOUserConsumer.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWNvbW1vbnMvbGlua2lzLXNjaGVkdWxlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9zY2hlZHVsZXIvcXVldWUvZmlmb3F1ZXVlL0ZJRk9Vc2VyQ29uc3VtZXIuc2NhbGE=) | `35.55% <0.00%> (-2.23%)` | :arrow_down: |
   | [...org/apache/linkis/common/utils/VariableUtils.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWNvbW1vbnMvbGlua2lzLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9jb21tb24vdXRpbHMvVmFyaWFibGVVdGlscy5zY2FsYQ==) | `59.77% <0.00%> (-0.35%)` | :arrow_down: |
   | [...n/java/org/apache/linkis/common/utils/DESUtil.java](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWNvbW1vbnMvbGlua2lzLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvbGlua2lzL2NvbW1vbi91dGlscy9ERVNVdGlsLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...a/org/apache/linkis/scheduler/event/LogEvent.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWNvbW1vbnMvbGlua2lzLXNjaGVkdWxlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9zY2hlZHVsZXIvZXZlbnQvTG9nRXZlbnQuc2NhbGE=) | `50.00% <0.00%> (ø)` | |
   | [...ache/linkis/common/listener/ListenerEventBus.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWNvbW1vbnMvbGlua2lzLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9jb21tb24vbGlzdGVuZXIvTGlzdGVuZXJFdmVudEJ1cy5zY2FsYQ==) | `0.00% <0.00%> (ø)` | |
   | [.../apache/linkis/jobhistory/cache/utils/MD5Util.java](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLXB1YmxpYy1lbmhhbmNlbWVudHMvbGlua2lzLXB1YmxpY3NlcnZpY2UvbGlua2lzLWpvYmhpc3Rvcnkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2xpbmtpcy9qb2JoaXN0b3J5L2NhY2hlL3V0aWxzL01ENVV0aWwuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...va/org/apache/linkis/bml/common/OperationEnum.java](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLXB1YmxpYy1lbmhhbmNlbWVudHMvbGlua2lzLWJtbC9saW5raXMtYm1sLXNlcnZlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvbGlua2lzL2JtbC9jb21tb24vT3BlcmF0aW9uRW51bS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [.../linkis/engineplugin/spark/utils/EngineUtils.scala](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGlua2lzLWVuZ2luZWNvbm4tcGx1Z2lucy9zcGFyay9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpbmtpcy9lbmdpbmVwbHVnaW4vc3BhcmsvdXRpbHMvRW5naW5lVXRpbHMuc2NhbGE=) | `3.44% <0.00%> (ø)` | |
   | ... and [108 more](https://codecov.io/gh/apache/incubator-linkis/pull/2464/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-linkis/pull/2464?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-linkis/pull/2464?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b462730...5bb93aa](https://codecov.io/gh/apache/incubator-linkis/pull/2464?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@linkis.apache.org

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


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


[GitHub] [incubator-linkis] QuintinTao commented on a diff in pull request #2464: Add test for sprak engine

Posted by GitBox <gi...@apache.org>.
QuintinTao commented on code in PR #2464:
URL: https://github.com/apache/incubator-linkis/pull/2464#discussion_r923907896


##########
linkis-engineconn-plugins/spark/src/test/scala/org/apache/linkis/engineplugin/spark/executor/TestSparkScalaExecutor.scala:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.engineplugin.spark.executor
+
+import org.apache.linkis.common.utils.Utils
+import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext
+import org.apache.linkis.engineplugin.spark.entity.SparkEngineSession
+import org.apache.linkis.engineplugin.spark.factory.{SparkEngineConnFactory}
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+import org.junit.jupiter.api.{Assertions,Test}
+
+
+class TestSparkScalaExecutor {
+
+  @Test
+  def testCreateContext: Unit = {
+    val engineFactory = new SparkEngineConnFactory
+    val sparkConf: SparkConf = new SparkConf(true)
+     System.setProperty("java.io.tmpdir", "./")
+    val sparkSession = SparkSession.builder()
+        .master("local[*]")
+        .appName("test").getOrCreate()
+    val outputDir = engineFactory.createOutputDir(sparkConf)
+    val sparkEngineSession = SparkEngineSession(sparkSession.sparkContext, sparkSession.sqlContext, sparkSession, outputDir)
+    val sparkScalaExecutor = new SparkScalaExecutor(sparkEngineSession, 1L)
+    Assertions.assertFalse(sparkScalaExecutor.isEngineInitialized)
+    sparkScalaExecutor.init()
+    Assertions.assertTrue(sparkScalaExecutor.isEngineInitialized)
+  val engineExecutionContext = new EngineExecutionContext(sparkScalaExecutor, Utils.getJvmUser)
+  val code = " val spark = SparkSession.builder().appName(\"Test extract\")\n      " +

Review Comment:
   > can remove sparkSession builder
   
   OK I removed the SparkSession in the string code. 



##########
linkis-engineconn-plugins/spark/src/test/scala/org/apache/linkis/engineplugin/spark/executor/TestSparkSqlExecutor.scala:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.engineplugin.spark.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.apache.linkis.engineplugin.spark.entity.SparkEngineSession
+import org.apache.linkis.engineplugin.spark.factory.SparkEngineConnFactory
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+import org.junit.jupiter.api.{Assertions, Test}
+
+import scala.collection.mutable
+
+class TestSparkSqlExecutor{
+  @Test
+  def testCreateContext: Unit = {
+    System.setProperty("wds.linkis.server.version", "v1")
+    val map = new mutable.HashMap[String, String]()
+    map.put("spring.mvc.servlet.path", "/api/rest_j/v1")
+    map.put("server.port", "26378")
+    map.put("spring.application.name", "SparkSqlExecutor")
+    map.put("eureka.client.register-with-eureka", "false")
+    DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(map.toMap))
+    val engineFactory = new SparkEngineConnFactory
+    val sparkConf = new SparkConf(true)
+    System.setProperty("java.io.tmpdir", "./")
+    val sparkSession = SparkSession.builder()
+      .master("local[*]")
+      .appName("testSparkSqlExecutor").getOrCreate()
+    val outputDir = engineFactory.createOutputDir(sparkConf)
+    val sparkEngineSession = SparkEngineSession(sparkSession.sparkContext, sparkSession.sqlContext, sparkSession, outputDir)
+    val sparkSqlExecutor = new SparkSqlExecutor(sparkEngineSession, 1L)
+    Assertions.assertFalse(sparkSqlExecutor.isEngineInitialized)
+    sparkSqlExecutor.init()
+    Assertions.assertTrue(sparkSqlExecutor.isEngineInitialized)
+    val engineExecutionContext = new EngineExecutionContext(sparkSqlExecutor, Utils.getJvmUser)
+    val code = " val spark = SparkSession.builder().appName(\"Test extract\")\n      " +
+      ".config(\"spark.some.config.option\", \"some-value\").master(\"local[*]\").getOrCreate()\n    " +
+      "val dataFrame = spark.createDataFrame(Seq(\n      " +
+      "(\"ming\", 20, 15552211521L),\n      " +
+      "(\"hong\", 19, 13287994007L),\n      " +
+      "(\"zhi\", 21, 15552211523L)\n    )).toDF(\"name\", \"age\", \"phone\") \n" +
+      "dataFrame.show()\n"
+    val response = sparkSqlExecutor.executeLine(engineExecutionContext, code)

Review Comment:
   OK



-- 
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: notifications-unsubscribe@linkis.apache.org

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


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