Skip to content
Open
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 @@ -34,34 +34,24 @@
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.test.examples.join.WindowJoinData;
import org.apache.flink.test.testdata.WordCountData;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.test.util.AbstractTestBase;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.File;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;

import static org.apache.flink.test.util.TestBaseUtils.checkLinesAgainstRegexp;
import static org.apache.flink.test.util.TestBaseUtils.compareResultsByLinesInMemory;

/** Integration test for streaming programs in Java examples. */
@RunWith(Parameterized.class)
public class StreamingExamplesITCase extends AbstractTestBaseJUnit4 {

@Parameterized.Parameter public boolean asyncState;

@Parameterized.Parameters
public static Collection<Boolean> setup() {
return Arrays.asList(false, true);
}
class StreamingExamplesITCase extends AbstractTestBase {

@Test
public void testWindowJoin() throws Exception {
void testWindowJoin() throws Exception {

final String resultPath = Files.createTempDirectory("result-path").toUri().toString();

Expand Down Expand Up @@ -111,7 +101,7 @@ public Tuple2<String, Integer> map(String value) throws Exception {
}

@Test
public void testSessionWindowing() throws Exception {
void testSessionWindowing() throws Exception {
final String resultPath = getTempDirPath("result");
org.apache.flink.streaming.examples.windowing.SessionWindowing.main(
new String[] {"--output", resultPath});
Expand All @@ -120,8 +110,9 @@ public void testSessionWindowing() throws Exception {
// state here.
}

@Test
public void testWindowWordCount() throws Exception {
@ParameterizedTest(name = "asyncState: {0}")
@ValueSource(booleans = {false, true})
void testWindowWordCount(boolean asyncState) throws Exception {
final String windowSize = "25";
final String slideSize = "15";
final String textPath = createTempFile("text.txt", WordCountData.TEXT);
Expand Down Expand Up @@ -153,8 +144,9 @@ public void testWindowWordCount() throws Exception {
checkLinesAgainstRegexp(resultPath, "^\\([a-z]+,(\\d)+\\)");
}

@Test
public void testWordCount() throws Exception {
@ParameterizedTest(name = "asyncState: {0}")
@ValueSource(booleans = {false, true})
void testWordCount(boolean asyncState) throws Exception {
final String textPath = createTempFile("text.txt", WordCountData.TEXT);
final String resultPath = getTempDirPath("result");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,37 @@
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.examples.windowing.TopSpeedWindowing;
import org.apache.flink.streaming.examples.windowing.util.TopSpeedWindowingExampleData;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.util.FileUtils;
import org.apache.flink.util.TestLogger;

import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;

import java.io.File;

import static org.apache.flink.test.util.TestBaseUtils.compareResultsByLinesInMemory;

/** Tests for {@link TopSpeedWindowing}. */
public class TopSpeedWindowingExampleITCase extends TestLogger {
class TopSpeedWindowingExampleITCase {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why logger just disapeared?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Added the extension file taking reference from #19716,
Didnt add test-jar exclude, nothing consumes this module's test-jar, let me know if we want to add it for caution or another reason.


@ClassRule public static TemporaryFolder temporaryFolder = new TemporaryFolder();

@ClassRule
public static MiniClusterWithClientResource miniClusterResource =
new MiniClusterWithClientResource(
@RegisterExtension
static final MiniClusterExtension MINI_CLUSTER_EXTENSION =
new MiniClusterExtension(
new MiniClusterResourceConfiguration.Builder()
.setNumberTaskManagers(1)
.setNumberSlotsPerTaskManager(1)
.build());

@TempDir static File temporaryFolder;

@Test
public void testTopSpeedWindowingExampleITCase() throws Exception {
File inputFile = temporaryFolder.newFile();
void testTopSpeedWindowingExampleITCase() throws Exception {
File inputFile = new File(temporaryFolder, "input");
inputFile.createNewFile();
FileUtils.writeFileUtf8(inputFile, TopSpeedWindowingExampleData.CAR_DATA);

final String resultPath = temporaryFolder.newFolder().toURI().toString();
final String resultPath = new File(temporaryFolder, "result").toURI().toString();

TopSpeedWindowing.main(
new String[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
import org.apache.flink.configuration.ConfigConstants;
import org.apache.flink.streaming.examples.socket.SocketWindowWordCount;
import org.apache.flink.test.testdata.WordCountData;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.test.util.AbstractTestBase;
import org.apache.flink.util.NetUtils;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -35,24 +34,15 @@
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.fail;
import static org.assertj.core.api.Assertions.fail;

/** Tests for {@link SocketWindowWordCount}. */
@RunWith(Parameterized.class)
public class SocketWindowWordCountITCase extends AbstractTestBaseJUnit4 {
class SocketWindowWordCountITCase extends AbstractTestBase {

@Parameterized.Parameter public boolean asyncState;

@Parameterized.Parameters
public static Collection<Boolean> setup() {
return Arrays.asList(false, true);
}

@Test
public void testJavaProgram() throws Exception {
@ParameterizedTest(name = "asyncState: {0}")
@ValueSource(booleans = {false, true})
void testJavaProgram(boolean asyncState) throws Exception {
InetAddress localhost = InetAddress.getByName("localhost");

// suppress sysout messages from this example
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.

org.apache.flink.util.TestLoggerExtension
org.apache.flink.util.TestNameProviderExtension