Skip to content

Commit a161e75

Browse files
david-streamlioDavid Kjerrumgaard
and
David Kjerrumgaard
authored
[Issue-9889] [integration tests] Refactored Function integration tests (apache#10140)
Co-authored-by: David Kjerrumgaard <dkjerrumgaard@splunk.com>
1 parent 4d2d66d commit a161e75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1893
-1307
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ nb-configuration.xml
3535

3636
# Mac
3737
**/.DS_Store
38+
.java-version
3839

3940
# VisualStudioCode artifacts
4041
.vscode/

tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsTest.java

+10-1,212
Large diffs are not rendered by default.

tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsTestBase.java

+43-56
Original file line numberDiff line numberDiff line change
@@ -32,54 +32,9 @@
3232
@Slf4j
3333
public abstract class PulsarFunctionsTestBase extends PulsarTestSuite {
3434

35-
@DataProvider(name = "FunctionRuntimeTypes")
36-
public static Object[][] getData() {
37-
return new Object[][] {
38-
{ FunctionRuntimeType.PROCESS },
39-
{ FunctionRuntimeType.THREAD }
40-
};
41-
}
42-
43-
protected final FunctionRuntimeType functionRuntimeType;
44-
45-
public PulsarFunctionsTestBase() {
46-
this(FunctionRuntimeType.PROCESS);
47-
}
48-
49-
protected PulsarFunctionsTestBase(FunctionRuntimeType functionRuntimeType) {
50-
this.functionRuntimeType = functionRuntimeType;
51-
}
52-
53-
private void setupFunctionWorkers() {
54-
final int numFunctionWorkers = 2;
55-
log.info("Setting up {} function workers : function runtime type = {}",
56-
numFunctionWorkers, functionRuntimeType);
57-
pulsarCluster.setupFunctionWorkers(randomName(5), functionRuntimeType, numFunctionWorkers);
58-
log.info("{} function workers has started", numFunctionWorkers);
59-
}
60-
61-
private void teardownFunctionWorkers() {
62-
log.info("Tearing down function workers ...");
63-
pulsarCluster.stopWorkers();
64-
log.info("All functions workers are stopped.");
65-
}
66-
67-
@Override
68-
public void setupCluster() throws Exception {
69-
super.setupCluster();
70-
setupFunctionWorkers();
71-
}
72-
73-
@Override
74-
public void tearDownCluster() throws Exception {
75-
teardownFunctionWorkers();
76-
super.tearDownCluster();
77-
}
78-
7935
//
8036
// Common Variables used by functions test
8137
//
82-
8338
public static final String EXCLAMATION_JAVA_CLASS =
8439
"org.apache.pulsar.functions.api.examples.ExclamationFunction";
8540

@@ -106,7 +61,6 @@ public void tearDownCluster() throws Exception {
10661

10762
public static final String PUBLISH_PYTHON_CLASS = "typed_message_builder_publish.TypedMessageBuilderPublish";
10863
public static final String EXCEPTION_PYTHON_CLASS = "exception_function";
109-
11064
public static final String EXCLAMATION_PYTHON_FILE = "exclamation_function.py";
11165
public static final String EXCLAMATION_WITH_DEPS_PYTHON_FILE = "exclamation_with_extra_deps.py";
11266
public static final String EXCLAMATION_PYTHON_ZIP_FILE = "exclamation.zip";
@@ -119,6 +73,49 @@ public void tearDownCluster() throws Exception {
11973
public static final String LOGGING_JAVA_CLASS =
12074
"org.apache.pulsar.functions.api.examples.LoggingFunction";
12175

76+
@DataProvider(name = "FunctionRuntimeTypes")
77+
public static Object[][] getData() {
78+
return new Object[][] {
79+
{ FunctionRuntimeType.PROCESS },
80+
{ FunctionRuntimeType.THREAD }
81+
};
82+
}
83+
84+
@DataProvider(name = "FunctionRuntimes")
85+
public static Object[][] functionRuntimes() {
86+
return new Object[][] {
87+
new Object[] { Runtime.JAVA },
88+
new Object[] { Runtime.PYTHON },
89+
new Object[] { Runtime.GO }
90+
};
91+
}
92+
93+
protected final FunctionRuntimeType functionRuntimeType;
94+
95+
public PulsarFunctionsTestBase() {
96+
this(FunctionRuntimeType.PROCESS);
97+
}
98+
99+
protected PulsarFunctionsTestBase(FunctionRuntimeType functionRuntimeType) {
100+
this.functionRuntimeType = functionRuntimeType;
101+
}
102+
103+
@BeforeClass(alwaysRun = true)
104+
public void setupFunctionWorkers() {
105+
final int numFunctionWorkers = 2;
106+
log.info("Setting up {} function workers : function runtime type = {}",
107+
numFunctionWorkers, functionRuntimeType);
108+
pulsarCluster.setupFunctionWorkers(randomName(5), functionRuntimeType, numFunctionWorkers);
109+
log.info("{} function workers has started", numFunctionWorkers);
110+
}
111+
112+
@AfterClass(alwaysRun = true)
113+
public void teardownFunctionWorkers() {
114+
log.info("Tearing down function workers ...");
115+
pulsarCluster.stopWorkers();
116+
log.info("All functions workers are stopped.");
117+
}
118+
122119
protected static String getExclamationClass(Runtime runtime,
123120
boolean pyZip,
124121
boolean extraDeps) {
@@ -136,14 +133,4 @@ protected static String getExclamationClass(Runtime runtime,
136133
throw new IllegalArgumentException("Unsupported runtime : " + runtime);
137134
}
138135
}
139-
140-
@DataProvider(name = "FunctionRuntimes")
141-
public static Object[][] functionRuntimes() {
142-
return new Object[][] {
143-
new Object[] { Runtime.JAVA },
144-
new Object[] { Runtime.PYTHON },
145-
new Object[] { Runtime.GO }
146-
};
147-
}
148-
149136
}

tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsThreadTest.java tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/go/PulsarFunctionsGoProcessTest.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.pulsar.tests.integration.functions;
19+
package org.apache.pulsar.tests.integration.functions.go;
2020

2121
import org.apache.pulsar.tests.integration.topologies.FunctionRuntimeType;
2222

23-
/**
24-
* Thread based test.
25-
*/
26-
public class PulsarFunctionsThreadTest extends PulsarFunctionsTest {
27-
public PulsarFunctionsThreadTest() {
28-
super(FunctionRuntimeType.THREAD);
29-
}
23+
public class PulsarFunctionsGoProcessTest extends PulsarFunctionsGoTest {
24+
25+
PulsarFunctionsGoProcessTest() {
26+
super(FunctionRuntimeType.PROCESS);
27+
}
28+
3029
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.pulsar.tests.integration.functions.go;
20+
21+
import org.apache.pulsar.tests.integration.functions.PulsarFunctionsTest;
22+
import org.apache.pulsar.tests.integration.functions.utils.CommandGenerator.Runtime;
23+
import org.apache.pulsar.tests.integration.topologies.FunctionRuntimeType;
24+
import org.testng.annotations.Test;
25+
26+
public class PulsarFunctionsGoTest extends PulsarFunctionsTest {
27+
28+
PulsarFunctionsGoTest(FunctionRuntimeType functionRuntimeType) {
29+
super(functionRuntimeType);
30+
}
31+
32+
@Test(enabled = false, groups = {"go_function", "function"})
33+
public void testGoFunctionLocalRun() throws Exception {
34+
testFunctionLocalRun(Runtime.GO);
35+
}
36+
37+
}

tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/PulsarFunctionsProcessTest.java tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/go/PulsarFunctionsGoThreadTest.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.pulsar.tests.integration.functions;
19+
package org.apache.pulsar.tests.integration.functions.go;
2020

2121
import org.apache.pulsar.tests.integration.topologies.FunctionRuntimeType;
2222

23-
/**
24-
* Process based test.
25-
*/
26-
public class PulsarFunctionsProcessTest extends PulsarFunctionsTest {
27-
public PulsarFunctionsProcessTest() {
28-
super(FunctionRuntimeType.PROCESS);
29-
}
23+
public class PulsarFunctionsGoThreadTest extends PulsarFunctionsGoTest {
24+
25+
PulsarFunctionsGoThreadTest() {
26+
super(FunctionRuntimeType.THREAD);
27+
}
3028
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.pulsar.tests.integration.functions.java;
20+
21+
import org.apache.pulsar.tests.integration.topologies.FunctionRuntimeType;
22+
23+
public class PulsarFunctionsJavaProcessTest extends PulsarFunctionsJavaTest {
24+
25+
public PulsarFunctionsJavaProcessTest() {
26+
super(FunctionRuntimeType.PROCESS);
27+
}
28+
29+
}

0 commit comments

Comments
 (0)