mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-31 02:51:51 -07:00
## What changed? Add a top-level Visibility config in the server config file. Option to overwrite the default number of preallocated custom search attributes in the server config (`visibility.persistenceCustomSearchAttributes`). Register the preallocated custom search attributes when using custom Visibility store. The config can be changed at any point: increasing the number of custom search attributes will register additional custom search attributes in the cluster metadata; decreasing the number of custom search attributes is no-op. Replace struct validator library with `github.com/go-playground/validator`. ## Why? Be able to add more custom search attributes when using SQL Visibility store. ## How did you test it? - [x] built - [x] run locally and tested manually - [x] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s) ## Potential risks
79 lines
1.3 KiB
Go
79 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestValidateVisibilityConfig(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
in Visibility
|
|
err bool
|
|
}{
|
|
{
|
|
name: "success",
|
|
in: Visibility{
|
|
PersistenceCustomSearchAttributes: map[string]int{
|
|
"Bool": 5,
|
|
"Keyword": 2,
|
|
},
|
|
},
|
|
err: false,
|
|
},
|
|
{
|
|
name: "invalid search attribute type",
|
|
in: Visibility{
|
|
PersistenceCustomSearchAttributes: map[string]int{
|
|
"Bool": 5,
|
|
"Foo": 2,
|
|
},
|
|
},
|
|
err: true,
|
|
},
|
|
{
|
|
name: "invalid unspecified",
|
|
in: Visibility{
|
|
PersistenceCustomSearchAttributes: map[string]int{
|
|
"Bool": 5,
|
|
"Unspecified": 2,
|
|
},
|
|
},
|
|
err: true,
|
|
},
|
|
{
|
|
name: "invalid negative number",
|
|
in: Visibility{
|
|
PersistenceCustomSearchAttributes: map[string]int{
|
|
"Bool": 5,
|
|
"Keyword": -2,
|
|
},
|
|
},
|
|
err: true,
|
|
},
|
|
{
|
|
name: "invalid large number",
|
|
in: Visibility{
|
|
PersistenceCustomSearchAttributes: map[string]int{
|
|
"Bool": 5,
|
|
"Keyword": 100,
|
|
},
|
|
},
|
|
err: true,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
validate := newValidator()
|
|
err := validate.Validate(tc.in)
|
|
if tc.err {
|
|
require.Error(t, err)
|
|
} else {
|
|
require.NoError(t, err)
|
|
}
|
|
})
|
|
}
|
|
}
|