From 3af398ef846c31600ad86822e0d7897af1aa4fa3 Mon Sep 17 00:00:00 2001 From: "prath.shenoy" Date: Mon, 16 Nov 2026 22:00:55 +0000 Subject: [PATCH] feat(stovepipe): Define stage configuration --- stovepipe/entity/BUILD.bazel | 10 +++ stovepipe/entity/build_analysis_config.go | 32 +++++++++ .../entity/build_analysis_config_test.go | 39 +++++++++++ stovepipe/entity/build_signal_config.go | 39 +++++++++++ stovepipe/entity/build_signal_config_test.go | 49 ++++++++++++++ stovepipe/entity/issue_track_config.go | 39 +++++++++++ stovepipe/entity/issue_track_config_test.go | 49 ++++++++++++++ stovepipe/entity/process_config.go | 39 +++++++++++ stovepipe/entity/process_config_test.go | 49 ++++++++++++++ stovepipe/entity/stage_config.go | 53 +++++++++++++++ stovepipe/entity/stage_config_test.go | 52 +++++++++++++++ stovepipe/extension/queueconfig/BUILD.bazel | 28 +++++++- .../extension/queueconfig/build_analysis.go | 33 ++++++++++ .../queueconfig/build_analysis_test.go | 48 ++++++++++++++ .../extension/queueconfig/build_signal.go | 40 +++++++++++ .../queueconfig/build_signal_test.go | 66 +++++++++++++++++++ stovepipe/extension/queueconfig/config.go | 43 ++++++++++++ .../extension/queueconfig/config_test.go | 50 ++++++++++++++ .../extension/queueconfig/issue_track.go | 40 +++++++++++ .../extension/queueconfig/issue_track_test.go | 66 +++++++++++++++++++ stovepipe/extension/queueconfig/process.go | 40 +++++++++++ .../extension/queueconfig/process_test.go | 66 +++++++++++++++++++ 22 files changed, 968 insertions(+), 2 deletions(-) create mode 100644 stovepipe/entity/build_analysis_config.go create mode 100644 stovepipe/entity/build_analysis_config_test.go create mode 100644 stovepipe/entity/build_signal_config.go create mode 100644 stovepipe/entity/build_signal_config_test.go create mode 100644 stovepipe/entity/issue_track_config.go create mode 100644 stovepipe/entity/issue_track_config_test.go create mode 100644 stovepipe/entity/process_config.go create mode 100644 stovepipe/entity/process_config_test.go create mode 100644 stovepipe/entity/stage_config.go create mode 100644 stovepipe/entity/stage_config_test.go create mode 100644 stovepipe/extension/queueconfig/build_analysis.go create mode 100644 stovepipe/extension/queueconfig/build_analysis_test.go create mode 100644 stovepipe/extension/queueconfig/build_signal.go create mode 100644 stovepipe/extension/queueconfig/build_signal_test.go create mode 100644 stovepipe/extension/queueconfig/config.go create mode 100644 stovepipe/extension/queueconfig/config_test.go create mode 100644 stovepipe/extension/queueconfig/issue_track.go create mode 100644 stovepipe/extension/queueconfig/issue_track_test.go create mode 100644 stovepipe/extension/queueconfig/process.go create mode 100644 stovepipe/extension/queueconfig/process_test.go diff --git a/stovepipe/entity/BUILD.bazel b/stovepipe/entity/BUILD.bazel index 1dad63104..90c504523 100644 --- a/stovepipe/entity/BUILD.bazel +++ b/stovepipe/entity/BUILD.bazel @@ -4,17 +4,21 @@ go_library( name = "go_default_library", srcs = [ "build.go", + "build_analysis_config.go", "build_issue.go", + "build_signal_config.go", "get_issues_by_request_id.go", "ingest.go", "issue_log.go", "issue_repair.go", "issue_state.go", "issue_summary.go", + "issue_track_config.go", "issue_tracking_state.go", "list.go", "list_open_issues.go", "open_issue.go", + "process_config.go", "project_fact_by_degree.go", "project_issue_attribution.go", "project_issues.go", @@ -32,6 +36,7 @@ go_library( "request_issue_summary.go", "request_log.go", "request_summary.go", + "stage_config.go", "validation_fact.go", ], importpath = "github.com/uber/submitqueue/stovepipe/entity", @@ -42,11 +47,15 @@ go_library( go_test( name = "go_default_test", srcs = [ + "build_analysis_config_test.go", + "build_signal_config_test.go", "build_test.go", "issue_log_test.go", "issue_state_test.go", "issue_summary_test.go", + "issue_track_config_test.go", "issue_tracking_state_test.go", + "process_config_test.go", "project_fact_by_degree_test.go", "project_issue_attribution_test.go", "queue_state_test.go", @@ -54,6 +63,7 @@ go_test( "request_issue_summary_test.go", "request_log_test.go", "request_test.go", + "stage_config_test.go", "validation_fact_test.go", ], embed = [":go_default_library"], diff --git a/stovepipe/entity/build_analysis_config.go b/stovepipe/entity/build_analysis_config.go new file mode 100644 index 000000000..ccc2ed054 --- /dev/null +++ b/stovepipe/entity/build_analysis_config.go @@ -0,0 +1,32 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import "fmt" + +// BuildAnalysisConfig contains configuration for the build-analysis stage. +type BuildAnalysisConfig struct { + // PollDelayMs is the positive interval between successful analysis passes, in milliseconds. + PollDelayMs int64 `json:"poll_delay_ms" yaml:"poll_delay_ms"` +} + +// Validate checks the build-analysis stage's configuration constraints. +func (c BuildAnalysisConfig) Validate() error { + if c.PollDelayMs <= 0 { + return fmt.Errorf("PollDelayMs must be positive, got %d", c.PollDelayMs) + } + + return nil +} diff --git a/stovepipe/entity/build_analysis_config_test.go b/stovepipe/entity/build_analysis_config_test.go new file mode 100644 index 000000000..6c2fdad9b --- /dev/null +++ b/stovepipe/entity/build_analysis_config_test.go @@ -0,0 +1,39 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestBuildAnalysisConfigValidate(t *testing.T) { + valid := BuildAnalysisConfig{ + PollDelayMs: 10, + } + + require.NoError(t, valid.Validate()) + + t.Run("PollDelayMs", func(t *testing.T) { + for _, value := range []int64{0, -1} { + cfg := valid + cfg.PollDelayMs = value + + require.Error(t, cfg.Validate()) + } + }) + +} diff --git a/stovepipe/entity/build_signal_config.go b/stovepipe/entity/build_signal_config.go new file mode 100644 index 000000000..dd632d962 --- /dev/null +++ b/stovepipe/entity/build_signal_config.go @@ -0,0 +1,39 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import "fmt" + +// BuildSignalConfig contains configuration for the build-signal stage. +type BuildSignalConfig struct { + // AcceptedPollDelayMs is the positive polling interval for accepted builds, in milliseconds. + AcceptedPollDelayMs int64 `json:"accepted_poll_delay_ms" yaml:"accepted_poll_delay_ms"` + + // RunningPollDelayMs is the positive polling interval for running builds, in milliseconds. + RunningPollDelayMs int64 `json:"running_poll_delay_ms" yaml:"running_poll_delay_ms"` +} + +// Validate checks the build-signal stage's configuration constraints. +func (c BuildSignalConfig) Validate() error { + if c.AcceptedPollDelayMs <= 0 { + return fmt.Errorf("AcceptedPollDelayMs must be positive, got %d", c.AcceptedPollDelayMs) + } + + if c.RunningPollDelayMs <= 0 { + return fmt.Errorf("RunningPollDelayMs must be positive, got %d", c.RunningPollDelayMs) + } + + return nil +} diff --git a/stovepipe/entity/build_signal_config_test.go b/stovepipe/entity/build_signal_config_test.go new file mode 100644 index 000000000..8b4df54cc --- /dev/null +++ b/stovepipe/entity/build_signal_config_test.go @@ -0,0 +1,49 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestBuildSignalConfigValidate(t *testing.T) { + valid := BuildSignalConfig{ + AcceptedPollDelayMs: 10, + RunningPollDelayMs: 11, + } + + require.NoError(t, valid.Validate()) + + t.Run("AcceptedPollDelayMs", func(t *testing.T) { + for _, value := range []int64{0, -1} { + cfg := valid + cfg.AcceptedPollDelayMs = value + + require.Error(t, cfg.Validate()) + } + }) + + t.Run("RunningPollDelayMs", func(t *testing.T) { + for _, value := range []int64{0, -1} { + cfg := valid + cfg.RunningPollDelayMs = value + + require.Error(t, cfg.Validate()) + } + }) + +} diff --git a/stovepipe/entity/issue_track_config.go b/stovepipe/entity/issue_track_config.go new file mode 100644 index 000000000..a78b37faa --- /dev/null +++ b/stovepipe/entity/issue_track_config.go @@ -0,0 +1,39 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import "fmt" + +// IssueTrackConfig contains configuration for the issue-tracking stage. +type IssueTrackConfig struct { + // RefreshDelayMs is the positive interval between refreshes, in milliseconds. + RefreshDelayMs int64 `json:"refresh_delay_ms" yaml:"refresh_delay_ms"` + + // RecoveryWaitDelayMs is the positive wait during recovery, in milliseconds. + RecoveryWaitDelayMs int64 `json:"recovery_wait_delay_ms" yaml:"recovery_wait_delay_ms"` +} + +// Validate checks the issue-tracking stage's configuration constraints. +func (c IssueTrackConfig) Validate() error { + if c.RefreshDelayMs <= 0 { + return fmt.Errorf("RefreshDelayMs must be positive, got %d", c.RefreshDelayMs) + } + + if c.RecoveryWaitDelayMs <= 0 { + return fmt.Errorf("RecoveryWaitDelayMs must be positive, got %d", c.RecoveryWaitDelayMs) + } + + return nil +} diff --git a/stovepipe/entity/issue_track_config_test.go b/stovepipe/entity/issue_track_config_test.go new file mode 100644 index 000000000..063bf7fe1 --- /dev/null +++ b/stovepipe/entity/issue_track_config_test.go @@ -0,0 +1,49 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestIssueTrackConfigValidate(t *testing.T) { + valid := IssueTrackConfig{ + RefreshDelayMs: 10, + RecoveryWaitDelayMs: 11, + } + + require.NoError(t, valid.Validate()) + + t.Run("RefreshDelayMs", func(t *testing.T) { + for _, value := range []int64{0, -1} { + cfg := valid + cfg.RefreshDelayMs = value + + require.Error(t, cfg.Validate()) + } + }) + + t.Run("RecoveryWaitDelayMs", func(t *testing.T) { + for _, value := range []int64{0, -1} { + cfg := valid + cfg.RecoveryWaitDelayMs = value + + require.Error(t, cfg.Validate()) + } + }) + +} diff --git a/stovepipe/entity/process_config.go b/stovepipe/entity/process_config.go new file mode 100644 index 000000000..f45783312 --- /dev/null +++ b/stovepipe/entity/process_config.go @@ -0,0 +1,39 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import "fmt" + +// ProcessConfig contains configuration for the process stage. +type ProcessConfig struct { + // MaxConcurrent is the positive concurrent validation limit. + MaxConcurrent int32 `json:"max_concurrent" yaml:"max_concurrent"` + + // GateWaitDelayMs is the positive wait for admission, in milliseconds. + GateWaitDelayMs int64 `json:"gate_wait_delay_ms" yaml:"gate_wait_delay_ms"` +} + +// Validate checks the process stage's configuration constraints. +func (c ProcessConfig) Validate() error { + if c.MaxConcurrent <= 0 { + return fmt.Errorf("MaxConcurrent must be positive, got %d", c.MaxConcurrent) + } + + if c.GateWaitDelayMs <= 0 { + return fmt.Errorf("GateWaitDelayMs must be positive, got %d", c.GateWaitDelayMs) + } + + return nil +} diff --git a/stovepipe/entity/process_config_test.go b/stovepipe/entity/process_config_test.go new file mode 100644 index 000000000..06899c41d --- /dev/null +++ b/stovepipe/entity/process_config_test.go @@ -0,0 +1,49 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestProcessConfigValidate(t *testing.T) { + valid := ProcessConfig{ + MaxConcurrent: 10, + GateWaitDelayMs: 11, + } + + require.NoError(t, valid.Validate()) + + t.Run("MaxConcurrent", func(t *testing.T) { + for _, value := range []int32{0, -1} { + cfg := valid + cfg.MaxConcurrent = value + + require.Error(t, cfg.Validate()) + } + }) + + t.Run("GateWaitDelayMs", func(t *testing.T) { + for _, value := range []int64{0, -1} { + cfg := valid + cfg.GateWaitDelayMs = value + + require.Error(t, cfg.Validate()) + } + }) + +} diff --git a/stovepipe/entity/stage_config.go b/stovepipe/entity/stage_config.go new file mode 100644 index 000000000..0e8cfa4f6 --- /dev/null +++ b/stovepipe/entity/stage_config.go @@ -0,0 +1,53 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import "fmt" + +// StageConfig contains configuration for the validation pipeline stages. +type StageConfig struct { + // Process contains configuration for the process stage. + Process ProcessConfig `json:"process" yaml:"process"` + + // BuildSignal contains configuration for the build-signal stage. + BuildSignal BuildSignalConfig `json:"build_signal" yaml:"build_signal"` + + // BuildAnalysis contains configuration for the build-analysis stage. + BuildAnalysis BuildAnalysisConfig `json:"build_analysis" yaml:"build_analysis"` + + // IssueTrack contains configuration for the issue-tracking stage. + IssueTrack IssueTrackConfig `json:"issue_track" yaml:"issue_track"` +} + +// Validate checks each stage after all configuration layers have been applied. +func (c StageConfig) Validate() error { + if err := c.Process.Validate(); err != nil { + return fmt.Errorf("process: %w", err) + } + + if err := c.BuildSignal.Validate(); err != nil { + return fmt.Errorf("buildSignal: %w", err) + } + + if err := c.BuildAnalysis.Validate(); err != nil { + return fmt.Errorf("buildAnalysis: %w", err) + } + + if err := c.IssueTrack.Validate(); err != nil { + return fmt.Errorf("issueTrack: %w", err) + } + + return nil +} diff --git a/stovepipe/entity/stage_config_test.go b/stovepipe/entity/stage_config_test.go new file mode 100644 index 000000000..0125e27c1 --- /dev/null +++ b/stovepipe/entity/stage_config_test.go @@ -0,0 +1,52 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entity + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func testStageConfig() StageConfig { + return StageConfig{ + Process: ProcessConfig{MaxConcurrent: 2, GateWaitDelayMs: 11}, + BuildSignal: BuildSignalConfig{AcceptedPollDelayMs: 12, RunningPollDelayMs: 13}, + BuildAnalysis: BuildAnalysisConfig{PollDelayMs: 14}, + IssueTrack: IssueTrackConfig{RefreshDelayMs: 15, RecoveryWaitDelayMs: 16}, + } +} + +func TestStageConfigValidatesEveryStage(t *testing.T) { + valid := testStageConfig() + require.NoError(t, valid.Validate()) + + for _, tt := range []struct { + name string + invalidate func(*StageConfig) + }{ + {"process", func(c *StageConfig) { c.Process = ProcessConfig{} }}, + {"build signal", func(c *StageConfig) { c.BuildSignal = BuildSignalConfig{} }}, + {"build analysis", func(c *StageConfig) { c.BuildAnalysis = BuildAnalysisConfig{} }}, + {"issue tracking", func(c *StageConfig) { c.IssueTrack = IssueTrackConfig{} }}, + } { + t.Run(tt.name, func(t *testing.T) { + cfg := valid + tt.invalidate(&cfg) + + require.Error(t, cfg.Validate()) + }) + } +} diff --git a/stovepipe/extension/queueconfig/BUILD.bazel b/stovepipe/extension/queueconfig/BUILD.bazel index a654ec803..9a1b85f67 100644 --- a/stovepipe/extension/queueconfig/BUILD.bazel +++ b/stovepipe/extension/queueconfig/BUILD.bazel @@ -1,9 +1,33 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["queueconfig.go"], + srcs = [ + "build_analysis.go", + "build_signal.go", + "config.go", + "issue_track.go", + "process.go", + "queueconfig.go", + ], importpath = "github.com/uber/submitqueue/stovepipe/extension/queueconfig", visibility = ["//visibility:public"], deps = ["//stovepipe/entity:go_default_library"], ) + +go_test( + name = "go_default_test", + srcs = [ + "build_analysis_test.go", + "build_signal_test.go", + "config_test.go", + "issue_track_test.go", + "process_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//stovepipe/entity:go_default_library", + "@com_github_stretchr_testify//assert:go_default_library", + "@com_github_stretchr_testify//require:go_default_library", + ], +) diff --git a/stovepipe/extension/queueconfig/build_analysis.go b/stovepipe/extension/queueconfig/build_analysis.go new file mode 100644 index 000000000..7adb62c0c --- /dev/null +++ b/stovepipe/extension/queueconfig/build_analysis.go @@ -0,0 +1,33 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import "github.com/uber/submitqueue/stovepipe/entity" + +// BuildAnalysisOverrides contains optional configuration for the build-analysis stage. +// Nil fields inherit their previous value; explicit values are retained for validation. +type BuildAnalysisOverrides struct { + // PollDelayMs overrides the interval between successful analysis passes, in milliseconds. + PollDelayMs *int64 +} + +// Apply returns a copy of base with explicitly supplied settings replaced. +func (o BuildAnalysisOverrides) Apply(base entity.BuildAnalysisConfig) entity.BuildAnalysisConfig { + if o.PollDelayMs != nil { + base.PollDelayMs = *o.PollDelayMs + } + + return base +} diff --git a/stovepipe/extension/queueconfig/build_analysis_test.go b/stovepipe/extension/queueconfig/build_analysis_test.go new file mode 100644 index 000000000..399eb2549 --- /dev/null +++ b/stovepipe/extension/queueconfig/build_analysis_test.go @@ -0,0 +1,48 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/uber/submitqueue/stovepipe/entity" +) + +func TestBuildAnalysisOverridesApply(t *testing.T) { + base := entity.BuildAnalysisConfig{ + PollDelayMs: 10, + } + + assert.Equal(t, base, (BuildAnalysisOverrides{}).Apply(base)) + + t.Run("PollDelayMs", func(t *testing.T) { + value := int64(25) + original := base + override := BuildAnalysisOverrides{PollDelayMs: &value} + + got := override.Apply(base) + want := base + want.PollDelayMs = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int64(25), got.PollDelayMs) + assert.Zero(t, override.Apply(base).PollDelayMs) + }) + +} diff --git a/stovepipe/extension/queueconfig/build_signal.go b/stovepipe/extension/queueconfig/build_signal.go new file mode 100644 index 000000000..d390cd280 --- /dev/null +++ b/stovepipe/extension/queueconfig/build_signal.go @@ -0,0 +1,40 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import "github.com/uber/submitqueue/stovepipe/entity" + +// BuildSignalOverrides contains optional configuration for the build-signal stage. +// Nil fields inherit their previous value; explicit values are retained for validation. +type BuildSignalOverrides struct { + // AcceptedPollDelayMs overrides the polling interval for accepted builds, in milliseconds. + AcceptedPollDelayMs *int64 + + // RunningPollDelayMs overrides the polling interval for running builds, in milliseconds. + RunningPollDelayMs *int64 +} + +// Apply returns a copy of base with explicitly supplied settings replaced. +func (o BuildSignalOverrides) Apply(base entity.BuildSignalConfig) entity.BuildSignalConfig { + if o.AcceptedPollDelayMs != nil { + base.AcceptedPollDelayMs = *o.AcceptedPollDelayMs + } + + if o.RunningPollDelayMs != nil { + base.RunningPollDelayMs = *o.RunningPollDelayMs + } + + return base +} diff --git a/stovepipe/extension/queueconfig/build_signal_test.go b/stovepipe/extension/queueconfig/build_signal_test.go new file mode 100644 index 000000000..0b8ab85f6 --- /dev/null +++ b/stovepipe/extension/queueconfig/build_signal_test.go @@ -0,0 +1,66 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/uber/submitqueue/stovepipe/entity" +) + +func TestBuildSignalOverridesApply(t *testing.T) { + base := entity.BuildSignalConfig{ + AcceptedPollDelayMs: 10, + RunningPollDelayMs: 11, + } + + assert.Equal(t, base, (BuildSignalOverrides{}).Apply(base)) + + t.Run("AcceptedPollDelayMs", func(t *testing.T) { + value := int64(25) + original := base + override := BuildSignalOverrides{AcceptedPollDelayMs: &value} + + got := override.Apply(base) + want := base + want.AcceptedPollDelayMs = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int64(25), got.AcceptedPollDelayMs) + assert.Zero(t, override.Apply(base).AcceptedPollDelayMs) + }) + + t.Run("RunningPollDelayMs", func(t *testing.T) { + value := int64(25) + original := base + override := BuildSignalOverrides{RunningPollDelayMs: &value} + + got := override.Apply(base) + want := base + want.RunningPollDelayMs = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int64(25), got.RunningPollDelayMs) + assert.Zero(t, override.Apply(base).RunningPollDelayMs) + }) + +} diff --git a/stovepipe/extension/queueconfig/config.go b/stovepipe/extension/queueconfig/config.go new file mode 100644 index 000000000..66d40e6d3 --- /dev/null +++ b/stovepipe/extension/queueconfig/config.go @@ -0,0 +1,43 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import "github.com/uber/submitqueue/stovepipe/entity" + +// Overrides contains optional configuration grouped by stage. +// Apply does not validate partial layers; validate the resolved result instead. +type Overrides struct { + // Process contains optional configuration for the process stage. + Process ProcessOverrides + + // BuildSignal contains optional configuration for the build-signal stage. + BuildSignal BuildSignalOverrides + + // BuildAnalysis contains optional configuration for the build-analysis stage. + BuildAnalysis BuildAnalysisOverrides + + // IssueTrack contains optional configuration for the issue-tracking stage. + IssueTrack IssueTrackOverrides +} + +// Apply returns a copy of base with each stage's overrides applied. +func (o Overrides) Apply(base entity.StageConfig) entity.StageConfig { + return entity.StageConfig{ + Process: o.Process.Apply(base.Process), + BuildSignal: o.BuildSignal.Apply(base.BuildSignal), + BuildAnalysis: o.BuildAnalysis.Apply(base.BuildAnalysis), + IssueTrack: o.IssueTrack.Apply(base.IssueTrack), + } +} diff --git a/stovepipe/extension/queueconfig/config_test.go b/stovepipe/extension/queueconfig/config_test.go new file mode 100644 index 000000000..5a6a59760 --- /dev/null +++ b/stovepipe/extension/queueconfig/config_test.go @@ -0,0 +1,50 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/uber/submitqueue/stovepipe/entity" +) + +func TestOverridesComposeAllStages(t *testing.T) { + concurrency := int32(2) + admission, accepted, running := int64(11), int64(12), int64(13) + analysis, refresh, recovery := int64(14), int64(15), int64(16) + overrides := Overrides{ + Process: ProcessOverrides{MaxConcurrent: &concurrency, GateWaitDelayMs: &admission}, + BuildSignal: BuildSignalOverrides{AcceptedPollDelayMs: &accepted, RunningPollDelayMs: &running}, + BuildAnalysis: BuildAnalysisOverrides{PollDelayMs: &analysis}, + IssueTrack: IssueTrackOverrides{RefreshDelayMs: &refresh, RecoveryWaitDelayMs: &recovery}, + } + var base entity.StageConfig + + got := overrides.Apply(base) + require.NoError(t, got.Validate()) + assert.Equal(t, entity.StageConfig{}, base) + assert.Equal(t, concurrency, got.Process.MaxConcurrent) + assert.Equal(t, admission, got.Process.GateWaitDelayMs) + assert.Equal(t, accepted, got.BuildSignal.AcceptedPollDelayMs) + assert.Equal(t, running, got.BuildSignal.RunningPollDelayMs) + assert.Equal(t, analysis, got.BuildAnalysis.PollDelayMs) + assert.Equal(t, refresh, got.IssueTrack.RefreshDelayMs) + assert.Equal(t, recovery, got.IssueTrack.RecoveryWaitDelayMs) + + inherited := (Overrides{}).Apply(got) + assert.Equal(t, got, inherited) +} diff --git a/stovepipe/extension/queueconfig/issue_track.go b/stovepipe/extension/queueconfig/issue_track.go new file mode 100644 index 000000000..1f0ab9e5e --- /dev/null +++ b/stovepipe/extension/queueconfig/issue_track.go @@ -0,0 +1,40 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import "github.com/uber/submitqueue/stovepipe/entity" + +// IssueTrackOverrides contains optional configuration for the issue-tracking stage. +// Nil fields inherit their previous value; explicit values are retained for validation. +type IssueTrackOverrides struct { + // RefreshDelayMs overrides the interval between refreshes, in milliseconds. + RefreshDelayMs *int64 + + // RecoveryWaitDelayMs overrides the wait during recovery, in milliseconds. + RecoveryWaitDelayMs *int64 +} + +// Apply returns a copy of base with explicitly supplied settings replaced. +func (o IssueTrackOverrides) Apply(base entity.IssueTrackConfig) entity.IssueTrackConfig { + if o.RefreshDelayMs != nil { + base.RefreshDelayMs = *o.RefreshDelayMs + } + + if o.RecoveryWaitDelayMs != nil { + base.RecoveryWaitDelayMs = *o.RecoveryWaitDelayMs + } + + return base +} diff --git a/stovepipe/extension/queueconfig/issue_track_test.go b/stovepipe/extension/queueconfig/issue_track_test.go new file mode 100644 index 000000000..b142f9ecc --- /dev/null +++ b/stovepipe/extension/queueconfig/issue_track_test.go @@ -0,0 +1,66 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/uber/submitqueue/stovepipe/entity" +) + +func TestIssueTrackOverridesApply(t *testing.T) { + base := entity.IssueTrackConfig{ + RefreshDelayMs: 10, + RecoveryWaitDelayMs: 11, + } + + assert.Equal(t, base, (IssueTrackOverrides{}).Apply(base)) + + t.Run("RefreshDelayMs", func(t *testing.T) { + value := int64(25) + original := base + override := IssueTrackOverrides{RefreshDelayMs: &value} + + got := override.Apply(base) + want := base + want.RefreshDelayMs = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int64(25), got.RefreshDelayMs) + assert.Zero(t, override.Apply(base).RefreshDelayMs) + }) + + t.Run("RecoveryWaitDelayMs", func(t *testing.T) { + value := int64(25) + original := base + override := IssueTrackOverrides{RecoveryWaitDelayMs: &value} + + got := override.Apply(base) + want := base + want.RecoveryWaitDelayMs = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int64(25), got.RecoveryWaitDelayMs) + assert.Zero(t, override.Apply(base).RecoveryWaitDelayMs) + }) + +} diff --git a/stovepipe/extension/queueconfig/process.go b/stovepipe/extension/queueconfig/process.go new file mode 100644 index 000000000..195de1d47 --- /dev/null +++ b/stovepipe/extension/queueconfig/process.go @@ -0,0 +1,40 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import "github.com/uber/submitqueue/stovepipe/entity" + +// ProcessOverrides contains optional configuration for the process stage. +// Nil fields inherit their previous value; explicit values are retained for validation. +type ProcessOverrides struct { + // MaxConcurrent overrides the concurrent validation limit. + MaxConcurrent *int32 + + // GateWaitDelayMs overrides the wait for admission, in milliseconds. + GateWaitDelayMs *int64 +} + +// Apply returns a copy of base with explicitly supplied settings replaced. +func (o ProcessOverrides) Apply(base entity.ProcessConfig) entity.ProcessConfig { + if o.MaxConcurrent != nil { + base.MaxConcurrent = *o.MaxConcurrent + } + + if o.GateWaitDelayMs != nil { + base.GateWaitDelayMs = *o.GateWaitDelayMs + } + + return base +} diff --git a/stovepipe/extension/queueconfig/process_test.go b/stovepipe/extension/queueconfig/process_test.go new file mode 100644 index 000000000..fc8fab2c7 --- /dev/null +++ b/stovepipe/extension/queueconfig/process_test.go @@ -0,0 +1,66 @@ +// Copyright (c) 2026 Uber Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package queueconfig + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/uber/submitqueue/stovepipe/entity" +) + +func TestProcessOverridesApply(t *testing.T) { + base := entity.ProcessConfig{ + MaxConcurrent: 10, + GateWaitDelayMs: 11, + } + + assert.Equal(t, base, (ProcessOverrides{}).Apply(base)) + + t.Run("MaxConcurrent", func(t *testing.T) { + value := int32(25) + original := base + override := ProcessOverrides{MaxConcurrent: &value} + + got := override.Apply(base) + want := base + want.MaxConcurrent = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int32(25), got.MaxConcurrent) + assert.Zero(t, override.Apply(base).MaxConcurrent) + }) + + t.Run("GateWaitDelayMs", func(t *testing.T) { + value := int64(25) + original := base + override := ProcessOverrides{GateWaitDelayMs: &value} + + got := override.Apply(base) + want := base + want.GateWaitDelayMs = value + + assert.Equal(t, want, got) + assert.Equal(t, original, base) + + value = 0 + assert.Equal(t, int64(25), got.GateWaitDelayMs) + assert.Zero(t, override.Apply(base).GateWaitDelayMs) + }) + +}