@@ -70,31 +70,44 @@ public class RestIntegTestTask extends DefaultTask {
70
70
runner. parallelism = ' 1'
71
71
runner. include(' **/*IT.class' )
72
72
runner. systemProperty(' tests.rest.load_packaged' , ' false' )
73
- // we pass all nodes to the rest cluster to allow the clients to round-robin between them
74
- // this is more realistic than just talking to a single node
75
- runner. systemProperty(' tests.rest.cluster' , " ${ -> nodes.collect{it.httpUri()}.join(",")} " )
76
- runner. systemProperty(' tests.config.dir' , " ${ -> nodes[0].pathConf} " )
77
- // TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin
78
- // that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass
79
- // both as separate sysprops
80
- runner. systemProperty(' tests.cluster' , " ${ -> nodes[0].transportUri()} " )
81
-
82
- // dump errors and warnings from cluster log on failure
83
- TaskExecutionAdapter logDumpListener = new TaskExecutionAdapter () {
84
- @Override
85
- void afterExecute (Task task , TaskState state ) {
86
- if (state. failure != null ) {
87
- for (NodeInfo nodeInfo : nodes) {
88
- printLogExcerpt(nodeInfo)
73
+
74
+ if (System . getProperty(" tests.rest.cluster" ) == null ) {
75
+ if (System . getProperty(" tests.cluster" ) != null ) {
76
+ throw new IllegalArgumentException (" tests.rest.cluster and tests.cluster must both be null or non-null" )
77
+ }
78
+ // we pass all nodes to the rest cluster to allow the clients to round-robin between them
79
+ // this is more realistic than just talking to a single node
80
+ runner. systemProperty(' tests.rest.cluster' , " ${ -> nodes.collect{it.httpUri()}.join(",")} " )
81
+ runner. systemProperty(' tests.config.dir' , " ${ -> nodes[0].pathConf} " )
82
+ // TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin
83
+ // that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass
84
+ // both as separate sysprops
85
+ runner. systemProperty(' tests.cluster' , " ${ -> nodes[0].transportUri()} " )
86
+
87
+ // dump errors and warnings from cluster log on failure
88
+ TaskExecutionAdapter logDumpListener = new TaskExecutionAdapter () {
89
+ @Override
90
+ void afterExecute (Task task , TaskState state ) {
91
+ if (state. failure != null ) {
92
+ for (NodeInfo nodeInfo : nodes) {
93
+ printLogExcerpt(nodeInfo)
94
+ }
89
95
}
90
96
}
91
97
}
92
- }
93
- runner. doFirst {
94
- project. gradle. addListener(logDumpListener)
95
- }
96
- runner. doLast {
97
- project. gradle. removeListener(logDumpListener)
98
+ runner. doFirst {
99
+ project. gradle. addListener(logDumpListener)
100
+ }
101
+ runner. doLast {
102
+ project. gradle. removeListener(logDumpListener)
103
+ }
104
+ } else {
105
+ if (System . getProperty(" tests.cluster" ) == null ) {
106
+ throw new IllegalArgumentException (" tests.rest.cluster and tests.cluster must both be null or non-null" )
107
+ }
108
+ // an external cluster was specified and all responsibility for cluster configuration is taken by the user
109
+ runner. systemProperty(' tests.rest.cluster' , System . getProperty(" tests.rest.cluster" ))
110
+ runner. systemProperty(' test.cluster' , System . getProperty(" tests.cluster" ))
98
111
}
99
112
100
113
// copy the rest spec/tests into the test resources
@@ -109,7 +122,10 @@ public class RestIntegTestTask extends DefaultTask {
109
122
clusterInit. enabled = false
110
123
return // no need to add cluster formation tasks if the task won't run!
111
124
}
112
- nodes = ClusterFormationTasks . setup(project, " ${ name} Cluster" , runner, clusterConfig)
125
+ // only create the cluster if needed as otherwise an external cluster to use was specified
126
+ if (System . getProperty(" tests.rest.cluster" ) == null ) {
127
+ nodes = ClusterFormationTasks . setup(project, " ${ name} Cluster" , runner, clusterConfig)
128
+ }
113
129
super . dependsOn(runner. finalizedBy)
114
130
}
115
131
}
0 commit comments