This document comprehensively describes what each test is testing and what it is NOT testing, along with any ambiguities that need clarification.
- Constructor:
TestNewFileLock()validates thatNewFileLock()returns a non-nil instance with initialized map - Basic locking:
TestFileLock_Lock()tests that new files can be locked successfully, including edge cases (empty strings, filenames with spaces) - Double locking prevention:
TestFileLock_DoubleLock()ensures the same file cannot be locked twice - Lock status checking:
TestFileLock_IsLocked()validates lock state queries and isolation between different filenames - Unlocking:
TestFileLock_Unlock()tests that unlocked files can be locked again - Graceful error handling:
TestFileLock_UnlockNonExistent()ensures unlocking non-existent locks doesn't panic - Concurrency safety:
TestFileLock_ConcurrentAccess()tests that only one goroutine can acquire the same lock - Parallel locking:
TestFileLock_ConcurrentDifferentFiles()tests that different files can be locked simultaneously - Lock lifecycle:
TestFileLock_LockUnlockCycle()tests repeated lock/unlock cycles
- Memory cleanup after many lock/unlock cycles
- Behavior with extremely long filenames (>1000 chars)
- Performance under high contention
- Lock timeouts or expiration
- Persistence across process restarts
- ✅ RESOLVED: Empty string filenames are NOT allowed -
Lock("")andIsLocked("")returnfalse - What's the maximum supported filename length? Should there be validation or limits?
- Should there be any filename sanitization (e.g., path traversal protection)?
- Basic validation:
TestIsAvroFileName()tests the core logic that files must end with ".avro" - Path handling: Tests that files with paths (e.g., "path/to/data.avro") are accepted
- Case sensitivity: Validates that only lowercase ".avro" is accepted
- Extension isolation: Tests that ".avro" in the middle or start of filename doesn't count
- Special characters: Tests hyphens, underscores, numbers in filenames
- Edge cases: Empty strings, very long filenames, multiple dots
- Whitespace handling: Tests that filenames with leading/trailing whitespace are rejected
- File existence on disk
- File readability/permissions
- File content validation
- Unicode filename support
- Network path handling (UNC paths, etc.)
- ✅ RESOLVED:
.avroalone is NOT a valid filename - requires at least one character before the extension - Should Unicode characters in filenames be supported? (e.g., "データ.avro")
- What about case-insensitive filesystems? Should "DATA.AVRO" be accepted on Windows?
- Should there be any path traversal validation (e.g., reject "../../../etc/passwd.avro")?
- Default behavior:
TestLoadConfig_DefaultValues()validates Kafka defaults but empty TLS values - Environment override:
TestLoadConfig_EnvironmentVariables()tests that env vars override defaults - Partial configuration:
TestLoadConfig_PartialEnvironmentVariables()tests mixed env/default behavior - Empty string handling:
TestLoadConfig_EmptyEnvironmentVariables()tests that empty strings fall back to defaults for Kafka but remain empty for TLS - Struct integrity:
TestConfig_StructFields()ensures all expected fields exist
- Invalid file paths in configuration
- Configuration validation (e.g., checking if cert files exist)
- Configuration reload/hot-reload
- Command-line flag integration
- JSON file configuration support (commented out in code)
- Configuration precedence order beyond env vars and defaults
- Why do TLS fields have no defaults while Kafka fields do? Is this intentional security behavior?
- Should the system validate that certificate files exist and are readable?
- What should happen with invalid file paths in configuration? (e.g., "/nonexistent/path.crt")
- Should there be validation that TLS_CERT and TLS_KEY are both set or both empty?
- Timeout calculation: Tests the 0.85 multiplier formula for response header timeouts
- No-op behavior:
TestHTTPClientManager_SetTimeout_NoOpSameValue()tests that setting the same timeout twice is a no-op - Precision edge cases: Tests very small timeouts and floating-point precision
- Configuration application: Tests that timeouts are applied to both client and transport
- Getter methods: Tests
APIBase()andClient()methods
- Actual network timeouts in practice
- Interaction with real TLS handshakes
- Transport connection pooling behavior
- Error handling when timeout values are invalid
- Concurrent timeout modifications
- Memory leaks from transport recreation
- Why specifically 0.85 as the multiplier? Is this based on empirical testing or network analysis?
- Should there be minimum/maximum timeout limits? (e.g., reject timeouts < 100ms or > 10 minutes)
- What should happen with zero or negative timeouts?
- Should concurrent calls to SetTimeout() be thread-safe?
- Constructor validation:
TestNewAvroHandler()tests proper initialization including timeout calculation (+5s) - Configuration endpoint:
TestAvroHandler_Config()tests JSON response format - SHA256 validation: Tests that incorrect SHA256 headers result in BadRequest
- File size validation: Tests that mismatched file sizes result in BadRequest
- Size limits:
TestAvroHandler_readPostedFile_SizeLimit()tests 20MB limit enforcement - Rate limiting: Tests that exceeding request limiter capacity returns 429
- Authorization: Tests that missing hostname results in 401
- Empty data handling: Tests SHA256 calculation for empty files
- Actual Avro schema validation and parsing (requires full setup)
- Kafka message production (would need Kafka integration)
- Complete request flow with valid Avro data
- Memory usage with large files
- Cleanup of temporary files in error scenarios
- Concurrent request handling beyond rate limiting
- ✅ RESOLVED: Client timeout = timeoutStick + 5s - So client times out after the server
- ✅ RESOLVED: Rate limiter capacity = 20 - To prevent overloading the Kafka server
- Should there be different rate limits for different certificate types/hostnames?
- What should happen if temporary file creation fails due to disk space?
- ✅ RESOLVED: 20MB limit is in the server - Located in
logferry-api/avro.goline 248. Should this be configurable?
- Domain suffix validation: Tests
.mon.ntppool.devand.ntppool.netsuffixes - Priority order: Tests that
.mon.ntppool.devhas precedence over.ntppool.net - Security edge cases: Tests against domain manipulation attempts
- Certificate chain handling: Tests multiple certificates and chains
- DNS name processing: Tests multiple DNS names per certificate
- Case sensitivity: Tests that domain matching is case-sensitive
- Empty input handling: Tests behavior with empty/nil certificate chains
- Certificate expiration validation
- Certificate revocation checking
- Certificate signature validation
- Certificate authority validation
- Certificate key usage validation
- Client certificate mutual TLS handshake
- ✅ RESOLVED:
.mon.ntppool.devhas priority - Because it's used most frequently - Should domain matching be case-insensitive to be more robust against certificate variations?
- What about subdomain depth limits? Should
very.deep.sub.domain.mon.ntppool.devbe accepted? - Should there be wildcard certificate support (e.g.,
*.mon.ntppool.dev)? - What happens if a certificate has both valid and invalid DNS names? Currently returns the first valid one - is this correct?
- Should there be additional certificate validation beyond DNS name checking?
- Input sanitization: No tests for malicious inputs (SQL injection, XSS, etc.)
- Denial of service: No tests for resource exhaustion attacks
- Path traversal: Limited testing of file path validation
- Network failures: Limited testing of network error scenarios
- Disk space: No testing of disk full scenarios
- Memory pressure: No testing under low memory conditions
- Load testing: No tests under high load
- Memory leaks: No long-running tests to detect leaks
- Garbage collection: No tests of GC behavior under load
- End-to-end flows: Tests are mostly unit tests, limited integration
- External dependencies: No testing with real Kafka, file systems, etc.
- Configuration interaction: Limited testing of configuration edge cases
Based on feedback, the following behaviors have been clarified and implemented:
- ✅ File locking with empty strings: NOT allowed - returns
false - ✅ Avro filename validation:
.avroalone is NOT valid - requires filename before extension - ✅ TLS certificate domain precedence:
.mon.ntppool.devhas priority because it's used most - ✅ Timeout calculations: +5s buffer ensures client times out after server; 0.85 multiplier still needs investigation
- ✅ Rate limiting strategy: Global limit of 20 to prevent Kafka overload
- ✅ 20MB file limit: Located in server, may need to be configurable
- Timeout calculations: What's the rationale for the 0.85 multiplier for response headers?
- Rate limiting strategy: Should limits be per-hostname or remain global?
- Configuration validation: Should the system validate file existence?
- Unicode filename support: Should filenames like "データ.avro" be supported?
- Case sensitivity: Should domain matching be case-insensitive for robustness?
- Error handling: What's the preferred behavior for edge cases like disk full, invalid certificates, etc.?
These remaining clarifications would help improve test coverage and ensure the tests match intended system behavior.