80 changed files with 3169 additions and 1048 deletions
@ -0,0 +1,41 @@
|
||||
/* |
||||
* 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.dolphinscheduler.common.enums; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue; |
||||
|
||||
public enum SqoopJobType { |
||||
CUSTOM(0, "CUSTOM"), |
||||
TEMPLATE(1, "TEMPLATE"); |
||||
|
||||
SqoopJobType(int code, String descp){ |
||||
this.code = code; |
||||
this.descp = descp; |
||||
} |
||||
|
||||
@EnumValue |
||||
private final int code; |
||||
private final String descp; |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getDescp() { |
||||
return descp; |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
/* |
||||
* 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.dolphinscheduler.common.utils; |
||||
|
||||
import java.util.Iterator; |
||||
import java.util.stream.Stream; |
||||
import java.util.stream.StreamSupport; |
||||
|
||||
public class StreamUtils { |
||||
|
||||
private StreamUtils() { } |
||||
|
||||
public static <T> Stream<T> asStream(Iterator<T> sourceIterator) { |
||||
return asStream(sourceIterator, false); |
||||
} |
||||
|
||||
public static <T> Stream<T> asStream(Iterator<T> sourceIterator, boolean parallel) { |
||||
Iterable<T> iterable = () -> sourceIterator; |
||||
return StreamSupport.stream(iterable.spliterator(), parallel); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,91 @@
|
||||
/* |
||||
* 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.dolphinscheduler.common.task; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.apache.dolphinscheduler.common.enums.HttpCheckCondition; |
||||
import org.apache.dolphinscheduler.common.enums.HttpMethod; |
||||
import org.apache.dolphinscheduler.common.process.HttpProperty; |
||||
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
||||
import org.apache.dolphinscheduler.common.task.http.HttpParameters; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
|
||||
/** |
||||
* http parameter |
||||
*/ |
||||
public class HttpParametersTest { |
||||
|
||||
|
||||
@Test |
||||
public void testGenerator(){ |
||||
String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," + |
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}"; |
||||
HttpParameters httpParameters = JSON.parseObject(paramData, HttpParameters.class); |
||||
|
||||
|
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() ); |
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout()); |
||||
Assert.assertEquals("https://www.baidu.com/",httpParameters.getUrl()); |
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod()); |
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition()); |
||||
Assert.assertEquals("",httpParameters.getCondition()); |
||||
|
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testCheckParameters(){ |
||||
String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," + |
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}"; |
||||
HttpParameters httpParameters = JSON.parseObject(paramData, HttpParameters.class); |
||||
|
||||
Assert.assertTrue( httpParameters.checkParameters()); |
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() ); |
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout()); |
||||
Assert.assertEquals("https://www.baidu.com/",httpParameters.getUrl()); |
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod()); |
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition()); |
||||
Assert.assertEquals("",httpParameters.getCondition()); |
||||
|
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testCheckValues() { |
||||
String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," + |
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}"; |
||||
HttpParameters httpParameters = JSON.parseObject(paramData, HttpParameters.class); |
||||
|
||||
Assert.assertTrue( httpParameters.checkParameters()); |
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() ); |
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout()); |
||||
Assert.assertEquals("https://www.baidu.com/",httpParameters.getUrl()); |
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod()); |
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition()); |
||||
Assert.assertEquals("",httpParameters.getCondition()); |
||||
Assert.assertEquals(0,httpParameters.getLocalParametersMap().size()); |
||||
Assert.assertEquals(0,httpParameters.getResourceFilesList().size()); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* 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.dolphinscheduler.common.utils; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
public class StreamUtilsTest { |
||||
|
||||
@Test |
||||
public void asStream() { |
||||
List<String> list = Arrays.asList("a", "b", "c"); |
||||
List<String> ret = StreamUtils.asStream(list.iterator()) |
||||
.filter(item -> item.equals("a")) |
||||
.collect(Collectors.toList()); |
||||
Assert.assertEquals("a", ret.get(0)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.2.1-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-microbench</artifactId> |
||||
<packaging>jar</packaging> |
||||
<name>${project.artifactId}</name> |
||||
|
||||
<properties> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
<jmh.version>1.21</jmh.version> |
||||
<javac.target>1.8</javac.target> |
||||
<uberjar.name>benchmarks</uberjar.name> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
|
||||
<dependency> |
||||
<groupId>org.openjdk.jmh</groupId> |
||||
<artifactId>jmh-core</artifactId> |
||||
<version>${jmh.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.openjdk.jmh</groupId> |
||||
<artifactId>jmh-generator-annprocess</artifactId> |
||||
<version>${jmh.version}</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>slf4j-api</artifactId> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>${maven-compiler-plugin.version}</version> |
||||
<configuration> |
||||
<compilerVersion>${javac.target}</compilerVersion> |
||||
<source>${javac.target}</source> |
||||
<target>${javac.target}</target> |
||||
<useIncrementalCompilation>false</useIncrementalCompilation> |
||||
</configuration> |
||||
</plugin> |
||||
|
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-assembly-plugin</artifactId> |
||||
<version>${maven-assembly-plugin.version}</version> |
||||
<configuration> |
||||
<archive> |
||||
<manifest> |
||||
<mainClass>org.openjdk.jmh.Main</mainClass> |
||||
</manifest> |
||||
</archive> |
||||
<descriptorRefs> |
||||
<descriptorRef>jar-with-dependencies</descriptorRef> |
||||
</descriptorRefs> |
||||
</configuration> |
||||
</plugin> |
||||
|
||||
</plugins> |
||||
</build> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,123 @@
|
||||
/* |
||||
* 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.dolphinscheduler.microbench.base; |
||||
|
||||
import org.junit.Test; |
||||
import org.openjdk.jmh.annotations.*; |
||||
import org.openjdk.jmh.results.format.ResultFormatType; |
||||
import org.openjdk.jmh.runner.Runner; |
||||
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; |
||||
import org.openjdk.jmh.runner.options.OptionsBuilder; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* BaseBenchMark |
||||
* If you need to test jmh, please extend him first |
||||
*/ |
||||
@Warmup(iterations = AbstractBaseBenchmark.DEFAULT_WARMUP_ITERATIONS) |
||||
@Measurement(iterations = AbstractBaseBenchmark.DEFAULT_MEASURE_ITERATIONS) |
||||
@State(Scope.Thread) |
||||
@Fork(AbstractBaseBenchmark.DEFAULT_FORKS) |
||||
public abstract class AbstractBaseBenchmark { |
||||
|
||||
static final int DEFAULT_WARMUP_ITERATIONS = 10; |
||||
|
||||
static final int DEFAULT_MEASURE_ITERATIONS = 10; |
||||
|
||||
static final int DEFAULT_FORKS = 2; |
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AbstractBaseBenchmark.class); |
||||
|
||||
|
||||
private ChainedOptionsBuilder newOptionsBuilder() { |
||||
|
||||
String className = getClass().getSimpleName(); |
||||
|
||||
ChainedOptionsBuilder optBuilder = new OptionsBuilder() |
||||
// set benchmark ClassName
|
||||
.include(className); |
||||
|
||||
if (getMeasureIterations() > 0) { |
||||
optBuilder.warmupIterations(getMeasureIterations()); |
||||
} |
||||
|
||||
if (getMeasureIterations() > 0) { |
||||
optBuilder.measurementIterations(getMeasureIterations()); |
||||
} |
||||
|
||||
if (getForks() > 0) { |
||||
optBuilder.forks(getForks()); |
||||
} |
||||
|
||||
String output = getReportDir(); |
||||
if (output != null) { |
||||
boolean writeFileStatus; |
||||
String filePath = getReportDir() + className + ".json"; |
||||
File file = new File(filePath); |
||||
|
||||
if (file.exists()) { |
||||
writeFileStatus = file.delete(); |
||||
|
||||
|
||||
} else { |
||||
writeFileStatus = file.getParentFile().mkdirs(); |
||||
try { |
||||
writeFileStatus = file.createNewFile(); |
||||
} catch (IOException e) { |
||||
logger.warn("jmh test create file error" + e); |
||||
} |
||||
} |
||||
if (writeFileStatus) { |
||||
optBuilder.resultFormat(ResultFormatType.JSON) |
||||
.result(filePath); |
||||
} |
||||
} |
||||
return optBuilder; |
||||
} |
||||
|
||||
@Test |
||||
public void run() throws Exception { |
||||
new Runner(newOptionsBuilder().build()).run(); |
||||
} |
||||
|
||||
private int getWarmupIterations() { |
||||
|
||||
String value = System.getProperty("warmupIterations"); |
||||
return null != value ? Integer.parseInt(value) : -1; |
||||
} |
||||
|
||||
private int getMeasureIterations() { |
||||
String value = System.getProperty("measureIterations"); |
||||
return null != value ? Integer.parseInt(value) : -1; |
||||
} |
||||
|
||||
private static String getReportDir() { |
||||
return System.getProperty("perfReportDir"); |
||||
} |
||||
|
||||
private static int getForks() { |
||||
String value = System.getProperty("forkCount"); |
||||
return null != value ? Integer.parseInt(value) : -1; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -0,0 +1,112 @@
|
||||
/* |
||||
* 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.dolphinscheduler.microbench.common; |
||||
|
||||
|
||||
import org.apache.dolphinscheduler.microbench.base.AbstractBaseBenchmark; |
||||
import org.openjdk.jmh.annotations.*; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
*Enum values JMH test |
||||
*/ |
||||
@Warmup(iterations = 2, time = 1) |
||||
@Measurement(iterations = 4, time = 1) |
||||
@State(Scope.Benchmark) |
||||
public class EnumBenchMark extends AbstractBaseBenchmark { |
||||
|
||||
@Benchmark |
||||
public boolean simpleTest(){ |
||||
return Boolean.TRUE; |
||||
} |
||||
@Param({"101", "108", "103", "104", "105", "103"}) |
||||
private int testNum; |
||||
|
||||
|
||||
@Benchmark |
||||
@BenchmarkMode(Mode.AverageTime) |
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS) |
||||
public void enumValuesTest() { |
||||
TestTypeEnum.oldGetNameByType(testNum); |
||||
} |
||||
|
||||
@Benchmark |
||||
@BenchmarkMode(Mode.AverageTime) |
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS) |
||||
public void enumStaticMapTest() { |
||||
TestTypeEnum.newGetNameByType(testNum); |
||||
} |
||||
|
||||
|
||||
public enum TestTypeEnum { |
||||
|
||||
TYPE_101(101, "TYPE101"), |
||||
TYPE_102(102, "TYPE102"), |
||||
TYPE_103(103, "TYPE103"), |
||||
TYPE_104(104, "TYPE104"), |
||||
TYPE_105(105, "TYPE105"), |
||||
TYPE_106(106, "TYPE106"), |
||||
TYPE_107(107, "TYPE107"), |
||||
TYPE_108(108, "TYPE108"); |
||||
|
||||
private int code; |
||||
private String name; |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
|
||||
TestTypeEnum(int code, String name) { |
||||
this.code = code; |
||||
this.name = name; |
||||
} |
||||
|
||||
private static final Map<Integer, TestTypeEnum> TEST_TYPE_MAP = new HashMap<>(); |
||||
|
||||
static { |
||||
for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { |
||||
TEST_TYPE_MAP.put(testTypeEnum.code,testTypeEnum); |
||||
} |
||||
} |
||||
|
||||
public static void newGetNameByType(int code) { |
||||
if (TEST_TYPE_MAP.containsKey(code)) { |
||||
TEST_TYPE_MAP.get(code); |
||||
return; |
||||
} |
||||
throw new IllegalArgumentException("invalid code : " + code); |
||||
} |
||||
|
||||
public static void oldGetNameByType(int code) { |
||||
for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { |
||||
if (testTypeEnum.getCode() == code) { |
||||
return; |
||||
} |
||||
} |
||||
throw new IllegalArgumentException("invalid code : " + code); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,208 @@
|
||||
/* |
||||
* 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.dolphinscheduler.server.worker.task.http; |
||||
|
||||
import static org.apache.dolphinscheduler.common.enums.CommandType.*; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Date; |
||||
|
||||
import org.apache.dolphinscheduler.common.enums.HttpCheckCondition; |
||||
import org.apache.dolphinscheduler.common.enums.HttpMethod; |
||||
import org.apache.dolphinscheduler.common.task.http.HttpParameters; |
||||
import org.apache.dolphinscheduler.common.utils.OSUtils; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
||||
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext; |
||||
import org.apache.dolphinscheduler.server.worker.task.ShellCommandExecutor; |
||||
import org.apache.dolphinscheduler.server.worker.task.TaskProps; |
||||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; |
||||
import org.apache.dolphinscheduler.service.process.ProcessService; |
||||
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
import org.apache.http.client.methods.RequestBuilder; |
||||
import org.apache.http.impl.client.CloseableHttpClient; |
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.mockito.Mockito; |
||||
import org.powermock.api.mockito.PowerMockito; |
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.ApplicationContext; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
|
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest(OSUtils.class) |
||||
@PowerMockIgnore({"javax.management.*","javax.net.ssl.*"}) |
||||
public class HttpTaskTest { |
||||
private static final Logger logger = LoggerFactory.getLogger(HttpTaskTest.class); |
||||
|
||||
|
||||
|
||||
private HttpTask httpTask; |
||||
|
||||
private ProcessService processService; |
||||
|
||||
private ShellCommandExecutor shellCommandExecutor; |
||||
|
||||
private ApplicationContext applicationContext; |
||||
private TaskExecutionContext taskExecutionContext; |
||||
|
||||
@Before |
||||
public void before() throws Exception { |
||||
taskExecutionContext = new TaskExecutionContext(); |
||||
|
||||
PowerMockito.mockStatic(OSUtils.class); |
||||
processService = PowerMockito.mock(ProcessService.class); |
||||
shellCommandExecutor = PowerMockito.mock(ShellCommandExecutor.class); |
||||
|
||||
applicationContext = PowerMockito.mock(ApplicationContext.class); |
||||
SpringApplicationContext springApplicationContext = new SpringApplicationContext(); |
||||
springApplicationContext.setApplicationContext(applicationContext); |
||||
PowerMockito.when(applicationContext.getBean(ProcessService.class)).thenReturn(processService); |
||||
|
||||
TaskProps props = new TaskProps(); |
||||
props.setExecutePath("/tmp"); |
||||
props.setTaskAppId(String.valueOf(System.currentTimeMillis())); |
||||
props.setTaskInstanceId(1); |
||||
props.setTenantCode("1"); |
||||
props.setEnvFile(".dolphinscheduler_env.sh"); |
||||
props.setTaskStartTime(new Date()); |
||||
props.setTaskTimeout(0); |
||||
props.setTaskParams( |
||||
"{\"localParams\":[],\"httpParams\":[],\"url\":\"https://github.com/\",\"httpMethod\":\"GET\"," + |
||||
"\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"https://github.com/\"," + |
||||
"\"connectTimeout\":\"1000\",\"socketTimeout\":\"1000\"}"); |
||||
|
||||
|
||||
taskExecutionContext = Mockito.mock(TaskExecutionContext.class); |
||||
Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(props.getTaskParams()); |
||||
Mockito.when(taskExecutionContext.getExecutePath()).thenReturn("/tmp"); |
||||
Mockito.when(taskExecutionContext.getTaskAppId()).thenReturn("1"); |
||||
Mockito.when(taskExecutionContext.getTenantCode()).thenReturn("root"); |
||||
Mockito.when(taskExecutionContext.getStartTime()).thenReturn(new Date()); |
||||
Mockito.when(taskExecutionContext.getTaskTimeout()).thenReturn(10000); |
||||
Mockito.when(taskExecutionContext.getLogPath()).thenReturn("/tmp/dx"); |
||||
|
||||
httpTask = new HttpTask(taskExecutionContext, logger); |
||||
httpTask.init(); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testGetParameters() { |
||||
Assert.assertNotNull(httpTask.getParameters()); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testCheckParameters() { |
||||
Assert.assertTrue(httpTask.getParameters().checkParameters()); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testGenerator(){ |
||||
String paramJson = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://github.com/\"," + |
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}"; |
||||
HttpParameters httpParameters = JSON.parseObject(paramJson, HttpParameters.class); |
||||
|
||||
|
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() ); |
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout()); |
||||
Assert.assertEquals("https://github.com/",httpParameters.getUrl()); |
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod()); |
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition()); |
||||
Assert.assertEquals("",httpParameters.getCondition()); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testHandle(){ |
||||
boolean flag = true ; |
||||
try { |
||||
httpTask.handle(); |
||||
} catch (Exception e) { |
||||
flag = false ; |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
Assert.assertTrue(flag); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testSendRequest(){ |
||||
|
||||
CloseableHttpClient client = httpTask.createHttpClient(); |
||||
|
||||
String statusCode = null; |
||||
String body = null; |
||||
|
||||
try { |
||||
|
||||
CloseableHttpResponse response = httpTask.sendRequest(client) ; |
||||
statusCode = String.valueOf(httpTask.getStatusCode(response)); |
||||
body = httpTask.getResponseBody(response); |
||||
int exitStatusCode = httpTask.validResponse(body, statusCode); |
||||
|
||||
Assert.assertNotEquals(-1,exitStatusCode); |
||||
|
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
}; |
||||
} |
||||
|
||||
@Test |
||||
public void testValidResponse(){ |
||||
String body = "body"; |
||||
String statusCode = "200" ; |
||||
|
||||
int exitStatusCode = httpTask.validResponse(body,statusCode); |
||||
Assert.assertNotEquals(-1,exitStatusCode); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testAppendMessage(){ |
||||
httpTask.appendMessage("message"); |
||||
|
||||
Assert.assertEquals("message",httpTask.getOutput()); |
||||
} |
||||
|
||||
@Test |
||||
public void testCreateHttpClient(){ |
||||
Assert.assertNotNull(httpTask.createHttpClient()); |
||||
} |
||||
|
||||
@Test |
||||
public void testCreateRequestBuilder(){ |
||||
RequestBuilder requestBuilder = httpTask.createRequestBuilder(); |
||||
Assert.assertEquals(RequestBuilder.get().getMethod(),requestBuilder.getMethod()); |
||||
} |
||||
|
||||
private ProcessInstance getProcessInstance() { |
||||
ProcessInstance processInstance = new ProcessInstance(); |
||||
processInstance.setCommandType(START_PROCESS); |
||||
processInstance.setScheduleTime(new Date()); |
||||
return processInstance; |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
/* |
||||
* 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.dolphinscheduler.data.security; |
||||
|
||||
public class AlertManageData { |
||||
/** |
||||
* Alert Name |
||||
*/ |
||||
public static final String ALERT_NAME = "selenium_alert_Name"; |
||||
/** |
||||
* Alert Type |
||||
*/ |
||||
public static final String ALERT_TYPE = "邮件"; |
||||
|
||||
/** |
||||
* Alert Description |
||||
*/ |
||||
public static final String DESCRIPTION = "create alert test"; |
||||
|
||||
public static final String ALERT_MANAGE = "告警组管理 - DolphinScheduler"; |
||||
|
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* 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.dolphinscheduler.data.security; |
||||
|
||||
public class QueueManageData { |
||||
/** |
||||
* Create Queue Name |
||||
*/ |
||||
public static final String QUEUE_NAME = "selenium_queue_name"; |
||||
|
||||
/** |
||||
* Create Queue Value |
||||
*/ |
||||
public static final String QUEUE_VALUE = "selenium_queue_value"; |
||||
|
||||
/** |
||||
* Edit Queue Name |
||||
*/ |
||||
public static final String EDIT_QUEUE_NAME = "_edit"; |
||||
|
||||
/** |
||||
* Edit Queue Value |
||||
*/ |
||||
public static final String EDIT_QUEUE_VALUE = "_edit"; |
||||
|
||||
public static final String QUEUE_MANAGE = "队列管理 - DolphinScheduler"; |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
/* |
||||
* 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.dolphinscheduler.data.security; |
||||
|
||||
public class TokenManageData { |
||||
public static final String TOKEN_MANAGE = "令牌管理 - DolphinScheduler"; |
||||
public static final String DATE = "2038-06-10 00:00:00"; |
||||
|
||||
|
||||
} |
@ -0,0 +1,35 @@
|
||||
/* |
||||
* 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.dolphinscheduler.locator.security; |
||||
|
||||
import org.openqa.selenium.By; |
||||
|
||||
public class AlertManageLocator { |
||||
//create alert locator
|
||||
public static final By CLICK_ALERT_MANAGE = By.xpath("//div[4]/div/a/div/a/span"); |
||||
public static final By CLICK_CREATE_ALERT = By.xpath("//div[1]/div[2]/div/div[2]/div[2]/div/div[1]/button/span"); |
||||
public static final By INPUT_ALERT_NAME = By.xpath("//div[2]/div/div[1]/div[2]/div/input"); |
||||
public static final By CLICK_ALERT_TYPE = By.xpath("//div[2]/div/div[2]/div/div[2]/div[2]/div/div[1]/div/input"); |
||||
public static final By SELECT_ALERT_EMAIL = By.xpath("//div[2]/div/div[2]/div/div[2]/div[2]/div/div[2]/div/div/div/ul/li[1]/span"); |
||||
public static final By INPUT_ALERT_DESCRIPTION = By.xpath("//textarea"); |
||||
public static final By SUBMIT_ALERT = By.xpath("//div[3]/button[2]/span"); |
||||
|
||||
//delete alert locator
|
||||
public static final By DELETE_ALERT_BUTTON = By.xpath("//span/button"); |
||||
public static final By CONFIRM_DELETE_ALERT_BUTTON = By.xpath("//div[2]/div/button[2]/span"); |
||||
} |
||||
|
@ -0,0 +1,31 @@
|
||||
/* |
||||
* 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.dolphinscheduler.locator.security; |
||||
|
||||
import org.openqa.selenium.By; |
||||
|
||||
public class QueueManageLocator { |
||||
//create queue locator
|
||||
public static final By CLICK_QUEUE_MANAGE = By.xpath("//div[6]/div/a/div/a/span"); |
||||
public static final By CLICK_CREATE_QUEUE = By.xpath("//button/span"); |
||||
public static final By INPUT_QUEUE_NAME = By.xpath("//div[2]/div/div/div[2]/div/input"); |
||||
public static final By INPUT_QUEUE_VALUE = By.xpath("//div[2]/div[2]/div/input"); |
||||
public static final By SUBMIT_QUEUE = By.xpath("//button[2]/span"); |
||||
|
||||
//edit queue locator
|
||||
public static final By CLICK_EDIT_QUEUE = By.xpath("//td[6]/button/i"); |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* 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.dolphinscheduler.locator.security; |
||||
|
||||
import org.openqa.selenium.By; |
||||
|
||||
public class TokenManageLocator { |
||||
//create token
|
||||
public static final By CLICK_TOKEN_MANAGE = By.xpath("//div[7]/div/a/div/a/span"); |
||||
|
||||
public static final By CLICK_CREATE_TOKEN = By.xpath("//div[2]/div/div[2]/div[2]/div/div[1]/button/span"); |
||||
|
||||
public static final By SELECT_USER = By.xpath("//div[2]/div[2]/div/div/div/span/i"); |
||||
|
||||
public static final By CLICK_GENERATE_TOKEN_BUTTON = By.xpath("//div[3]/div[2]/button/span"); |
||||
|
||||
public static final By CLICK_SUBMIT_BUTTON = By.xpath("//div[3]/button[2]/span"); |
||||
|
||||
//edit token
|
||||
public static final By CLICK_EDIT_BUTTON = By.xpath("//div[3]/div[1]/div/table/tr[2]/td[7]/button/i"); |
||||
|
||||
//delete token
|
||||
public static final By CLICK_DELETE_BUTTON = By.xpath("//div[3]/div[1]/div/table/tr[2]/td[7]/span/button"); |
||||
|
||||
public static final By CLICK_CONFIRM_DELETE_BUTTON = By.xpath("//div[2]/div/button[2]/span"); |
||||
|
||||
} |
@ -0,0 +1,77 @@
|
||||
/* |
||||
* 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.dolphinscheduler.page.security; |
||||
|
||||
import org.apache.dolphinscheduler.common.PageCommon; |
||||
import org.apache.dolphinscheduler.data.security.AlertManageData; |
||||
import org.apache.dolphinscheduler.locator.security.AlertManageLocator; |
||||
import org.openqa.selenium.WebDriver; |
||||
|
||||
public class AlertManagePage extends PageCommon { |
||||
/** |
||||
* Unique constructor |
||||
* @param driver driver |
||||
*/ |
||||
public AlertManagePage(WebDriver driver) { |
||||
super(driver); |
||||
} |
||||
|
||||
/** |
||||
* createTenant |
||||
* |
||||
* @return Whether to enter the specified page after create tenant |
||||
*/ |
||||
public boolean createAlert() throws InterruptedException { |
||||
// click alert manage
|
||||
clickElement(AlertManageLocator.CLICK_ALERT_MANAGE); |
||||
Thread.sleep(1000); |
||||
|
||||
// click create alert button
|
||||
clickElement(AlertManageLocator.CLICK_CREATE_ALERT); |
||||
Thread.sleep(1000); |
||||
|
||||
// input alert data
|
||||
sendInput(AlertManageLocator.INPUT_ALERT_NAME, AlertManageData.ALERT_NAME); |
||||
|
||||
clickElement(AlertManageLocator.CLICK_ALERT_TYPE); |
||||
|
||||
clickElement(AlertManageLocator.SELECT_ALERT_EMAIL); |
||||
|
||||
sendInput(AlertManageLocator.INPUT_ALERT_DESCRIPTION, AlertManageData.DESCRIPTION); |
||||
|
||||
// click button
|
||||
clickButton(AlertManageLocator.SUBMIT_ALERT); |
||||
|
||||
// Whether to enter the specified page after submit
|
||||
return ifTitleContains(AlertManageData.ALERT_MANAGE); |
||||
} |
||||
|
||||
public boolean deleteAlert() throws InterruptedException { |
||||
|
||||
// click user manage
|
||||
clickElement(AlertManageLocator.CLICK_ALERT_MANAGE); |
||||
|
||||
// click delete user button
|
||||
clickButton(AlertManageLocator.DELETE_ALERT_BUTTON); |
||||
|
||||
// click confirm delete button
|
||||
clickButton(AlertManageLocator.CONFIRM_DELETE_ALERT_BUTTON); |
||||
|
||||
// Whether to enter the specified page after submit
|
||||
return ifTitleContains(AlertManageData.ALERT_MANAGE); |
||||
} |
||||
} |
@ -0,0 +1,85 @@
|
||||
/* |
||||
* 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.dolphinscheduler.page.security; |
||||
|
||||
import org.apache.dolphinscheduler.common.PageCommon; |
||||
import org.apache.dolphinscheduler.data.security.QueueManageData; |
||||
import org.apache.dolphinscheduler.locator.security.QueueManageLocator; |
||||
import org.openqa.selenium.WebDriver; |
||||
|
||||
public class QueueManagePage extends PageCommon { |
||||
/** |
||||
* Unique constructor |
||||
* @param driver driver |
||||
*/ |
||||
public QueueManagePage(WebDriver driver) { |
||||
super(driver); |
||||
} |
||||
|
||||
/** |
||||
* create queue |
||||
* |
||||
* @return Whether to enter the specified page after create queue |
||||
*/ |
||||
public boolean createQueue() throws InterruptedException { |
||||
// click queue manage
|
||||
clickElement(QueueManageLocator.CLICK_QUEUE_MANAGE); |
||||
Thread.sleep(1000); |
||||
|
||||
// click create queue button
|
||||
clickElement(QueueManageLocator.CLICK_CREATE_QUEUE); |
||||
Thread.sleep(1000); |
||||
|
||||
// input queue data
|
||||
sendInput(QueueManageLocator.INPUT_QUEUE_NAME, QueueManageData.QUEUE_NAME); |
||||
|
||||
sendInput(QueueManageLocator.INPUT_QUEUE_VALUE, QueueManageData.QUEUE_VALUE); |
||||
|
||||
// click button
|
||||
clickButton(QueueManageLocator.SUBMIT_QUEUE); |
||||
|
||||
// Whether to enter the specified page after submit
|
||||
return ifTitleContains(QueueManageData.QUEUE_MANAGE); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* edit queue |
||||
* |
||||
* @return Whether to enter the specified page after create queue |
||||
*/ |
||||
public boolean editQueue() throws InterruptedException { |
||||
// click queue manage
|
||||
Thread.sleep(1000); |
||||
clickElement(QueueManageLocator.CLICK_QUEUE_MANAGE); |
||||
Thread.sleep(1000); |
||||
|
||||
// click edit queue button
|
||||
clickElement(QueueManageLocator.CLICK_EDIT_QUEUE); |
||||
Thread.sleep(1000); |
||||
|
||||
// input queue data
|
||||
sendInput(QueueManageLocator.INPUT_QUEUE_NAME, QueueManageData.EDIT_QUEUE_NAME); |
||||
sendInput(QueueManageLocator.INPUT_QUEUE_VALUE, QueueManageData.EDIT_QUEUE_VALUE); |
||||
|
||||
// click button
|
||||
clickButton(QueueManageLocator.SUBMIT_QUEUE); |
||||
|
||||
// Whether to enter the specified page after submit
|
||||
return ifTitleContains(QueueManageData.QUEUE_MANAGE); |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
/* |
||||
* 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.dolphinscheduler.page.security; |
||||
|
||||
import org.apache.dolphinscheduler.common.PageCommon; |
||||
import org.apache.dolphinscheduler.data.security.TokenManageData; |
||||
import org.apache.dolphinscheduler.locator.security.TokenManageLocator; |
||||
import org.openqa.selenium.WebDriver; |
||||
|
||||
public class TokenManagePage extends PageCommon { |
||||
public TokenManagePage(WebDriver driver) { |
||||
super(driver); |
||||
} |
||||
|
||||
/** |
||||
* createTenant |
||||
* |
||||
* @return Whether to enter the specified page after creat tenant |
||||
*/ |
||||
public boolean createToken() throws InterruptedException { |
||||
//create token
|
||||
Thread.sleep(1000); |
||||
clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE); |
||||
Thread.sleep(1000); |
||||
|
||||
// click create token button
|
||||
clickButton(TokenManageLocator.CLICK_CREATE_TOKEN); |
||||
Thread.sleep(1000); |
||||
|
||||
//selectDate(TokenManageLocator.js, TokenManageLocator.CLICK_TIME, TokenManageData.DATE);
|
||||
|
||||
clickButton(TokenManageLocator.SELECT_USER); |
||||
|
||||
clickButton(TokenManageLocator.CLICK_GENERATE_TOKEN_BUTTON); |
||||
Thread.sleep(2500); |
||||
|
||||
// click button
|
||||
clickButton(TokenManageLocator.CLICK_SUBMIT_BUTTON); |
||||
|
||||
// Whether to enter the specified page after submit
|
||||
return ifTitleContains(TokenManageData.TOKEN_MANAGE); |
||||
} |
||||
|
||||
|
||||
//edit token
|
||||
public boolean editToken() throws InterruptedException { |
||||
// click token manage
|
||||
clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE); |
||||
Thread.sleep(1000); |
||||
|
||||
// click create token button
|
||||
clickButton(TokenManageLocator.CLICK_EDIT_BUTTON); |
||||
Thread.sleep(1000); |
||||
|
||||
clickButton(TokenManageLocator.SELECT_USER); |
||||
|
||||
clickButton(TokenManageLocator.CLICK_GENERATE_TOKEN_BUTTON); |
||||
Thread.sleep(2500); |
||||
|
||||
// click button
|
||||
clickButton(TokenManageLocator.CLICK_SUBMIT_BUTTON); |
||||
|
||||
// Whether to enter the specified page after submit
|
||||
return ifTitleContains(TokenManageData.TOKEN_MANAGE); |
||||
} |
||||
|
||||
|
||||
//delete token
|
||||
public boolean deleteToken() throws InterruptedException { |
||||
// click token manage
|
||||
clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE); |
||||
Thread.sleep(1000); |
||||
|
||||
clickButton(TokenManageLocator.CLICK_DELETE_BUTTON); |
||||
clickButton(TokenManageLocator.CLICK_CONFIRM_DELETE_BUTTON); |
||||
|
||||
return ifTitleContains(TokenManageData.TOKEN_MANAGE); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* 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.dolphinscheduler.testcase.testDeleteData; |
||||
|
||||
import org.apache.dolphinscheduler.base.BaseTest; |
||||
import org.apache.dolphinscheduler.page.security.AlertManagePage; |
||||
import org.apache.dolphinscheduler.page.security.TenantManagePage; |
||||
import org.testng.annotations.Test; |
||||
|
||||
public class TestDeleteAlert extends BaseTest { |
||||
private AlertManagePage alertManagePage; |
||||
private TenantManagePage tenantManagePage; |
||||
|
||||
@Test(groups={"functionTests"},dependsOnGroups = { "login","alert" },description = "TestDeleteAlert",priority=8) |
||||
public void testDeleteAlert() throws InterruptedException { |
||||
tenantManagePage = new TenantManagePage(driver); |
||||
System.out.println("jump to testSecurity to delete alert"); |
||||
tenantManagePage.jumpSecurity(); |
||||
|
||||
alertManagePage = new AlertManagePage(driver); |
||||
|
||||
//assert alert manage page
|
||||
System.out.println("start delete alert"); |
||||
assert alertManagePage.deleteAlert(); |
||||
System.out.println("end delete alert"); |
||||
System.out.println("==================================="); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* 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.dolphinscheduler.testcase.testDeleteData; |
||||
|
||||
import org.apache.dolphinscheduler.base.BaseTest; |
||||
import org.apache.dolphinscheduler.page.security.TenantManagePage; |
||||
import org.apache.dolphinscheduler.page.security.TokenManagePage; |
||||
import org.testng.annotations.Test; |
||||
|
||||
public class TestDeleteToken extends BaseTest { |
||||
private TokenManagePage tokenManagePage; |
||||
private TenantManagePage tenantManagePage; |
||||
|
||||
|
||||
@Test(groups = {"functionTests"}, dependsOnGroups = {"login", "token"}, description = "TestDeleteToken") |
||||
public void testUserManage() throws InterruptedException { |
||||
tenantManagePage = new TenantManagePage(driver); |
||||
System.out.println("jump to security to delete token"); |
||||
tenantManagePage.jumpSecurity(); |
||||
|
||||
tokenManagePage = new TokenManagePage(driver); |
||||
//delete token
|
||||
System.out.println("start delete token"); |
||||
assert tokenManagePage.deleteToken(); |
||||
System.out.println("end delete token"); |
||||
System.out.println("==================================="); |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
/* |
||||
* 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.dolphinscheduler.testcase.testSecurity; |
||||
|
||||
import org.apache.dolphinscheduler.base.BaseTest; |
||||
import org.apache.dolphinscheduler.page.security.AlertManagePage; |
||||
import org.testng.annotations.Test; |
||||
|
||||
public class TestAlertManage extends BaseTest { |
||||
private AlertManagePage alertManagePage; |
||||
|
||||
@Test(groups={"functionTests","alert"},dependsOnGroups = { "login" },description = "AlertManagePage") |
||||
public void testAlertManage() throws InterruptedException { |
||||
alertManagePage = new AlertManagePage(driver); |
||||
//assert alert manage page
|
||||
System.out.println("start create alert"); |
||||
assert alertManagePage.createAlert(); |
||||
System.out.println("end create alert"); |
||||
System.out.println("==================================="); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* 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.dolphinscheduler.testcase.testSecurity; |
||||
|
||||
import org.apache.dolphinscheduler.base.BaseTest; |
||||
import org.apache.dolphinscheduler.page.security.QueueManagePage; |
||||
import org.testng.annotations.Test; |
||||
|
||||
|
||||
public class TestQueueManage extends BaseTest { |
||||
private QueueManagePage queueManagePage; |
||||
|
||||
@Test(groups={"functionTests","queue"},dependsOnGroups = { "login" },description = "TestQueueManage") |
||||
public void testTenantManage() throws InterruptedException { |
||||
queueManagePage = new QueueManagePage(driver); |
||||
//create queue
|
||||
System.out.println("start create queue"); |
||||
assert queueManagePage.createQueue(); |
||||
System.out.println("end create queue"); |
||||
System.out.println("==================================="); |
||||
|
||||
//edit queue
|
||||
System.out.println("start edit queue"); |
||||
assert queueManagePage.editQueue(); |
||||
System.out.println("end edit queue"); |
||||
System.out.println("==================================="); |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
/* |
||||
* 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.dolphinscheduler.testcase.testSecurity; |
||||
|
||||
import org.apache.dolphinscheduler.base.BaseTest; |
||||
import org.apache.dolphinscheduler.page.security.TokenManagePage; |
||||
import org.testng.annotations.Test; |
||||
|
||||
public class TestTokenManage extends BaseTest { |
||||
private TokenManagePage tokenManagePage; |
||||
|
||||
@Test(groups={"functionTests","token"},dependsOnGroups = { "login" },description = "TestTokenManage") |
||||
public void testUserManage() throws InterruptedException { |
||||
tokenManagePage = new TokenManagePage(driver); |
||||
//generate token
|
||||
System.out.println("start create token"); |
||||
assert tokenManagePage.createToken(); |
||||
System.out.println("end create token"); |
||||
System.out.println("==================================="); |
||||
|
||||
|
||||
//edit token
|
||||
System.out.println("start edit token"); |
||||
assert tokenManagePage.editToken(); |
||||
System.out.println("end edit token"); |
||||
System.out.println("==================================="); |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue