Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/server/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions docs/server/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions docs/server/swagger.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions pkg/runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ type ScalingConfig struct {
// When nil, replicas are unmanaged (preserving HPA or manual kubectl control).
// When set (including 0), the value is an explicit replica count.
BackendReplicas *int32 `json:"backend_replicas,omitempty" yaml:"backend_replicas,omitempty"`

// SessionCacheSize is the maximum number of sessions held in the local LRU cache.
// When nil, consuming code applies a sensible default (e.g. 1000).
SessionCacheSize *int32 `json:"session_cache_size,omitempty" yaml:"session_cache_size,omitempty"`
}

// WriteJSON serializes the RunConfig to JSON and writes it to the provided writer
Expand Down
35 changes: 5 additions & 30 deletions pkg/runner/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2242,19 +2242,18 @@ func TestRunConfig_WriteJSON_ReadJSON_EmbeddedAuthServer(t *testing.T) {
})
}

func TestRunConfig_BackendReplicasAndSessionCacheSize(t *testing.T) {
func TestRunConfig_BackendReplicas(t *testing.T) {
t.Parallel()

const testServerName = "srv"
int32ptr := func(v int32) *int32 { return &v }

t.Run("round-trip with both fields set", func(t *testing.T) {
t.Run("round-trip with backend_replicas set", func(t *testing.T) {
t.Parallel()
original := NewRunConfig()
original.Name = "test-server"
original.ScalingConfig = &ScalingConfig{
BackendReplicas: int32ptr(3),
SessionCacheSize: int32ptr(500),
BackendReplicas: int32ptr(3),
}

var buf bytes.Buffer
Expand All @@ -2265,8 +2264,6 @@ func TestRunConfig_BackendReplicasAndSessionCacheSize(t *testing.T) {
require.NotNil(t, got.ScalingConfig)
require.NotNil(t, got.ScalingConfig.BackendReplicas)
assert.Equal(t, int32(3), *got.ScalingConfig.BackendReplicas)
require.NotNil(t, got.ScalingConfig.SessionCacheSize)
assert.Equal(t, int32(500), *got.ScalingConfig.SessionCacheSize)
})

t.Run("round-trip without scaling config preserves nil", func(t *testing.T) {
Expand All @@ -2289,7 +2286,6 @@ func TestRunConfig_BackendReplicasAndSessionCacheSize(t *testing.T) {
require.NoError(t, cfg.WriteJSON(&buf))
assert.NotContains(t, buf.String(), "scaling_config")
assert.NotContains(t, buf.String(), "backend_replicas")
assert.NotContains(t, buf.String(), "session_cache_size")
})

t.Run("explicit backend_replicas 2 in JSON deserializes to pointer with value 2", func(t *testing.T) {
Expand All @@ -2304,7 +2300,6 @@ func TestRunConfig_BackendReplicasAndSessionCacheSize(t *testing.T) {
require.NotNil(t, got.ScalingConfig)
require.NotNil(t, got.ScalingConfig.BackendReplicas, "BackendReplicas should be non-nil when present in JSON")
assert.Equal(t, int32(2), *got.ScalingConfig.BackendReplicas)
assert.Nil(t, got.ScalingConfig.SessionCacheSize, "SessionCacheSize should be nil when omitted from JSON")
})

t.Run("backend_replicas 0 in JSON deserializes to pointer-to-zero, not nil", func(t *testing.T) {
Expand All @@ -2323,30 +2318,12 @@ func TestRunConfig_BackendReplicasAndSessionCacheSize(t *testing.T) {
assert.Equal(t, int32(0), *got.ScalingConfig.BackendReplicas)
})

t.Run("session_cache_size 0 in JSON deserializes to pointer-to-zero, not nil", func(t *testing.T) {
t.Parallel()
// omitempty only omits when the pointer is nil; pointer-to-zero is a meaningful
// "set to 0" and must survive a round-trip.
cfg := NewRunConfig()
cfg.Name = testServerName
cfg.ScalingConfig = &ScalingConfig{SessionCacheSize: int32ptr(0)}
var buf bytes.Buffer
require.NoError(t, cfg.WriteJSON(&buf))
got, err := ReadJSON(&buf)
require.NoError(t, err)
require.NotNil(t, got.ScalingConfig)
require.NotNil(t, got.ScalingConfig.SessionCacheSize, "SessionCacheSize should be non-nil when explicitly set to 0 in JSON")
assert.Equal(t, int32(0), *got.ScalingConfig.SessionCacheSize)
assert.Nil(t, got.ScalingConfig.BackendReplicas, "BackendReplicas should be nil when omitted from JSON")
})

t.Run("YAML round-trip with both fields set", func(t *testing.T) {
t.Run("YAML round-trip with backend_replicas set", func(t *testing.T) {
t.Parallel()
original := NewRunConfig()
original.Name = "yaml-server"
original.ScalingConfig = &ScalingConfig{
BackendReplicas: int32ptr(5),
SessionCacheSize: int32ptr(250),
BackendReplicas: int32ptr(5),
}

data, err := yaml.Marshal(original)
Expand All @@ -2357,7 +2334,5 @@ func TestRunConfig_BackendReplicasAndSessionCacheSize(t *testing.T) {
require.NotNil(t, got.ScalingConfig)
require.NotNil(t, got.ScalingConfig.BackendReplicas)
assert.Equal(t, int32(5), *got.ScalingConfig.BackendReplicas)
require.NotNil(t, got.ScalingConfig.SessionCacheSize)
assert.Equal(t, int32(250), *got.ScalingConfig.SessionCacheSize)
})
}
Loading