refactor(接口测试,性能测试): 修改js engine

This commit is contained in:
Captain.B 2021-04-09 17:44:56 +08:00 committed by 刘瑞斌
parent f32939922e
commit ead167f573
7 changed files with 18 additions and 7062 deletions

View File

@ -20,7 +20,6 @@
<jmeter.version>5.4.1</jmeter.version> <jmeter.version>5.4.1</jmeter.version>
<nacos.version>1.1.3</nacos.version> <nacos.version>1.1.3</nacos.version>
<dubbo.version>2.7.8</dubbo.version> <dubbo.version>2.7.8</dubbo.version>
<graalvm.version>20.1.0</graalvm.version>
</properties> </properties>
<dependencies> <dependencies>
@ -298,34 +297,9 @@
<!-- 执行 js 代码依赖 --> <!-- 执行 js 代码依赖 -->
<dependency> <dependency>
<groupId>org.graalvm.sdk</groupId> <groupId>org.mozilla</groupId>
<artifactId>graal-sdk</artifactId> <artifactId>rhino-engine</artifactId>
<version>${graalvm.version}</version> <version>1.7.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>profiler</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>chromeinspector</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -53,7 +53,7 @@ public class MsJSR223Processor extends MsTestElement {
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
processor.setProperty("scriptLanguage", "nashorn"); processor.setProperty("scriptLanguage", "nashorn");
} }
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("graalVMScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) {
processor.setProperty("scriptLanguage", "javascript"); processor.setProperty("scriptLanguage", "javascript");
} }
processor.setProperty("script", this.getScript()); processor.setProperty("script", this.getScript());

View File

@ -47,7 +47,7 @@ public class MsJSR223PostProcessor extends MsTestElement {
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
processor.setProperty("scriptLanguage", "nashorn"); processor.setProperty("scriptLanguage", "nashorn");
} }
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("graalVMScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) {
processor.setProperty("scriptLanguage", "javascript"); processor.setProperty("scriptLanguage", "javascript");
} }
processor.setProperty("script", this.getScript()); processor.setProperty("script", this.getScript());

View File

@ -12,7 +12,6 @@ import org.apache.jmeter.modifiers.JSR223PreProcessor;
import org.apache.jmeter.save.SaveService; import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
import org.graalvm.polyglot.Context;
import java.util.List; import java.util.List;
@ -43,7 +42,6 @@ public class MsJSR223PreProcessor extends MsTestElement {
} }
public JSR223PreProcessor getJSR223PreProcessor() { public JSR223PreProcessor getJSR223PreProcessor() {
Context.newBuilder().allowNativeAccess(true).build();
JSR223PreProcessor processor = new JSR223PreProcessor(); JSR223PreProcessor processor = new JSR223PreProcessor();
processor.setEnabled(this.isEnable()); processor.setEnabled(this.isEnable());
@ -59,7 +57,7 @@ public class MsJSR223PreProcessor extends MsTestElement {
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
processor.setProperty("scriptLanguage", "nashorn"); processor.setProperty("scriptLanguage", "nashorn");
} }
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("graalVMScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("rhinoScript")) {
processor.setProperty("scriptLanguage", "javascript"); processor.setProperty("scriptLanguage", "javascript");
} }

View File

@ -8,7 +8,7 @@ import javax.script.ScriptException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public class ScriptEngineUtils { public class ScriptEngineUtils {
private static final String ENGINE_NAME = "graal.js"; private static final String ENGINE_NAME = "rhino";
private static ScriptEngine engine; private static ScriptEngine engine;
static { static {

File diff suppressed because one or more lines are too long

View File

@ -96,14 +96,14 @@
], ],
isCodeEditAlive: true, isCodeEditAlive: true,
languages: [ languages: [
'beanshell', "python", "groovy", "nashornScript","graalVMScript" 'beanshell', "python", "groovy", "nashornScript", "rhinoScript"
], ],
codeEditModeMap: { codeEditModeMap: {
beanshell: 'java', beanshell: 'java',
python: 'python', python: 'python',
groovy: 'java', groovy: 'java',
nashornScript: 'javascript', nashornScript: 'javascript',
graalVMScript: 'javascript', rhinoScript: 'javascript',
} }
} }
}, },