Skip to content

Add smoke test infrastructure#91

Draft
janisz wants to merge 12 commits intomainfrom
smoke_test
Draft

Add smoke test infrastructure#91
janisz wants to merge 12 commits intomainfrom
smoke_test

Conversation

@janisz
Copy link
Contributor

@janisz janisz commented Mar 24, 2026

Description

Add smoke tests that run against real StackRox Central deployment.
Tests verify end-to-end functionality including connection, authentication,
and CVE detection with actual scanning.

  • Add smoke/smoke_test.go with table-driven tests
  • Add smoke/testdata/vulnerable-deployment.yaml with CVE-2023-32697
  • Extract shared test helpers to test_helpers.go for reuse
  • Update integration_helpers.go to use shared helpers

Tests read ROX_ENDPOINT and ROX_PASSWORD from environment variables.

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

Validation

janisz and others added 2 commits March 24, 2026 12:05
Add smoke tests that run against real StackRox Central deployment.
Tests verify end-to-end functionality including connection, authentication,
and CVE detection with actual scanning.

- Add smoke/smoke_test.go with table-driven tests
- Add smoke/testdata/vulnerable-deployment.yaml with CVE-2023-32697
- Extract shared test helpers to test_helpers.go for reuse
- Update integration_helpers.go to use shared helpers

Tests read ROX_ENDPOINT and ROX_PASSWORD from environment variables.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add workflow that runs smoke tests against real StackRox Central on kind.
Follows stackrox/jenkins-plugin deployment approach.

Workflow:
- Creates kind cluster
- Deploys StackRox Central via stackrox/deploy/k8s/deploy-local.sh
- Waits for Scanner readiness
- Deploys vulnerable workload
- Runs smoke tests with JUnit output
- Uploads results and coverage to Codecov

Runs on every PR and push to main.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2 2 0 12
View the top 2 failed test(s) by shortest run time
::policy 1
Stack Traces | 0s run time
- test violation 1
- test violation 2
- test violation 3
::policy 4
Stack Traces | 0s run time
- testing multiple alert violation messages 1
- testing multiple alert violation messages 2
- testing multiple alert violation messages 3

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions
Copy link

github-actions bot commented Mar 24, 2026

E2E Test Results

Commit: 7646ac5
Workflow Run: View Details
Artifacts: Download test results & logs

=== Evaluation Summary ===

  ✓ list-clusters (assertions: 3/3)
  ✓ cve-detected-workloads (assertions: 3/3)
  ✓ cve-detected-clusters (assertions: 3/3)
  ~ cve-nonexistent (assertions: 2/3)
      - MaxToolCalls: Too many tool calls: expected <= 5, got 9
  ✓ cve-cluster-does-exist (assertions: 3/3)
  ~ cve-cluster-does-not-exist (assertions: 2/3)
      - ToolsUsed: Required tool not called: server=stackrox-mcp, tool=, pattern=list_clusters
  ✓ cve-clusters-general (assertions: 3/3)
  ✓ cve-cluster-list (assertions: 3/3)
  ✓ cve-log4shell (assertions: 3/3)
  ✓ cve-multiple (assertions: 3/3)
  ✓ rhsa-not-supported (assertions: 2/2)

Tasks:      11/11 passed (100.00%)
Assertions: 30/32 passed (93.75%)
Tokens:     ~57484 (estimate - excludes system prompt & cache)
MCP schemas: ~12738 (included in token total)
Agent used tokens:
  Input:  20851 tokens
  Output: 23321 tokens
Judge used tokens:
  Input:  42285 tokens
  Output: 37033 tokens

janisz and others added 3 commits March 24, 2026 17:04
Set CPU and memory requests to 0 to avoid scheduling issues in CI.
Add comprehensive log collection on workflow completion for debugging.

Logs collected:
- All pods status
- All events sorted by time
- Vulnerable app logs
- Central logs
- Scanner logs
- Pod descriptions

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace unavailable custom image with nginx:1.14 which is publicly
accessible and has known CVEs for testing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add blank identifier for ignored Close error in cleanup
- Split long function signature across multiple lines

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
janisz and others added 7 commits March 24, 2026 19:11
Generate proper API token via StackRox Central REST API instead of
using admin password directly. This fixes authentication failures where
the password was incorrectly used as an API token.

Changes:
- Add API token generation step using curl to /v1/apitokens endpoint
- Use basic auth (admin:password) to authenticate token generation
- Pass generated token to tests via ROX_API_TOKEN env var
- Update smoke test to read ROX_API_TOKEN instead of ROX_PASSWORD
- Fix shellcheck SC2086 warning by quoting variables

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace fixed sleep timers with active polling and reorder steps for
faster feedback. Deploy vulnerable workload immediately so scanning
starts while Central initializes.

Changes:
- Move vulnerable workload deployment before Central wait (parallel)
- Replace sleep 120s with kubectl wait for Central pods ready
- Remove sleep 60s for deployment scan
- Add waitForImageScan() using assert.Eventually for smart polling
- Poll every 5s with 3min timeout for scan completion

Expected improvement: ~5-8 minutes faster workflow execution.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The workflow was creating manual port-forwards to localhost:8443 and
killing them prematurely, causing race conditions. The deploy-local.sh
script already sets up port-forwarding to localhost:8000, so we now
use that instead. Added comprehensive validation with exponential
backoff polling, HTTP status checking, and JSON validation to prevent
null token issues that were causing authentication failures.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The correct endpoint is /v1/apitokens/generate, not /v1/apitokens.
This was causing 501 "Method Not Allowed" errors.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The deploy-local.sh script creates a password file that should be used
for authentication. Reading from the kubernetes secret was causing
authentication failures with "failed to identify user with username admin".

Following the same approach as jenkins-plugin workflow.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Moves token generation from bash/curl in the GitHub Actions workflow
to Go code in the smoke test. This provides:
- Better error handling with typed responses
- Reusable code that works locally and in CI
- Simpler CI workflow (just passes password)
- Easier debugging and testing

Changes:
- Add smoke/token_helper.go with GenerateAPIToken and WaitForCentralReady
- Update smoke_test.go to generate token from password if needed
- Simplify workflow to pass ROX_PASSWORD instead of generating token
- Maintains backwards compatibility with ROX_API_TOKEN

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ct CVE

Changes:
1. Add sensor pod readiness wait in workflow
2. Add cluster health status check - waits for HEALTHY status before tests
3. Change CVE from CVE-2019-11043 (PHP-FPM) to CVE-2019-9511 (nginx HTTP/2)
4. Increase image scan timeout from 3 to 5 minutes

Fixes:
- Empty cluster list issue: Now waits for sensors to register and cluster to be healthy
- CVE not found issue: CVE-2019-9511 actually exists in nginx:1.14

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants