32
32
@ Slf4j
33
33
public abstract class PulsarFunctionsTestBase extends PulsarTestSuite {
34
34
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
-
79
35
//
80
36
// Common Variables used by functions test
81
37
//
82
-
83
38
public static final String EXCLAMATION_JAVA_CLASS =
84
39
"org.apache.pulsar.functions.api.examples.ExclamationFunction" ;
85
40
@@ -106,7 +61,6 @@ public void tearDownCluster() throws Exception {
106
61
107
62
public static final String PUBLISH_PYTHON_CLASS = "typed_message_builder_publish.TypedMessageBuilderPublish" ;
108
63
public static final String EXCEPTION_PYTHON_CLASS = "exception_function" ;
109
-
110
64
public static final String EXCLAMATION_PYTHON_FILE = "exclamation_function.py" ;
111
65
public static final String EXCLAMATION_WITH_DEPS_PYTHON_FILE = "exclamation_with_extra_deps.py" ;
112
66
public static final String EXCLAMATION_PYTHON_ZIP_FILE = "exclamation.zip" ;
@@ -119,6 +73,49 @@ public void tearDownCluster() throws Exception {
119
73
public static final String LOGGING_JAVA_CLASS =
120
74
"org.apache.pulsar.functions.api.examples.LoggingFunction" ;
121
75
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
+
122
119
protected static String getExclamationClass (Runtime runtime ,
123
120
boolean pyZip ,
124
121
boolean extraDeps ) {
@@ -136,14 +133,4 @@ protected static String getExclamationClass(Runtime runtime,
136
133
throw new IllegalArgumentException ("Unsupported runtime : " + runtime );
137
134
}
138
135
}
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
-
149
136
}
0 commit comments