@@ -68,6 +68,10 @@ public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
6868
6969 private static final int SEARCH_SSL_PORT = 18094 ;
7070
71+ private static final int ANALYTICS_PORT = 8095 ;
72+
73+ private static final int ANALYTICS_SSL_PORT = 18095 ;
74+
7175 private static final int KV_PORT = 11210 ;
7276
7377 private static final int KV_SSL_PORT = 11207 ;
@@ -84,7 +88,17 @@ public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
8488
8589 private String password = "password" ;
8690
87- private Set <CouchbaseService > enabledServices = EnumSet .allOf (CouchbaseService .class );
91+ /**
92+ * Enabled services does not include Analytics since most users likely do not need to test
93+ * with it and is also a little heavy on memory and runtime requirements. Also, it is only
94+ * available with the enterprise edition (EE).
95+ */
96+ private Set <CouchbaseService > enabledServices = EnumSet .of (
97+ CouchbaseService .KV ,
98+ CouchbaseService .QUERY ,
99+ CouchbaseService .SEARCH ,
100+ CouchbaseService .INDEX
101+ );
88102
89103 private final List <BucketDefinition > buckets = new ArrayList <>();
90104
@@ -144,6 +158,17 @@ public CouchbaseContainer withEnabledServices(final CouchbaseService... enabled)
144158 return this ;
145159 }
146160
161+ /**
162+ * Enables the analytics service which is not enabled by default.
163+ *
164+ * @return this {@link CouchbaseContainer} for chaining purposes.
165+ */
166+ public CouchbaseContainer withAnalyticsService () {
167+ checkNotRunning ();
168+ this .enabledServices .add (CouchbaseService .ANALYTICS );
169+ return this ;
170+ }
171+
147172 public final String getUsername () {
148173 return username ;
149174 }
@@ -177,6 +202,8 @@ protected void configure() {
177202 QUERY_SSL_PORT ,
178203 SEARCH_PORT ,
179204 SEARCH_SSL_PORT ,
205+ ANALYTICS_PORT ,
206+ ANALYTICS_SSL_PORT ,
180207 KV_PORT ,
181208 KV_SSL_PORT
182209 );
@@ -214,6 +241,16 @@ protected void configure() {
214241 );
215242 }
216243
244+ if (enabledServices .contains (CouchbaseService .ANALYTICS )) {
245+ waitStrategy = waitStrategy .withStrategy (
246+ new HttpWaitStrategy ()
247+ .forPath ("/admin/ping" )
248+ .forPort (ANALYTICS_PORT )
249+ .withBasicCredentials (username , password )
250+ .forStatusCode (200 )
251+ );
252+ }
253+
217254 waitingFor (waitStrategy );
218255 }
219256
@@ -262,6 +299,10 @@ private void initializeIsEnterprise() {
262299 } catch (IOException e ) {
263300 throw new IllegalStateException ("Couchbase /pools did not return valid JSON" );
264301 }
302+
303+ if (!isEnterprise && enabledServices .contains (CouchbaseService .ANALYTICS )) {
304+ throw new IllegalStateException ("The Analytics Service is only supported with the Enterprise version" );
305+ }
265306 }
266307
267308 /**
@@ -349,6 +390,11 @@ private void configureExternalPorts() {
349390 builder .add ("ftsSSL" , Integer .toString (getMappedPort (SEARCH_SSL_PORT )));
350391 }
351392
393+ if (enabledServices .contains (CouchbaseService .ANALYTICS )) {
394+ builder .add ("cbas" , Integer .toString (getMappedPort (ANALYTICS_PORT )));
395+ builder .add ("cbasSSL" , Integer .toString (getMappedPort (ANALYTICS_SSL_PORT )));
396+ }
397+
352398 @ Cleanup Response response = doHttpRequest (
353399 MGMT_PORT ,
354400 "/node/controller/setupAlternateAddresses/external" ,
0 commit comments