oscerd opened a new pull request, #3008:
URL: https://github.com/apache/camel-kamelets/pull/3008

   Follow-up to #3007, which shipped `couchbase-source` without a test on the 
grounds that the project's Citrus toolchain had no Couchbase container. That 
was true only in the sense that there is no *built-in* one — the generic 
container works fine, it just needs setting up by hand.
   
   ## The test
   
   ```
   testcontainers: start: container (couchbase/server:community-7.6.2)
     -> initCluster.groovy   (cluster init, bucket, primary index, seed one 
document)
     -> camel: cli: run      (couchbase-source -> log-sink)
     -> camel: cli: verify   (logMessage: "hello-from-couchbase")
   ```
   
   Same shape as the existing `mongodb-source-route` test, so it should read 
familiarly.
   
   ## Three things that were not optional
   
   Recording these because each cost a full run to find, and the next person 
adding a container-based test will hit at least one.
   
   **Ports are bound one-to-one.** The Couchbase SDK bootstraps from the 
management port and then reconnects using the addresses the *cluster* 
advertises. With a remapped host port the client bootstraps and then cannot 
reach the data service. Hence explicit `8091:8091`, `8093:8093`, `11210:11210` 
rather than `exposedPorts`.
   
   **The wait strategy needs a full-line regex.** Testcontainers matches log 
wait patterns against the entire line, so `"Starting Couchbase Server"` never 
matches the actual line and the container times out after five minutes. It has 
to be `".*Starting Couchbase Server.*"`.
   
   **No Groovy GStrings in the script.** Citrus resolves dollar-brace 
expressions in these scripts as its own test variables, so a GString fails with 
`Unknown variable 'user'`. The script uses string concatenation throughout — 
including, eventually, in the comment that explains why.
   
   ## Why the statement looks the way it does
   
   ```properties
   couchbase.statement=SELECT META().id AS __id, * FROM _default
   ```
   
   Not the obvious `SELECT * FROM <bucket>`, because both halves matter:
   
   - `CouchbaseConsumer` reads `row.getString("__id")` and **skips any row 
without it**, logging a warning rather than failing. A query without `META().id 
AS __id` yields a source that polls happily and emits nothing.
   - The consumer runs the query through `scope.query(...)`, so the keyspace is 
resolved as `<bucket>._default.<what-you-wrote>`. `FROM <bucket>` becomes 
`<bucket>._default.<bucket>` and fails with `Keyspace not found`.
   
   I found both by running the Kamelet against a live cluster, and they mean 
**the example currently shipped in `couchbase-source` is wrong** — `SELECT * 
FROM \`travel-sample\` LIMIT 10` would silently return nothing. That is my 
error from #3007. I am fixing it in a separate PR rather than folding a Kamelet 
change into a test PR.
   
   ## Verification
   
   Passes locally, twice through (test and verify phases), about 35 seconds 
each:
   
   ```
   Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 -- in CouchbaseIT
     ✔ SUCCESS (38088ms) couchbase-source-route-test
   ```
   
   `mvn clean install` passes with tests from the repository root.
   
   ## For reviewers
   
   **The image is large** — `couchbase/server:community-7.6.2` is about 1.7 GB, 
materially bigger than redpanda or floci. On a cold CI cache that is a real 
cost for one test, and worth weighing against the value of covering this 
Kamelet.
   
   **I did not add `camel.apache.org/kamelet.verified: "true"`.** The 
contributor guide ties that label to having passing behaviour tests, but it is 
applied to only 21 Kamelets and notably not to `mongodb-source`, which does 
have a test — so it looks like a curation decision rather than an automatic 
consequence. Happy to add it if you want it applied here.
   
   ---
   _Claude Code on behalf of Andrea Cosentino_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to