mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 22:09:08 +01:00
[test] Add e2e coverage for remote-jobs opt-in and bundle params
Adds an e2e suite (e2e/remotejobs) that runs on the container harness and exercises the two stacked PRs end-to-end against a live management server and a real client: - Remote-jobs opt-in (#7153): a peer that ran plain `netbird up` reports remote_jobs_allowed=false via the peers API, and the client refuses a streamed job ("remote jobs are not enabled on this peer"). After `netbird up --allow-remote-jobs`, the flag flips to true on the API and the same job is accepted for execution. - Bundle job parameters (#7147): an unknown anonymize_level is rejected at job creation, and a messy-but-valid value (' Strict ') is normalized to 'strict' in the stored job the API returns. Adds a small harness helper, Client.Up(extraArgs...), to re-run `netbird up` with flags so the opt-in can be toggled mid-test without recreating the container.
This commit is contained in:
@@ -120,6 +120,26 @@ func (cl *Client) Restart(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Up re-runs `netbird up` inside the client with the given extra flags (e.g.
|
||||
// "--allow-remote-jobs"), bouncing the connection first so the new config is
|
||||
// picked up and re-synced to management. Used to toggle peer options that ride
|
||||
// on the login/sync request without recreating the container.
|
||||
func (cl *Client) Up(ctx context.Context, extraArgs ...string) error {
|
||||
if _, _, err := cl.container.Exec(ctx, []string{"netbird", "down"}, tcexec.Multiplexed()); err != nil {
|
||||
return fmt.Errorf("netbird down: %w", err)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
code, reader, err := cl.container.Exec(ctx, append([]string{"netbird", "up"}, extraArgs...), tcexec.Multiplexed())
|
||||
if err != nil {
|
||||
return fmt.Errorf("netbird up: %w", err)
|
||||
}
|
||||
if code != 0 {
|
||||
out, _ := io.ReadAll(reader)
|
||||
return fmt.Errorf("netbird up %v exited %d: %s", extraArgs, code, string(out))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status returns `netbird status` output from inside the client.
|
||||
func (cl *Client) Status(ctx context.Context) (string, error) {
|
||||
code, reader, err := cl.container.Exec(ctx, []string{"netbird", "status"}, tcexec.Multiplexed())
|
||||
|
||||
Reference in New Issue
Block a user