2021-01-13 01:27:41 +00:00
|
|
|
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
2020-09-16 14:19:51 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2020-07-09 19:30:59 +00:00
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2020-08-19 18:21:07 +00:00
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
2020-07-09 19:30:59 +00:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
|
2021-06-22 15:23:19 +00:00
|
|
|
"go.pinniped.dev/test/testlib"
|
2020-07-09 19:30:59 +00:00
|
|
|
)
|
|
|
|
|
2020-08-19 18:21:07 +00:00
|
|
|
func TestGetDeployment(t *testing.T) {
|
2021-06-22 15:23:19 +00:00
|
|
|
env := testlib.IntegrationEnv(t)
|
|
|
|
client := testlib.NewKubernetesClientset(t)
|
2020-07-09 19:30:59 +00:00
|
|
|
|
2021-03-05 01:25:43 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
2020-07-09 19:30:59 +00:00
|
|
|
defer cancel()
|
|
|
|
|
2020-10-09 17:11:47 +00:00
|
|
|
appDeployment, err := client.AppsV1().Deployments(env.ConciergeNamespace).Get(ctx, env.ConciergeAppName, metav1.GetOptions{})
|
2020-07-09 19:30:59 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2020-08-19 18:21:07 +00:00
|
|
|
cond := getDeploymentCondition(appDeployment.Status, appsv1.DeploymentAvailable)
|
|
|
|
require.NotNil(t, cond)
|
2021-06-22 15:23:19 +00:00
|
|
|
require.Equalf(t, corev1.ConditionTrue, cond.Status, "app should be available: %s", testlib.Sdump(appDeployment))
|
2020-08-19 18:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// getDeploymentCondition returns the condition with the provided type.
|
|
|
|
// Copied from k8s.io/kubectl/pkg/util/deployment/deployment.go to prevent us from vendoring the world.
|
|
|
|
func getDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition {
|
|
|
|
for i := range status.Conditions {
|
|
|
|
c := status.Conditions[i]
|
|
|
|
if c.Type == condType {
|
|
|
|
return &c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
2020-07-09 19:30:59 +00:00
|
|
|
}
|