Skip to content

Commit b35f271

Browse files
committed
Add Clouseau to the developer setup
Provide a way to the developers to deploy and launch the Clouseau search module more easily, therefore making it more accessible. This can help with running the Search-based Elixir tests as well as the Mango `text` search tests. This could allow us to catch more bugs ahead of time and might even inspire more improvements in the area. The extension is designed in a way to make it simple to integrate with the CI — only the Java environment of the proper version needs to be deployed, everything else could be managed from this repository. Such as bumping the version of Clouseau or fine-tuning the configuration parameters. This is an opt-in feature on two levels. First, one has to tell `./configure --enable-clouseau` to instantiate Clouseau locally. This will create the `clouseau` sub-directory that holds the contents of the Clouseau distribution of the specified version, which currently defaults to 2.22.0 (the latest). If an older version is needed, use the `--clouseau-version` flag. Then the `mango-test` and `elixir-search` targets will try to use Clouseau automatically just to make it easy to use in the old way. However, the `dev/run` script will not do the same. It requires the `--with-clouseau` flag to be passed for that. That is because the developer may not necessarily want to launch Clouseau ad hoc, even if it is available. With this, note that `elixir-search` is added to the `check` target. In lack of a configured Clouseau instance, it will become a no-op and a warning is emitted.
1 parent 03a2cb4 commit b35f271

File tree

9 files changed

+439
-37
lines changed

9 files changed

+439
-37
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"context": "..",
66
"args": {
77
// Useful choices include:
8-
// apache/couchdbci-debian:bullseye-erlang-25.0.2
9-
// apache/couchdbci-debian:bullseye-erlang-24.3.4.2
10-
// apache/couchdbci-debian:bullseye-erlang-23.3.4.15
8+
// apache/couchdbci-debian:bullseye-erlang-26.1.2
9+
// apache/couchdbci-debian:bullseye-erlang-25.3.2.7
10+
// apache/couchdbci-debian:bookworm-erlang-24.3.4.14
1111
//
12-
"COUCHDB_IMAGE": "apache/couchdbci-debian:bullseye-erlang-24.3.4.10"
12+
"COUCHDB_IMAGE": "apache/couchdbci-debian:bullseye-erlang-24.3.4.14"
1313
}
1414
},
1515

@@ -23,7 +23,7 @@
2323
// Your code will live inside the volume created for the container under /workspace.
2424
"workspaceMount": "target=/workspaces/couchdb,type=volume",
2525
"workspaceFolder": "/workspaces/couchdb",
26-
"postCreateCommand": "./configure --enable-nouveau && make",
26+
"postCreateCommand": "./configure --enable-nouveau --enable-clouseau && make",
2727

2828
"customizations": {
2929
"vscode": {

Makefile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ check: all
157157
@$(MAKE) eunit
158158
@$(MAKE) mango-test
159159
@$(MAKE) elixir
160+
@$(MAKE) elixir-search
160161
@$(MAKE) weatherreport-test
161162
@$(MAKE) nouveau-test
162163

@@ -263,12 +264,17 @@ elixir: elixir-init devclean
263264
--no-eval 'mix test --trace --include test/elixir/test/config/suite.elixir --exclude test/elixir/test/config/skip.elixir $(EXUNIT_OPTS)'
264265

265266
.PHONY: elixir-search
266-
# target: elixir-search - Run search tests, requires a running Clouseau instance
267+
# target: elixir-search - Run search tests, requires a configured Clouseau instance
267268
elixir-search: export MIX_ENV=integration
268269
elixir-search: elixir-init devclean
270+
ifeq ($(with_clouseau), 1)
269271
@dev/run -n 1 -q -a adm:pass \
272+
--with-clouseau \
270273
--locald-config test/config/test-config.ini \
271274
--no-eval 'mix test --trace --include test/elixir/test/config/search.elixir'
275+
else
276+
@echo "Warning: Clouseau is not enabled, \`elixir-search\` cannot be run."
277+
endif
272278

273279
.PHONY: elixir-source-checks
274280
# target: elixir-source-checks - Check source code formatting of Elixir test files
@@ -313,19 +319,24 @@ list-eunit-suites:
313319
build-test:
314320
@test/build/test-configure.sh
315321

322+
ifeq ($(with_clouseau), 1)
323+
_WITH_CLOUSEAU="--with-clouseau"
324+
endif
316325

317326
.PHONY: mango-test
318327
# target: mango-test - Run Mango tests
319328
mango-test: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
320329
mango-test: devclean all
321-
@cd src/mango && \
322-
python3 -m venv .venv && \
323-
.venv/bin/python3 -m pip install -r requirements.txt
324-
@cd src/mango && \
325-
../../dev/run "$(TEST_OPTS)" \
330+
@python3 -m venv src/mango/.venv && \
331+
src/mango/.venv/bin/python3 -m pip install -r src/mango/requirements.txt
332+
@dev/run \
333+
"$(TEST_OPTS)" \
334+
"$(_WITH_CLOUSEAU)" \
326335
-n 1 \
327336
--admin=adm:pass \
328-
'COUCH_USER=adm COUCH_PASS=pass .venv/bin/python3 -m nose2 $(MANGO_TEST_OPTS)'
337+
--no-eval "\
338+
COUCH_USER=adm COUCH_PASS=pass \
339+
src/mango/.venv/bin/nose2 -s src/mango/test -c src/mango/unittest.cfg $(MANGO_TEST_OPTS)"
329340

330341

331342
.PHONY: weatherreport-test

Makefile.win

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ check: all
143143
@$(MAKE) eunit
144144
@$(MAKE) mango-test
145145
@$(MAKE) elixir
146+
@$(MAKE) elixir-search
146147
@$(MAKE) nouveau-test
147148

148149
ifdef apps
@@ -203,6 +204,8 @@ python-black-update: .venv/bin/black
203204
--exclude="build/|buck-out/|dist/|_build/|\.git/|\.hg/|\.mypy_cache/|\.nox/|\.tox/|\.venv/|src/erlfmt|src/rebar/pr2relnotes.py|src/fauxton" \
204205
build-aux dev\run dev\format_*.py src\mango\test src\docs\src\conf.py src\docs\ext .
205206

207+
-include install.mk
208+
206209
ifeq ($(with_nouveau), 0)
207210
exclude_nouveau=--exclude nouveau
208211
endif
@@ -239,12 +242,17 @@ elixir: elixir-init devclean
239242
--no-eval 'mix test --trace --include test\elixir\test\config\suite.elixir --exclude test\elixir\test\config\skip.elixir $(EXUNIT_OPTS)'
240243

241244
.PHONY: elixir-search
242-
# target: elixir-search - Run search tests, requires a running Clouseau instance
245+
# target: elixir-search - Run search tests, requires a configured Clouseau instance
243246
elixir-search: export MIX_ENV=integration
244247
elixir-search: elixir-init devclean
248+
ifeq ($(with_clouseau), 1)
245249
@dev\run -n 1 -q -a adm:pass \
250+
--with-clouseau \
246251
--locald-config test/config/test-config.ini \
247252
--no-eval 'mix test --trace --include test/elixir/test/config/search.elixir'
253+
else
254+
@echo "Warning: Clouseau is not enabled, `elixir-search` cannot be run."
255+
endif
248256

249257
.PHONY: elixir-source-checks
250258
# target: elixir-source-checks - Check source code formatting of Elixir test files
@@ -278,19 +286,24 @@ list-eunit-apps:
278286
list-eunit-suites:
279287
@powershell -Command 'Get-ChildItem -Path src -Recurse -Filter "*_tests?.erl" | ForEach-Object { "{0}" -f $$_.BaseName } | Sort'
280288

289+
ifeq ($(with_clouseau), 1)
290+
_WITH_CLOUSEAU="--with-clouseau"
291+
endif
281292

282293
.PHONY: mango-test
283294
# target: mango-test - Run Mango tests
284295
mango-test: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
285296
mango-test: devclean all
286-
@cd src\mango && \
287-
python.exe -m venv .venv && \
288-
.venv\Scripts\pip.exe install -r requirements.txt
289-
@cd src\mango && \
290-
..\..\dev\run "$(TEST_OPTS)" \
297+
@$(PYTHON) -m venv src\mango\.venv && \
298+
src\mango\.venv\Scripts\pip.exe install -r src\mango\requirements.txt
299+
@dev\run \
300+
"$(TEST_OPTS)" \
301+
"$(_WITH_CLOUSEAU)" \
291302
-n 1 \
292303
--admin=adm:pass \
293-
"env COUCH_USER=adm COUCH_PASS=pass .venv\Scripts\nose2 $(MANGO_TEST_OPTS)"
304+
"\
305+
env COUCH_USER=adm COUCH_PASS=pass \
306+
src\mango\.venv\Scripts\nose2 -s src\mango\test -c src\mango\unittest.cfg $(MANGO_TEST_OPTS)"
294307

295308

296309
################################################################################
@@ -350,7 +363,6 @@ dist: all derived
350363

351364
.PHONY: release
352365
# target: release - Create an Erlang release including CouchDB!
353-
-include install.mk
354366
release: all
355367
@echo 'Installing CouchDB into rel\couchdb\ ...'
356368
-@rmdir /s/q rel\couchdb >NUL 2>&1 || true

README-DEV.rst

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ Configure the source by running::
152152

153153
./configure
154154

155-
If you intend to run the test suites::
155+
If you intend to run the test suites with Clouseau::
156156

157-
./configure -c
157+
./configure --enable-clouseau
158158

159159
If you don't want to build Fauxton or documentation specify
160160
``--disable-fauxton`` and/or ``--disable-docs`` arguments for ``configure`` to
@@ -237,14 +237,8 @@ but it could be done manually via the corresponding target::
237237

238238
make elixir-search
239239

240-
Note that this requires a running Clouseau instance with the name
241-
``clouseau@127.0.0.1``. The easiest way to get it is to clone the
242-
`cloudant-labs/clouseau <https://github.com/cloudant-labs/clouseau>`_
243-
repository and launch it run there once all the prerequisites (JDK,
244-
Scala, and Maven) have been installed successfully, e.g.::
245-
246-
git clone https://github.com/cloudant-labs/clouseau
247-
mvn -f clouseau/pom.xml scala:run
240+
Note that this requires Clouseau to be configured for running, see
241+
above.
248242

249243
Mango Integration Tests
250244
~~~~~~~~~~~~~~~~~~~~~~~
@@ -262,7 +256,7 @@ the implementation. Consult its documentation for more information.
262256

263257
Tests that rely on text indexes are run only if the ``search`` feature
264258
is reported to be available (i.e. a working Clouseau instance is
265-
connected), otherwise they will be skipped.
259+
configured and working), otherwise they will be skipped.
266260

267261
Note that the databases that are created during the tests will be all
268262
removed after each of the suites completed. However, with the help of
@@ -272,6 +266,58 @@ to keep those databases around for further investigation::
272266
MANGO_TESTS_KEEP_DBS=please \
273267
make mango-test MANGO_TEST_OPTS='03-operator-test'
274268

269+
Running Clouseau
270+
~~~~~~~~~~~~~~~~
271+
272+
When configured with the ``./configure`` script, the ``./dev/run``
273+
script is capable of launching Clouseau instances alongside the
274+
CouchDB nodes and hooking them up. This is what the ``mango-test``
275+
and ``elixir-search`` targets also use to run their respective test
276+
suites, and let Clouseau automatically manage them.
277+
278+
Although the ``./configure`` and the ``./dev/run`` scripts try to take
279+
care of the details of the Clouseau deployment, it is still the
280+
responsibility of the user to provide a suitable Java environment for
281+
running. Clouseau can run with JRE 1.7 and 1.8 only. Also, when
282+
Nouveau is in use, which uses a more recent Java environment, the old
283+
JDK has to be installed separately and the ``CLOUSEAU_JAVA_HOME``
284+
environment variable has to be set to point its location.
285+
286+
Fortunately, the ```asdf`` tool <https://asdf-vm.com/>` provides a
287+
convenient way to install old versions of JDK through its ```java``
288+
plugin <https://github.com/halcyon/asdf-java>`::
289+
290+
asdf plugin add java
291+
292+
Then use ``asdf`` to install it::
293+
294+
asdf install java zulu-jre-8.74.0.17
295+
296+
Finally, use ``asdf`` to set the ``CLOUSEAU_JAVA_HOME`` environment
297+
variable::
298+
299+
export CLOUSEAU_JAVA_HOME=$(asdf where java zulu-jre-8.74.0.17)
300+
301+
If the use of ``asdf`` is not an option, `the Zulu site
302+
<https://cdn.azul.com/zulu/bin/>` could be used directly to get the
303+
distribution package for the appropriate JRE version. But this is
304+
just one of the possibilities to access installers for old Java
305+
environments.
306+
307+
Once both Clouseau and the corresponding Java environment are set,
308+
they are not put in use automatically. In order to do so, the
309+
``./dev/run`` script needs to be run with Clouseau enabled as
310+
follows::
311+
312+
dev/run --with-clouseau
313+
314+
When a specific Erlang cookie string is set in
315+
``rel/overlay/etc/vm.args``, the ``--erlang-cookie`` flag could be
316+
used to configure Clouseau to work with that::
317+
318+
dev/run --with-clouseau --erlang-cookie=brumbrum
319+
320+
275321
Static Code Analysis
276322
~~~~~~~~~~~~~~~~~~~~
277323

build-aux/Jenkinsfile.full

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,47 @@ meta = [
2727
name: 'CentOS 7',
2828
spidermonkey_vsn: '1.8.5',
2929
enable_nouveau: true,
30+
enable_clouseau: false,
3031
image: "apache/couchdbci-centos:7-erlang-${ERLANG_VERSION}"
3132
],
3233

3334
'centos8': [
3435
name: 'CentOS 8',
3536
spidermonkey_vsn: '60',
3637
enable_nouveau: true,
38+
enable_clouseau: false,
3739
image: "apache/couchdbci-centos:8-erlang-${ERLANG_VERSION}"
3840
],
3941

4042
'bionic': [
4143
name: 'Ubuntu 18.04',
4244
spidermonkey_vsn: '1.8.5',
4345
enable_nouveau: true,
46+
enable_clouseau: false,
4447
image: "apache/couchdbci-ubuntu:bionic-erlang-${ERLANG_VERSION}"
4548
],
4649

4750
'focal': [
4851
name: 'Ubuntu 20.04',
4952
spidermonkey_vsn: '68',
5053
enable_nouveau: true,
54+
enable_clouseau: false,
5155
image: "apache/couchdbci-ubuntu:focal-erlang-${ERLANG_VERSION}"
5256
],
5357

5458
'jammy': [
5559
name: 'Ubuntu 22.04',
5660
spidermonkey_vsn: '91',
5761
enable_nouveau: true,
62+
enable_clouseau: false,
5863
image: "apache/couchdbci-ubuntu:jammy-erlang-${ERLANG_VERSION}"
5964
],
6065

6166
'buster': [
6267
name: 'Debian 10',
6368
spidermonkey_vsn: '60',
6469
enable_nouveau: true,
70+
enable_clouseau: false,
6571
image: "apache/couchdbci-debian:buster-erlang-${ERLANG_VERSION}"
6672
],
6773

@@ -72,6 +78,7 @@ meta = [
7278
// name: 'Debian 11 ARM',
7379
// spidermonkey_vsn: '78',
7480
// enable_nouveau: true,
81+
// enable_clouseau: false,
7582
// image: "apache/couchdbci-debian:bullseye-erlang-${ERLANG_VERSION}",
7683
// node_label: 'arm64v8'
7784
// ],
@@ -80,6 +87,7 @@ meta = [
8087
name: 'Debian 11 POWER',
8188
spidermonkey_vsn: '78',
8289
enable_nouveau: true,
90+
enable_clouseau: false,
8391
image: "apache/couchdbci-debian:bullseye-erlang-${ERLANG_VERSION}",
8492
node_label: 'ppc64le'
8593
],
@@ -98,32 +106,37 @@ meta = [
98106
name: 'Debian 11',
99107
spidermonkey_vsn: '78',
100108
enable_nouveau: true,
109+
enable_clouseau: true,
101110
image: "apache/couchdbci-debian:bullseye-erlang-${ERLANG_VERSION}"
102111
],
103112

104113
'bookworm': [
105114
name: 'Debian 12',
106115
spidermonkey_vsn: '78',
107116
enable_nouveau: true,
117+
enable_clouseau: false,
108118
image: "apache/couchdbci-debian:bookworm-erlang-${ERLANG_VERSION}"
109119
],
110120

111121
'freebsd-x86_64': [
112122
name: 'FreeBSD',
113123
spidermonkey_vsn: '91',
124+
enable_clouseau: false,
114125
gnu_make: 'gmake'
115126
],
116127

117128
'freebsd-arm64': [
118129
name: 'FreeBSD',
119130
spidermonkey_vsn: '91',
131+
enable_clouseau: false,
120132
gnu_make: 'gmake'
121133
],
122134

123135
'macos': [
124136
name: 'macOS',
125137
spidermonkey_vsn: '91',
126138
enable_nouveau: false,
139+
enable_clouseau: false,
127140
gnu_make: 'make'
128141
]
129142
]
@@ -133,6 +146,9 @@ def String configure(config) {
133146
if (config.enable_nouveau) {
134147
result += " --enable-nouveau"
135148
}
149+
if (config.enable_clouseau) {
150+
result += " --enable-clouseau"
151+
}
136152
return result
137153
}
138154

@@ -170,6 +186,7 @@ def generateNativeStage(platform) {
170186
sh '$MAKE'
171187
sh '$MAKE eunit'
172188
sh '$MAKE elixir'
189+
sh '$MAKE elixir-search'
173190
sh '$MAKE mango-test'
174191
sh '$MAKE weatherreport-test'
175192
sh '$MAKE nouveau-test'
@@ -223,6 +240,7 @@ def generateContainerStage(platform) {
223240
sh 'make'
224241
sh 'make eunit'
225242
sh 'make elixir'
243+
sh 'make elixir-search'
226244
sh 'make mango-test'
227245
sh 'make weatherreport-test'
228246
sh 'make nouveau-test'

0 commit comments

Comments
 (0)