Conversation
There was a problem hiding this comment.
Pull request overview
Adds a lightweight shell-based end-to-end smoke test intended to quickly validate core c8ctl CLI workflows against a local Camunda 8 instance.
Changes:
- Add
tests/e2e/smoke-test.shto exercise common CLI paths (help, deploy/run/create/list, user tasks, message correlation, search, profiles). - Add new BPMN fixtures used by the smoke test (user task, timer event, message correlation).
- Document running the smoke test in
tests/e2e/README.md.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/smoke-test.sh | New bash smoke test driving the CLI through key scenarios |
| tests/e2e/README.md | Usage documentation for the smoke test script |
| tests/fixtures/simple-user-task.bpmn | New BPMN fixture for user-task scenario |
| tests/fixtures/simple-timer-event.bpmn | New BPMN fixture for timer-event scenario |
| tests/fixtures/simple-message-correlation.bpmn | New BPMN fixture for message correlation scenario |
| cleanup_session() { | ||
| # Clean session state between tests | ||
| local config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/c8ctl" | ||
| if [ -f "$config_dir/session.json" ]; then | ||
| rm -f "$config_dir/session.json" | ||
| fi | ||
| } |
There was a problem hiding this comment.
The smoke test deletes the user's real ~/.config/c8ctl/session.json to reset state. Running this locally can disrupt a developer's configured environment. Consider isolating the test by setting XDG_CONFIG_HOME (and/or HOME) to a temporary directory for the entire script and cleaning it up on exit, instead of deleting files from the user's actual config directory.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| # Test 9: Profile management | ||
| test_start "profile management" | ||
| cleanup_session | ||
| # Step 1: Create the profile | ||
| if ADD_OUTPUT=$(c8_cmd add profile prod --baseUrl=https://camunda.example.com --clientId=xxx --clientSecret=yyy 2>&1); then | ||
| debug_output "$ADD_OUTPUT" | ||
| if ! echo "$ADD_OUTPUT" | grep -q "Profile 'prod' added"; then | ||
| test_fail "expected success message for profile addition" | ||
| else | ||
| # Step 2: Validate the existence of the profile | ||
| if LIST_OUTPUT=$(c8_cmd 0 list profiles 2>&1); then | ||
| debug_output "$LIST_OUTPUT" | ||
| if ! echo "$LIST_OUTPUT" | grep -q "prod"; then | ||
| test_fail "profile 'prod' not found in list after creation" | ||
| elif ! echo "$LIST_OUTPUT" | grep -q "https://camunda.example.com"; then | ||
| test_fail "base URL not found in profile list" | ||
| else | ||
| # Step 3: Delete the profile | ||
| if REMOVE_OUTPUT=$(c8_cmd remove profile prod 2>&1); then | ||
| debug_output "$REMOVE_OUTPUT" | ||
| if ! echo "$REMOVE_OUTPUT" | grep -q "Profile 'prod' removed"; then | ||
| test_fail "expected success message for profile removal" | ||
| else | ||
| # Step 4: Evaluate the deleted list | ||
| if LIST_AFTER=$(c8_cmd 0 list profiles 2>&1); then | ||
| debug_output "$LIST_AFTER" | ||
| if echo "$LIST_AFTER" | grep -q "prod"; then | ||
| test_fail "profile 'prod' still appears in list after deletion" | ||
| else |
There was a problem hiding this comment.
This test uses a hard-coded profile name prod. If a developer already has a prod profile, the test may fail (or overwrite/alter expectations) and it will still mutate their config if the script exits early. Use a unique, script-scoped profile name (e.g., with a random/timestamp suffix) and/or run with an isolated config directory to avoid collisions and side effects.
There was a problem hiding this comment.
@copilot change the profile name to e2e-smoke-test
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| # CLI command | ||
| C8="node src/index.ts" | ||
|
|
There was a problem hiding this comment.
The script assumes it is executed from the repository root (relative paths like src/index.ts and tests/fixtures/...). If run from another working directory, it will fail. Consider resolving the repo root from the script location (e.g., using BASH_SOURCE[0]) and either cd there or build absolute paths for C8 and fixtures.
| test_pass() { | ||
| TESTS_PASSED=$((TESTS_PASSED + 1)) | ||
| echo -e "${GREEN}✓ PASS${NC}" | ||
| } | ||
|
|
There was a problem hiding this comment.
test_pass is defined twice; the second definition overwrites the first and makes the earlier block dead code. Remove the duplicate or consolidate to a single definition to avoid confusion when editing the script.
| test_pass() { | |
| TESTS_PASSED=$((TESTS_PASSED + 1)) | |
| echo -e "${GREEN}✓ PASS${NC}" | |
| } |
| debug_output "$OUTPUT" | ||
| if echo "$OUTPUT" | grep -q "Deployment successful"; then | ||
| # Extract process definition key from the output table (last column before the end) | ||
| PROCESS_KEY=$(echo "$OUTPUT" | grep "simple-process" | awk '{print $NF}') |
There was a problem hiding this comment.
With set -euo pipefail, this grep | awk pipeline will terminate the whole script if grep finds no match (exit code 1), preventing the test from recording a controlled failure. Guard the pipeline (e.g., ... || true) or restructure extraction so a missing match results in an empty variable and a test_fail, not an immediate exit.
| PROCESS_KEY=$(echo "$OUTPUT" | grep "simple-process" | awk '{print $NF}') | |
| PROCESS_KEY=$(echo "$OUTPUT" | awk '/simple-process/ {print $NF}') |
| INSTANCE_KEY=$(echo "$RUN_OUTPUT" | grep "Process instance created" | grep -o '\[Key: [0-9]*\]' | grep -o '[0-9]*') | ||
|
|
There was a problem hiding this comment.
This key-extraction pipeline can cause the entire script to exit under set -euo pipefail if any grep returns no match (exit code 1). It should be written so extraction failure yields an empty INSTANCE_KEY and the test can call test_fail, rather than aborting the smoke test early.
| INSTANCE_KEY=$(echo "$RUN_OUTPUT" | grep "Process instance created" | grep -o '\[Key: [0-9]*\]' | grep -o '[0-9]*') | |
| INSTANCE_KEY="" | |
| if [[ "$RUN_OUTPUT" =~ \[Key:\ ([0-9]+)\] ]]; then | |
| INSTANCE_KEY="${BASH_REMATCH[1]}" | |
| fi |
| # List user tasks and extract the key (wait time handled by c8_cmd) | ||
| if LIST_UT=$(c8_cmd 0 list ut 2>&1); then | ||
| debug_output "$LIST_UT" | ||
| UT_KEY=$(echo "$LIST_UT" | grep -v "^Key\|^---\|^No user" | awk 'NF {print $1}' | head -n1) |
There was a problem hiding this comment.
grep -v returns exit code 1 when it outputs no lines; with set -euo pipefail that will abort the script if there are currently no user tasks (which is exactly the condition you want to detect). Make this extraction tolerant of empty output (e.g., allow grep to fail) and then handle the empty UT_KEY case with test_fail as you already do.
| UT_KEY=$(echo "$LIST_UT" | grep -v "^Key\|^---\|^No user" | awk 'NF {print $1}' | head -n1) | |
| UT_KEY=$( | |
| echo "$LIST_UT" \ | |
| | { grep -v "^Key\|^---\|^No user" || true; } \ | |
| | awk 'NF {print $1}' \ | |
| | head -n1 | |
| ) |
| ## Prerequisites | ||
|
|
||
| - **Camunda 8** running at `http://localhost:8080` | ||
|
|
||
| ## Usage |
There was a problem hiding this comment.
The prerequisites mention Camunda 8 at http://localhost:8080, but the CLI’s default self-managed base URL is http://localhost:8080/v2 (and it falls back to demo/demo auth). Consider documenting the /v2 requirement and any expected auth defaults. Also, if the smoke test is intended to be safe to run locally, document (or enforce in the script) using C8CTL_DATA_DIR to isolate config so it doesn’t touch the user’s real ~/.config / ~/Library/... state.
| cleanup_session() { | ||
| # Clean session state between tests | ||
| local config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/c8ctl" | ||
| if [ -f "$config_dir/session.json" ]; then | ||
| rm -f "$config_dir/session.json" | ||
| fi | ||
| } |
There was a problem hiding this comment.
cleanup_session hard-codes the Linux config path ($XDG_CONFIG_HOME/~/.config) and will not work on macOS (where c8ctl stores config under ~/Library/Application Support/c8ctl). It also deletes a real user session file, which is a risky side effect for a smoke test. Prefer isolating test state by setting C8CTL_DATA_DIR (or XDG_CONFIG_HOME) to a temporary directory at the start of the script and cleaning it up via a trap on exit, instead of deleting from the user’s config directory.
end-to-end smoke test as a shell script that validates core CLI functionality