Skip to content

Commit

Permalink
chore(ot-operator): remove main installation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-rumian committed Mar 10, 2022
1 parent 90eae9d commit fb3818b
Showing 1 changed file with 1 addition and 152 deletions.
153 changes: 1 addition & 152 deletions tests/integration/helm_opentelemetry_operator_enabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/e2e-framework/klient/k8s"
"sigs.k8s.io/e2e-framework/klient/k8s/resources"
"sigs.k8s.io/e2e-framework/klient/wait"
"sigs.k8s.io/e2e-framework/klient/wait/conditions"
"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"

terrak8s "github.com/gruntwork-io/terratest/modules/k8s"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand All @@ -30,155 +28,6 @@ func Test_Helm_OpenTelemetry_Operator_Enabled(t *testing.T) {
waitDuration = time.Minute * 2
)

featInstall := features.New("installation").
Assess("sumologic secret is created",
func(ctx context.Context, t *testing.T, envConf *envconf.Config) context.Context {
terrak8s.WaitUntilSecretAvailable(t, ctxopts.KubectlOptions(ctx), "sumologic", 60, tickDuration)
secret := terrak8s.GetSecret(t, ctxopts.KubectlOptions(ctx), "sumologic")
// Apart from 10 default entries it also has 1 for traces
require.Len(t, secret.Data, 11)
return ctx
}).
Assess("fluentd logs statefulset is ready",
stepfuncs.WaitUntilStatefulSetIsReady(
waitDuration,
tickDuration,
stepfuncs.WithNameF(
stepfuncs.ReleaseFormatter("%s-sumologic-fluentd-logs"),
),
stepfuncs.WithLabelsF(
stepfuncs.LabelFormatterKV{
K: "app",
V: stepfuncs.ReleaseFormatter("%s-sumologic-fluentd-logs"),
},
),
),
).
Assess("fluentd logs buffers PVCs are created",
func(ctx context.Context, t *testing.T, envConf *envconf.Config) context.Context {
namespace := ctxopts.Namespace(ctx)
releaseName := ctxopts.HelmRelease(ctx)
kubectlOptions := ctxopts.KubectlOptions(ctx)

t.Logf("kubeconfig: %s", kubectlOptions.ConfigPath)
cl, err := terrak8s.GetKubernetesClientFromOptionsE(t, kubectlOptions)
require.NoError(t, err)

assert.Eventually(t, func() bool {
pvcs, err := cl.CoreV1().PersistentVolumeClaims(namespace).
List(ctx, metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s-sumologic-fluentd-logs", releaseName),
})
if !assert.NoError(t, err) {
return false
}

return err == nil && len(pvcs.Items) == 1
}, waitDuration, tickDuration)
return ctx
}).
Assess("fluentd metrics statefulset is ready",
stepfuncs.WaitUntilStatefulSetIsReady(
waitDuration,
tickDuration,
stepfuncs.WithNameF(
stepfuncs.ReleaseFormatter("%s-sumologic-fluentd-metrics"),
),
stepfuncs.WithLabelsF(
stepfuncs.LabelFormatterKV{
K: "app",
V: stepfuncs.ReleaseFormatter("%s-sumologic-fluentd-metrics"),
},
),
),
).
Assess("fluentd metrics buffers PVCs are created",
func(ctx context.Context, t *testing.T, envConf *envconf.Config) context.Context {
namespace := ctxopts.Namespace(ctx)
releaseName := ctxopts.HelmRelease(ctx)
kubectlOptions := ctxopts.KubectlOptions(ctx)

t.Logf("kubeconfig: %s", kubectlOptions.ConfigPath)
cl, err := terrak8s.GetKubernetesClientFromOptionsE(t, kubectlOptions)
require.NoError(t, err)

assert.Eventually(t, func() bool {
pvcs, err := cl.CoreV1().PersistentVolumeClaims(namespace).
List(ctx, metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s-sumologic-fluentd-metrics", releaseName),
})
if !assert.NoError(t, err) {
return false
}

return err == nil && len(pvcs.Items) == 1
}, waitDuration, tickDuration)
return ctx
}).
Assess("fluentd events statefulset is ready",
stepfuncs.WaitUntilStatefulSetIsReady(
waitDuration,
tickDuration,
stepfuncs.WithNameF(
stepfuncs.ReleaseFormatter("%s-sumologic-fluentd-events"),
),
stepfuncs.WithLabelsF(
stepfuncs.LabelFormatterKV{
K: "app",
V: stepfuncs.ReleaseFormatter("%s-sumologic-fluentd-events"),
},
),
),
).
Assess("fluentd events buffers PVCs are created",
func(ctx context.Context, t *testing.T, envConf *envconf.Config) context.Context {
namespace := ctxopts.Namespace(ctx)
releaseName := ctxopts.HelmRelease(ctx)
kubectlOptions := ctxopts.KubectlOptions(ctx)

t.Logf("kubeconfig: %s", kubectlOptions.ConfigPath)
cl, err := terrak8s.GetKubernetesClientFromOptionsE(t, kubectlOptions)
require.NoError(t, err)

assert.Eventually(t, func() bool {
pvcs, err := cl.CoreV1().PersistentVolumeClaims(namespace).
List(ctx, metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s-sumologic-fluentd-events", releaseName),
})
if !assert.NoError(t, err) {
return false
}

return err == nil && len(pvcs.Items) == 1
}, waitDuration, tickDuration)
return ctx
}).
Assess("prometheus pods are available",
stepfuncs.WaitUntilPodsAvailable(
metav1.ListOptions{
LabelSelector: "app=prometheus",
},
1,
waitDuration,
tickDuration,
),
).
Assess("fluent-bit daemonset is running",
func(ctx context.Context, t *testing.T, envConf *envconf.Config) context.Context {
var daemonsets []appsv1.DaemonSet
require.Eventually(t, func() bool {
daemonsets = terrak8s.ListDaemonSets(t, ctxopts.KubectlOptions(ctx), metav1.ListOptions{
LabelSelector: "app.kubernetes.io/name=fluent-bit",
})

return len(daemonsets) == 1
}, waitDuration, tickDuration)

require.EqualValues(t, 0, daemonsets[0].Status.NumberUnavailable)
return ctx
}).
Feature()

featTraces := features.New("traces").
// TODO: Rewrite into similar step func as WaitUntilStatefulSetIsReady but for deployments
Assess("otelcol deployment is ready", func(ctx context.Context, t *testing.T, envConf *envconf.Config) context.Context {
Expand Down Expand Up @@ -274,5 +123,5 @@ func Test_Helm_OpenTelemetry_Operator_Enabled(t *testing.T) {
}).
Feature()

testenv.Test(t, featInstall, featTraces, featOpenTelemetryOperator)
testenv.Test(t, featTraces, featOpenTelemetryOperator)
}

0 comments on commit fb3818b

Please sign in to comment.