Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement-12333][Test] Migrate all UT cases from jUnit 4 to jUnit 5 in microbench and e2e module #12348

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package org.apache.dolphinscheduler.e2e.pages.common;

import org.junit.rules.ExpectedException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.BrowserWebDriverContainer;
import org.testcontainers.containers.ContainerState;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.org.awaitility.Awaitility;

Expand All @@ -70,7 +66,6 @@ final class DolphinSchedulerExtension implements BeforeAllCallback, AfterAllCall
private RemoteWebDriver driver;
private DockerComposeContainer<?> compose;
private BrowserWebDriverContainer<?> browser;
private Network network;
private HostAndPort address;
private String rootPath;

Expand All @@ -92,8 +87,9 @@ public void beforeAll(ExtensionContext context) throws IOException {

setBrowserContainerByOsName();

if (network != null) {
browser.withNetwork(network);
if (compose != null) {
Testcontainers.exposeHostPorts(compose.getServicePort("dolphinscheduler_1", 12345));
browser.withAccessToHost(true);
}
browser.start();

Expand Down Expand Up @@ -126,25 +122,7 @@ private void runInDockerContainer(ExtensionContext context) {
compose = createDockerCompose(context);
compose.start();

final ContainerState dsContainer = compose.getContainerByServiceName("dolphinscheduler_1")
.orElseThrow(() -> new RuntimeException("Failed to find a container named 'dolphinscheduler'"));
final String networkId = dsContainer.getContainerInfo().getNetworkSettings().getNetworks().keySet().iterator().next();
network = new Network() {
@Override
public String getId() {
return networkId;
}

@Override
public void close() {
}

@Override
public Statement apply(Statement base, Description description) {
return null;
}
};
address = HostAndPort.fromParts("dolphinscheduler", 12345);
address = HostAndPort.fromParts("host.testcontainers.internal", compose.getServicePort("dolphinscheduler_1", 12345));
rootPath = "/dolphinscheduler/ui/";
}

Expand Down Expand Up @@ -221,6 +199,7 @@ private DockerComposeContainer<?> createDockerCompose(ExtensionContext context)
compose = new DockerComposeContainer<>(files)
.withPull(true)
.withTailChildContainers(true)
.withExposedService("dolphinscheduler_1", 12345)
.withLogConsumer("dolphinscheduler_1", outputFrame -> LOGGER.info(outputFrame.getUtf8String()))
.waitingFor("dolphinscheduler_1", Wait.forHealthcheck().withStartupTimeout(Duration.ofSeconds(180)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import static java.nio.charset.StandardCharsets.UTF_8;

import static org.junit.platform.commons.util.StringUtils.isBlank;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

Expand All @@ -45,7 +43,7 @@ public String getTestId() {
public String getFilesystemFriendlyName() {
final String contextId = context.getUniqueId();
try {
return (isBlank(contextId))
return (contextId == null || contextId.trim().isEmpty())
? UNKNOWN_NAME
: URLEncoder.encode(contextId, UTF_8.toString());
} catch (UnsupportedEncodingException e) {
Expand Down
37 changes: 17 additions & 20 deletions dolphinscheduler-microbench/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
~ 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"
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dolphinscheduler-microbench</artifactId>
<packaging>jar</packaging>
Expand All @@ -35,6 +34,18 @@
<uberjar.name>benchmarks</uberjar.name>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
Expand All @@ -51,9 +62,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>

<dependency>
Expand All @@ -67,18 +77,6 @@

</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -112,5 +110,4 @@
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.io.File;
import java.io.IOException;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Scope;
Expand Down Expand Up @@ -122,4 +122,3 @@ private static int getForks() {
}

}