mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-09 19:16:59 +02:00
Improve the exposed service reliability by using a TCP loadbalancer between the nodes exposing the service. Rework the exposed service proxy registry to be a COSI controller instead to simplify the logic, improve reliability and testability. Closes siderolabs/omni#396. Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
// Copyright (c) 2024 Sidero Labs, Inc.
|
|
//
|
|
// Use of this software is governed by the Business Source License
|
|
// included in the LICENSE file.
|
|
|
|
package workloadproxy_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap/zapcore"
|
|
"go.uber.org/zap/zaptest"
|
|
|
|
"github.com/siderolabs/omni/internal/backend/workloadproxy"
|
|
)
|
|
|
|
func TestReconciler(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
reconciler := workloadproxy.NewReconciler(zaptest.NewLogger(t), zapcore.InfoLevel)
|
|
|
|
err := reconciler.Reconcile("cluster1", map[string][]string{
|
|
"alias1": {
|
|
"upstream1",
|
|
"upstream2",
|
|
},
|
|
"alias2": {
|
|
"upstream3",
|
|
"upstream4",
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
proxy, id, err := reconciler.GetProxy("alias1")
|
|
require.NoError(t, err)
|
|
|
|
require.NotNil(t, proxy)
|
|
require.Equal(t, "cluster1", id)
|
|
|
|
proxy, id, err = reconciler.GetProxy("alias2")
|
|
require.NoError(t, err)
|
|
|
|
require.NotNil(t, proxy)
|
|
require.Equal(t, "cluster1", id)
|
|
|
|
err = reconciler.Reconcile("cluster2", nil)
|
|
require.NoError(t, err)
|
|
|
|
proxy, id, err = reconciler.GetProxy("alias1")
|
|
require.NoError(t, err)
|
|
|
|
require.NotNil(t, proxy)
|
|
require.Equal(t, "cluster1", id)
|
|
|
|
proxy, id, err = reconciler.GetProxy("alias3")
|
|
require.NoError(t, err)
|
|
|
|
require.Nil(t, proxy)
|
|
require.Zero(t, id)
|
|
}
|