Repository navigation
test: make lib tests hermetic (#7) - #13
Merged
Merged
Conversation
KafkaProcessor::health_check reads `health.check.timeout.ms` from the processor config, but KafkaProcessor::new forwarded every config key to rdkafka's ClientConfig. librdkafka rejects unknown properties, so setting the documented health-check timeout made producer creation fail with "No such configuration property". Skip that key when building the client config. Refs #7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`cargo test --all-features --lib` failed 20 tests without credentials, Kafka or Pub/Sub. - key_manager: the DB tests supply an explicit static master key instead of reading HAMMERWORK_MASTER_KEY. They use plain #[tokio::test] with #[ignore = "requires <db>: <env var>"] and connect through DATABASE_URL or MYSQL_DATABASE_URL, so the MySQL tests no longer depend on #[sqlx::test] reading DATABASE_URL. Each backend's tests are serialized with a lock, run migrations, and clear the key tables first, because several assert table-wide statistics. Twelve of these tests are blocked by KeyManager persistence bugs (#9) and say so in their ignore reason. - streaming: Kafka health-check and batch-send tests need a real broker (KAFKA_BROKERS). Pub/Sub construction tests need GOOGLE_APPLICATION_CREDENTIALS. These are ignored when the real backend feature is on and skip at runtime if the env var is unset, so `--include-ignored` runs without those services stay green. New hermetic tests cover the Kafka failure paths (unreachable broker) and rejection of an invalid Pub/Sub service account key. The configuration-usage test is split per backend, uses only keys that librdkafka accepts, and checks the fields each placeholder processor actually reports. - integration_tests: test_full_system_integration uses only the Kafka and Kinesis streams, which do not connect at creation. The Pub/Sub variant is a separate gated test. Refs #7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove needless borrows in try_parse_from calls and useless vec! in the spawn, archive and workflow command tests. Refs #7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…BUGS CI runs DB tests with --include-ignored, so the 12 KeyManager tests that fail on the persistence bugs tracked in #9 would keep the PostgreSQL and MySQL jobs red. Return early unless HAMMERWORK_TEST_KNOWN_BUGS is set, matching the convention used for the integration test targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodingAnarchy
force-pushed
the
fix/hermetic-lib-tests
branch
from
October 8, 2026 06:53
4cfb447 to
d8a6d88
Compare
28 of 32 tasks
Owner
Author
|
CI verification: unit tests and the MySQL 8 integration job pass. The PostgreSQL job's remaining failures are doctests (tracked in #7) and the 3 cargo-hammerwork |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #7 (hermetic lib tests workstream).
Summary
cargo test --all-features --libfailed 20 tests that neededHAMMERWORK_MASTER_KEY, Google Pub/Sub credentials or a Kafka broker, or that hit a MySQL#[sqlx::test]pool timeout. After this PR it passes with no env vars or services. Tests that need a real service are#[ignore = "requires <service>: <env vars>"]and read their connection details from env vars.Changes
encryption::key_managertests (14): each test passes a static test master key in its config, so nothing depends onHAMMERWORK_MASTER_KEY. The tests switch from#[sqlx::test]to#[tokio::test]plus#[ignore], and connect throughDATABASE_URL(Postgres) orMYSQL_DATABASE_URL(MySQL). The MySQL tests therefore work in a local run that has both databases, and also in the CI MySQL job. Each backend's tests:streamingtests:KAFKA_BROKERS. Pub/Sub construction tests needGOOGLE_APPLICATION_CREDENTIALS.--include-ignoredthey skip with a message if the env var is unset, so the CI Postgres job (--include-ignored --skip mysql) does not need Kafka or Pub/Sub.test_stream_processor_configuration_usageis split per backend. It now uses only keys librdkafka accepts, and checks the fields each placeholder processor actually reports. This also fixes it under--features streamingand--features kafkaalone.integration_tests::test_full_system_integration: uses the Kafka and Kinesis streams, which don't connect when they are created. The Pub/Sub variant is a separate gated test.KafkaProcessor::newforwarded every config key to librdkafka, including the processor's ownhealth.check.timeout.ms. librdkafka rejects unknown properties, so setting the documented health-check timeout made producer creation fail. That key is now skipped.vec!) in the#[cfg(test)]modules ofcargo-hammerworkspawn.rs,archive.rsandworkflow.rs.Known failures: #9
With databases available, 12 of the 14 key-manager DB tests fail because of real
KeyManagerpersistence bugs, filed as #9:store_key,load_keyandrecord_audit_eventare stubs that always fail.perform_automatic_rotationdoes nothing.key_sourceviolates the CHECK constraint.rotation_intervalas text into anINTERVALcolumn.Each of those tests says
blocked by #9in its ignore reason. Fixing them is a larger library change than this PR's scope, so these tests will keep failing in the Postgres and MySQL CI jobs until #9 lands.test_get_or_create_master_key_id_{postgres,mysql}pass.Test plan
cargo test --all-features --lib, no env vars, 3 runs: 321 passed, 0 failed, 21 ignoredcargo test --all-features --lib -- --include-ignoredwithDATABASE_URLandMYSQL_DATABASE_URL, 3 runs: 330 passed. The 12 failures are exactly the KeyManager persistence is broken on both backends (stubbed DB methods, key_source/interval encoding) #9-blocked tests, and the same 12 each run.cargo test --libwith default features,--features postgres,--features mysql,streaming,kafka,google-pubsubandkinesis: all passcargo test -p cargo-hammerwork --lib --bins: passcargo fmt --all --check;cargo clippy -p hammerwork --all-features --lib -- -D warningsis clean, and the touched#[cfg(test)]code has no findings🤖 Generated with Claude Code