mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
What changed?
Added support for enabling experimental features via gRPC headers and
namespace configuration:
1. New experimental feature infrastructure:
- Added temporal-experimental gRPC header support
- supports comma-separated values, wildcards (*), and case-insensitive
matching
- Added FrontendEnabledExperiments dynamic config setting to allow
per-namespace control of which experiments can be enabled
2. CHASM scheduler experiment:
- Defined ChasmSchedulerExperiment = "chasm-sch" constant
4. Test improvements:
- Refactored common/headers/headers_test.go to remove testify suite
pattern and use standard table-driven tests with t.Parallel()
Why?
We need a safe, controlled way to roll out experimental features like
the CHASM scheduler (v2). This infrastructure provides:
- Dual gating mechanism: Experiments require both client opt-in (via
header) AND server-side namespace configuration, preventing accidental
enablement
- Flexibility: Supports multiple experiments, wildcard enablement for
testing, and per-namespace control
How did you test it?
- built
- added new unit tests
---------
Co-authored-by: alex stanfield <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
86 lines
1.9 KiB
Go
86 lines
1.9 KiB
Go
package frontend
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestConfig_IsExperimentAllowed(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
namespace string
|
|
experiment string
|
|
setupFunc func(namespace string) []string
|
|
expected bool
|
|
}{
|
|
{
|
|
name: "no experiments allowed",
|
|
namespace: "test-namespace",
|
|
experiment: "chasm-scheduler",
|
|
setupFunc: func(ns string) []string { return []string{} },
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "specific experiment match",
|
|
namespace: "test-namespace",
|
|
experiment: "chasm-scheduler",
|
|
setupFunc: func(ns string) []string { return []string{"chasm-scheduler"} },
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "specific experiment no match",
|
|
namespace: "test-namespace",
|
|
experiment: "other-experiment",
|
|
setupFunc: func(ns string) []string { return []string{"chasm-scheduler"} },
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "wildcard allows any",
|
|
namespace: "test-namespace",
|
|
experiment: "any-experiment",
|
|
setupFunc: func(ns string) []string { return []string{"*"} },
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "namespace specific wildcard",
|
|
namespace: "ns-with-wildcard",
|
|
experiment: "any-experiment",
|
|
setupFunc: func(ns string) []string {
|
|
if ns == "ns-with-wildcard" {
|
|
return []string{"*"}
|
|
}
|
|
return nil
|
|
},
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "namespace specific match",
|
|
namespace: "ns-with-specific",
|
|
experiment: "chasm-scheduler",
|
|
setupFunc: func(ns string) []string {
|
|
if ns == "ns-with-specific" {
|
|
return []string{"chasm-scheduler"}
|
|
}
|
|
return nil
|
|
},
|
|
expected: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
config := &Config{
|
|
AllowedExperiments: tt.setupFunc,
|
|
}
|
|
|
|
result := config.IsExperimentAllowed(tt.experiment, tt.namespace)
|
|
require.Equal(t, tt.expected, result)
|
|
})
|
|
}
|
|
}
|