Skip to content

chore: upodate make test#1815

Open
moshloop wants to merge 2 commits intomainfrom
pr/makefile-updates
Open

chore: upodate make test#1815
moshloop wants to merge 2 commits intomainfrom
pr/makefile-updates

Conversation

@moshloop
Copy link
Member

@moshloop moshloop commented Mar 8, 2026

Summary by CodeRabbit

  • Tests

    • Added concurrent test execution support with parallel node capability via new test-concurrent target
    • Enhanced test suite setup for synchronized multi-node execution
    • Improved test filtering and organization with e2e labeling
  • Chores

    • Added indirect dependency

@github-actions
Copy link

github-actions bot commented Mar 8, 2026

Benchstat

Base: 34a4f31c0d72ffec6dd16252cee324e1999ec910
Head: 027187842ec563a6022baebf51009c582bb6fc19

goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                                │ bench-base.txt │          bench-head.txt           │
                                                │     sec/op     │   sec/op     vs base              │
Main/Sample-15000/catalog_changes/Without_RLS-4      5.231m ± 3%   5.252m ± 1%       ~ (p=0.394 n=6)
Main/Sample-15000/catalog_changes/With_RLS-4         129.4m ± 0%   126.3m ± 1%  -2.36% (p=0.002 n=6)
Main/Sample-15000/config_changes/Without_RLS-4       5.241m ± 0%   5.254m ± 1%       ~ (p=0.485 n=6)
Main/Sample-15000/config_changes/With_RLS-4          130.0m ± 2%   128.1m ± 1%  -1.44% (p=0.002 n=6)
Main/Sample-15000/config_detail/Without_RLS-4        3.888m ± 1%   3.898m ± 0%       ~ (p=0.310 n=6)
Main/Sample-15000/config_detail/With_RLS-4           123.7m ± 0%   128.5m ± 1%  +3.84% (p=0.002 n=6)
Main/Sample-15000/config_names/Without_RLS-4         12.80m ± 0%   12.62m ± 3%       ~ (p=0.065 n=6)
Main/Sample-15000/config_names/With_RLS-4            125.6m ± 1%   125.6m ± 1%       ~ (p=0.818 n=6)
Main/Sample-15000/config_summary/Without_RLS-4       59.94m ± 0%   60.27m ± 1%  +0.55% (p=0.004 n=6)
Main/Sample-15000/config_summary/With_RLS-4          739.7m ± 1%   737.3m ± 0%       ~ (p=0.240 n=6)
Main/Sample-15000/configs/Without_RLS-4              7.162m ± 1%   7.124m ± 1%  -0.53% (p=0.041 n=6)
Main/Sample-15000/configs/With_RLS-4                 123.4m ± 2%   123.9m ± 0%       ~ (p=0.394 n=6)
Main/Sample-15000/analysis_types/Without_RLS-4       3.935m ± 2%   3.905m ± 0%       ~ (p=0.065 n=6)
Main/Sample-15000/analysis_types/With_RLS-4          3.877m ± 5%   3.880m ± 1%       ~ (p=0.937 n=6)
Main/Sample-15000/analyzer_types/Without_RLS-4       3.699m ± 1%   3.706m ± 2%       ~ (p=0.180 n=6)
Main/Sample-15000/analyzer_types/With_RLS-4          3.747m ± 1%   3.740m ± 2%       ~ (p=0.394 n=6)
Main/Sample-15000/change_types/Without_RLS-4         5.237m ± 1%   5.253m ± 2%       ~ (p=0.310 n=6)
Main/Sample-15000/change_types/With_RLS-4            5.345m ± 1%   5.248m ± 1%  -1.81% (p=0.002 n=6)
Main/Sample-15000/config_classes/Without_RLS-4       3.275m ± 1%   3.263m ± 1%       ~ (p=0.093 n=6)
Main/Sample-15000/config_classes/With_RLS-4          124.5m ± 0%   122.7m ± 3%       ~ (p=0.065 n=6)
Main/Sample-15000/config_types/Without_RLS-4         3.891m ± 1%   4.020m ± 2%  +3.31% (p=0.002 n=6)
Main/Sample-15000/config_types/With_RLS-4            126.5m ± 1%   123.4m ± 0%  -2.48% (p=0.002 n=6)
geomean                                              19.18m        19.14m       -0.17%

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2026

Walkthrough

This pull request refactors test infrastructure to enable concurrent test execution with coordinated database setup. It introduces synchronized lifecycle hooks across test suites and a new setup module that manages template creation and per-node database cloning for parallel test nodes.

Changes

Cohort / File(s) Summary
Test Infrastructure
Makefile
Added test-concurrent target for running tests with 4 parallel nodes, filtering out benchmarks and e2e tests. Updated existing test target to skip bench package and apply e2e label filter.
Test Suite Configuration
tests/e2e/suite_test.go, tests/suite_test.go
Replaced simple BeforeSuite/AfterSuite hooks with synchronized variants (SynchronizedBeforeSuite/SynchronizedAfterSuite) that coordinate setup across multiple test nodes using new SetupTemplate and SetupNode functions.
Test Labeling & Assertions
tests/e2e/loki_test.go, tests/context_test.go
Added "e2e" label to Loki integration test suite. Updated context trace assertion to align with logger's global IsTraceEnabled() setting.
Database Setup Module
tests/setup/template.go
New module providing SetupTemplate() and SetupNode() functions to orchestrate Postgres template database creation, optional dummy data seeding, and per-node database cloning. Includes synchronized cleanup hooks for multi-node teardown.
Setup Utilities
tests/setup/common.go
Updated cleanup hook label description from "remote postgres" to "remove postgres db".
Dependencies
go.mod
Added indirect dependency on github.com/clipperhouse/stringish v0.1.1.

Sequence Diagram(s)

sequenceDiagram
    participant Ginkgo as Ginkgo Test Runner
    participant SyncSetup as SynchronizedBeforeSuite
    participant Template as SetupTemplate
    participant DB as PostgreSQL
    participant Node as SetupNode
    participant TestContext as Test Context

    Ginkgo->>SyncSetup: Trigger synchronized setup
    SyncSetup->>Template: SetupTemplate(setupOpts)
    Template->>DB: Connect (DUTY_DB_URL or embedded)
    Template->>DB: Create template database
    Template->>DB: Populate dummy data (if enabled)
    Template-->>SyncSetup: Return serialized templateInfo
    
    Note over Ginkgo: Per test node execution
    SyncSetup->>Node: SetupNode(templateInfo, setupOpts)
    Node->>DB: Clone template to node database
    Node->>Node: Setup node context with DB name/URL
    Node->>Node: Inject fake Kubernetes client
    Node-->>TestContext: Return node-specific context
    
    TestContext-->>Ginkgo: Context ready for test execution
Loading
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'chore: upodate make test' contains a typo ('upodate' instead of 'update') and is vague about which make test changes are included. Correct the typo to 'update' and be more specific about the changes, such as 'chore: update make test targets for concurrent testing' to clarify the primary changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pr/makefile-updates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go.mod`:
- Line 114: The go.mod contains improperly organized require blocks (the
indirect entry "github.com/clipperhouse/stringish v0.1.1 // indirect" is out of
order and split across blocks); run `go mod tidy` to merge/clean the require
blocks and reorder entries alphabetically, also update/go mod tidy to refresh
go.sum, then commit the tidied go.mod and go.sum so the module files are
consistent.

In `@Makefile`:
- Around line 15-18: The ginkgo commands in the Makefile (the default ginkgo
target and the test-concurrent target) are missing the repository-standard label
filter for local-ignored tests; update both ginkgo invocations to use
--label-filter "!e2e && !ignore_local" (i.e., add && !ignore_local to the
existing --label-filter) so the lines that currently call ginkgo -r -v
--skip-package=... --label-filter "!e2e" include the combined filter.

In `@tests/setup/template.go`:
- Around line 144-151: The direct-mode branch that checks info.TemplateDB == ""
currently starts duty in duty.ClientOnly via duty.Start("direct",
duty.ClientOnly, ...), which skips migrations and opts.DummyData and allows all
nodes to share one DB; change this branch to follow the same initialization flow
as SetupDB (i.e., invoke duty.Start with the same mode/opts used in SetupDB so
per-node clones, migrations and DummyData are applied, then call
setupNodeContext), or if you intentionally cannot create per-node clones, make
this branch explicitly reject parallel execution (e.g., panic or return an
error) with a clear message; update the code paths around TemplateDB,
duty.Start, and setupNodeContext to reflect the chosen behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61ba1b3e-5561-4cc8-84e3-ba129d6c2bdf

📥 Commits

Reviewing files that changed from the base of the PR and between 34a4f31 and 0271878.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • Makefile
  • go.mod
  • tests/context_test.go
  • tests/e2e/loki_test.go
  • tests/e2e/suite_test.go
  • tests/setup/common.go
  • tests/setup/template.go
  • tests/suite_test.go

)

require (
github.com/clipperhouse/stringish v0.1.1 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the current state of go.mod and see line 114 in context
head -n 120 go.mod | tail -n 20

Repository: flanksource/duty

Length of output: 667


🏁 Script executed:

# Also check the full size of go.mod to understand the file better
wc -l go.mod

Repository: flanksource/duty

Length of output: 70


🏁 Script executed:

# Let's search for the stringish dependency to understand the context
rg "stringish" go.mod go.sum

Repository: flanksource/duty

Length of output: 319


🏁 Script executed:

# Show larger context around line 114 - the indirect require block
sed -n '110,130p' go.mod

Repository: flanksource/duty

Length of output: 879


🏁 Script executed:

# Check the entire indirect require block to see ordering
sed -n '/^require (/,/^)/p' go.mod | grep "indirect"

Repository: flanksource/duty

Length of output: 16297


🏁 Script executed:

# Look for CI configuration files that might show the lint failure
find . -maxdepth 2 -name ".github" -o -name "*.yml" -o -name "*.yaml" | head -20

Repository: flanksource/duty

Length of output: 132


🏁 Script executed:

# Check if there's a Makefile or script that runs go mod tidy
find . -maxdepth 2 -name "Makefile" -o -name "*.sh" | xargs grep -l "go mod tidy" 2>/dev/null || echo "No tidy scripts found"

Repository: flanksource/duty

Length of output: 70


🏁 Script executed:

# Check the Makefile for tidy/lint targets
grep -A 3 "tidy\|lint\|mod" Makefile | head -20

Repository: flanksource/duty

Length of output: 518


🏁 Script executed:

# Look for GitHub Actions workflows
ls -la .github/workflows/ 2>/dev/null || echo "No workflows directory"

Repository: flanksource/duty

Length of output: 535


🏁 Script executed:

# Check golangci.yaml for relevant lint rules
cat .golangci.yaml

Repository: flanksource/duty

Length of output: 671


🏁 Script executed:

# Check the lint.yml workflow for go mod tidy check
cat .github/workflows/lint.yml

Repository: flanksource/duty

Length of output: 961


Commit the tidied module files.

The go.mod file violates Go module hygiene. Line 114's indirect dependency is split across two require blocks and lacks proper alphabetical ordering (entries starting with "c" should precede those starting with "g"). Run go mod tidy to reorganize and merge the require blocks, then commit the result.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` at line 114, The go.mod contains improperly organized require blocks
(the indirect entry "github.com/clipperhouse/stringish v0.1.1 // indirect" is
out of order and split across blocks); run `go mod tidy` to merge/clean the
require blocks and reorder entries alphabetically, also update/go mod tidy to
refresh go.sum, then commit the tidied go.mod and go.sum so the module files are
consistent.

Comment on lines +15 to +18
ginkgo -r -v --skip-package=tests/e2e --skip-package=bench --label-filter "!e2e"

test-concurrent: ginkgo
ginkgo -r -v --nodes=4 --skip-package=bench --label-filter "!e2e"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether the repository currently has specs labeled ignore_local.
rg -n --glob '**/*_test.go' 'Label\("ignore_local"\)'

Repository: flanksource/duty

Length of output: 42


Add !ignore_local filter to match repository standards.

The repository standard (per learnings) is to use --label-filter='!ignore_local' when running tests with ginkgo. Update both targets to include this filter, e.g. --label-filter "!e2e && !ignore_local".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 15 - 18, The ginkgo commands in the Makefile (the
default ginkgo target and the test-concurrent target) are missing the
repository-standard label filter for local-ignored tests; update both ginkgo
invocations to use --label-filter "!e2e && !ignore_local" (i.e., add &&
!ignore_local to the existing --label-filter) so the lines that currently call
ginkgo -r -v --skip-package=... --label-filter "!e2e" include the combined
filter.

Comment on lines +144 to +151
if info.TemplateDB == "" {
// Direct connection mode (DUTY_DB_CREATE=false)
PgUrl = info.AdminURL
ctx, _, err := duty.Start("direct", duty.ClientOnly, duty.WithUrl(PgUrl))
if err != nil {
panic(fmt.Sprintf("failed to connect to db: %v", err))
}
return setupNodeContext(ctx, "direct")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Direct mode regresses the old setup contract.

Unlike tests/setup/common.go:SetupDB, the TemplateDB == "" branch on Line 147 goes straight into duty.ClientOnly, so an existing DUTY_DB_URL no longer gets migrations or opts.DummyData. That matches the current BeforeSuite panic on missing migration_logs/properties, and test-concurrent would also make every node share the same database on this path. Keep this branch on the same initialization flow as SetupDB, or explicitly reject parallel execution when no per-node clone can be created.

🧰 Tools
🪛 GitHub Actions: Test

[error] 149-149: PANICKED! BeforeSuite failed: failed to connect to db: ERROR: relation "migration_logs" does not exist (SQLSTATE 42P01); earlier errors include relation "properties" does not exist. This caused the OpenAPI/Duty test suite to abort with a failing BeforeSuite.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/setup/template.go` around lines 144 - 151, The direct-mode branch that
checks info.TemplateDB == "" currently starts duty in duty.ClientOnly via
duty.Start("direct", duty.ClientOnly, ...), which skips migrations and
opts.DummyData and allows all nodes to share one DB; change this branch to
follow the same initialization flow as SetupDB (i.e., invoke duty.Start with the
same mode/opts used in SetupDB so per-node clones, migrations and DummyData are
applied, then call setupNodeContext), or if you intentionally cannot create
per-node clones, make this branch explicitly reject parallel execution (e.g.,
panic or return an error) with a clear message; update the code paths around
TemplateDB, duty.Start, and setupNodeContext to reflect the chosen behavior.

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.

1 participant