Skip to content

Commit f186e74

Browse files
committed
Add analytics service
1 parent 1956663 commit f186e74

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public class CouchbaseContainer<SELF extends CouchbaseContainer<SELF>> extends G
5757
private static final int QUERY_SSL_PORT = 18093;
5858
private static final int SEARCH_PORT = 8094;
5959
private static final int SEARCH_SSL_PORT = 18094;
60+
private static final int ANALYTICS_PORT = 8095;
61+
private static final int ANALYTICS_SSL_PORT = 18095;
6062
//</editor-fold>
6163

6264
@Getter
@@ -94,6 +96,10 @@ public class CouchbaseContainer<SELF extends CouchbaseContainer<SELF>> extends G
9496
@Wither
9597
private boolean fts = false;
9698

99+
@Getter
100+
@Wither
101+
private boolean analytics = false;
102+
97103
@Wither
98104
private boolean beerSample = false;
99105

@@ -153,6 +159,12 @@ protected void configure() {
153159
addExposedPort(SEARCH_SSL_PORT);
154160
}
155161
}
162+
if (isAnalytics()) {
163+
addExposedPort(ANALYTICS_PORT);
164+
if (isSsl()) {
165+
addExposedPort(ANALYTICS_SSL_PORT);
166+
}
167+
}
156168
setWaitStrategy(new HttpWaitStrategy().forPath("/ui/index.html#/"));
157169
}
158170

@@ -181,6 +193,9 @@ public void initCluster() {
181193
if (fts) {
182194
servicePayloadBuilder.append("fts,");
183195
}
196+
if (analytics) {
197+
servicePayloadBuilder.append("cbas,");
198+
}
184199
String setupServiceContent = "services=" + URLEncoder.encode(servicePayloadBuilder.toString(), "UTF-8");
185200

186201
String webSettingsURL = "/settings/web";
@@ -307,6 +322,12 @@ private PortInfo createPortInfo() {
307322
portInfo.sslPorts().put(ServiceType.SEARCH, getMappedPort(SEARCH_SSL_PORT));
308323
}
309324
}
325+
if (isAnalytics()) {
326+
portInfo.ports().put(ServiceType.ANALYTICS, getMappedPort(ANALYTICS_PORT));
327+
if (isSsl()) {
328+
portInfo.sslPorts().put(ServiceType.ANALYTICS, getMappedPort(ANALYTICS_SSL_PORT));
329+
}
330+
}
310331
} catch (IllegalStateException e) {
311332
logger().warn(e.getMessage());
312333
}

0 commit comments

Comments
 (0)