mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-31 20:39:37 +08:00
* Revert "Make `PortList.Pop()` thread-safe (#11799)" This reverts commita17337d1a1. * Revert "Ensure stateOK is reported only when all components have sent updates (#11249)" This reverts commitb749302e2c. * Revert "Throw startup error if `TeleportReadyEvent` is not emitted (#11725)" This reverts commit933e247287. * Revert "Fix ProxyKube not reporting its readiness (#12150)" This reverts commit6cdcfe7721.
89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
// Copyright 2021 Gravitational, 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 service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestProcessStateGetState(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
desc string
|
|
states map[string]*componentState
|
|
want componentStateEnum
|
|
}{
|
|
{
|
|
desc: "no components",
|
|
states: map[string]*componentState{},
|
|
want: stateStarting,
|
|
},
|
|
{
|
|
desc: "one component in stateOK",
|
|
states: map[string]*componentState{
|
|
"one": {state: stateOK},
|
|
},
|
|
want: stateOK,
|
|
},
|
|
{
|
|
desc: "multiple components in stateOK",
|
|
states: map[string]*componentState{
|
|
"one": {state: stateOK},
|
|
"two": {state: stateOK},
|
|
"three": {state: stateOK},
|
|
},
|
|
want: stateOK,
|
|
},
|
|
{
|
|
desc: "multiple components, one is degraded",
|
|
states: map[string]*componentState{
|
|
"one": {state: stateRecovering},
|
|
"two": {state: stateDegraded},
|
|
"three": {state: stateOK},
|
|
},
|
|
want: stateDegraded,
|
|
},
|
|
{
|
|
desc: "multiple components, one is recovering",
|
|
states: map[string]*componentState{
|
|
"one": {state: stateOK},
|
|
"two": {state: stateRecovering},
|
|
"three": {state: stateOK},
|
|
},
|
|
want: stateRecovering,
|
|
},
|
|
{
|
|
desc: "multiple components, one is starting",
|
|
states: map[string]*componentState{
|
|
"one": {state: stateOK},
|
|
"two": {state: stateStarting},
|
|
"three": {state: stateOK},
|
|
},
|
|
want: stateStarting,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.desc, func(t *testing.T) {
|
|
ps := &processState{states: tt.states}
|
|
got := ps.getState()
|
|
require.Equal(t, got, tt.want)
|
|
})
|
|
}
|
|
}
|