Skip to content

Commit

Permalink
fix: delete go.mod dead code
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Fernandez <mariofer@redhat.com>
  • Loading branch information
marioferh committed Aug 1, 2023
1 parent 13d4e56 commit 526803f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
11 changes: 1 addition & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,4 @@ require (
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

// // HACK: controller-runtime 0.14.6 does not support k8s/api 0.27.0
// // see: https://github.com/rhobs/observability-operator/issues/285
// replace (
// k8s.io/api => k8s.io/api v0.26.4
// k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.4
// k8s.io/apimachinery => k8s.io/apimachinery v0.26.4
// k8s.io/client-go => k8s.io/client-go v0.26.4
// )
)
12 changes: 12 additions & 0 deletions test/e2e/framework/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (f *Framework) AssertResourceNeverExists(name, namespace string, resource c
}

return func(t *testing.T) {
//nolint
if err := wait.Poll(option.PollInterval, option.WaitTimeout, func() (done bool, err error) {
key := types.NamespacedName{
Name: name,
Expand All @@ -65,6 +66,7 @@ func (f *Framework) AssertResourceNeverExists(name, namespace string, resource c
}

return true, fmt.Errorf("resource %s/%s should not have been created", namespace, name)
//nolint
}); err != wait.ErrWaitTimeout {
t.Fatal(err)
}
Expand All @@ -82,6 +84,7 @@ func (f *Framework) AssertResourceEventuallyExists(name, namespace string, resou
}

return func(t *testing.T) {
//nolint
if err := wait.Poll(option.PollInterval, option.WaitTimeout, func() (done bool, err error) {
key := types.NamespacedName{
Name: name,
Expand All @@ -91,6 +94,7 @@ func (f *Framework) AssertResourceEventuallyExists(name, namespace string, resou
return true, nil
}
return false, nil
//nolint
}); err == wait.ErrWaitTimeout {
t.Fatal(fmt.Errorf("resource %s/%s was never created", namespace, name))
}
Expand All @@ -108,6 +112,7 @@ func (f *Framework) AssertStatefulsetReady(name, namespace string, fns ...Option
}
return func(t *testing.T) {
key := types.NamespacedName{Name: name, Namespace: namespace}
//nolint
if err := wait.Poll(5*time.Second, option.WaitTimeout, func() (bool, error) {
pod := &appsv1.StatefulSet{}
err := f.K8sClient.Get(context.Background(), key, pod)
Expand All @@ -119,6 +124,7 @@ func (f *Framework) AssertStatefulsetReady(name, namespace string, fns ...Option
}

func (f *Framework) GetResourceWithRetry(t *testing.T, name, namespace string, obj client.Object) {
//nolint
err := wait.Poll(5*time.Second, CustomForeverTestTimeout, func() (bool, error) {
key := types.NamespacedName{Name: name, Namespace: namespace}

Expand All @@ -130,6 +136,7 @@ func (f *Framework) GetResourceWithRetry(t *testing.T, name, namespace string, o
return true, nil
})

//nolint
if err == wait.ErrWaitTimeout {
t.Fatal(fmt.Errorf("resource %s/%s was never created", namespace, name))
}
Expand Down Expand Up @@ -226,6 +233,7 @@ func (f *Framework) GetOperatorMetrics(t *testing.T) []byte {

stopChan := make(chan struct{})
defer close(stopChan)
//nolint
if err := wait.Poll(5*time.Second, CustomForeverTestTimeout, func() (bool, error) {
err := f.StartPortForward(pod.Name, pod.Namespace, "8080", stopChan)
return err == nil, nil
Expand Down Expand Up @@ -264,6 +272,7 @@ func (f *Framework) GetStackWhenAvailable(t *testing.T, name, namespace string)
Name: name,
Namespace: namespace,
}
//nolint
err := wait.Poll(5*time.Second, CustomForeverTestTimeout, func() (bool, error) {
err := f.K8sClient.Get(context.Background(), key, &ms)
if err != nil {
Expand All @@ -276,6 +285,7 @@ func (f *Framework) GetStackWhenAvailable(t *testing.T, name, namespace string)
return false, nil
})

//nolint
if err == wait.ErrWaitTimeout {
t.Fatal(fmt.Errorf("resource %s/%s was not available", namespace, name))
}
Expand All @@ -288,13 +298,15 @@ func (f *Framework) AssertAlertmanagerAbsent(t *testing.T, name, namespace strin
Name: name,
Namespace: namespace,
}
//nolint
err := wait.Poll(5*time.Second, CustomForeverTestTimeout, func() (bool, error) {
err := f.K8sClient.Get(context.Background(), key, &am)
if errors.IsNotFound(err) {
return true, nil
}
return false, nil
})
//nolint
if err == wait.ErrWaitTimeout {
t.Fatal(fmt.Errorf("alertmanager %s/%s is present when expected to be absent", namespace, name))
}
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/monitoring_stack_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func nilResrouceSelectorPropagatesToPrometheus(t *testing.T) {
assert.NilError(t, err, "failed to patch monitoring stack with nil resource selector")

prometheus := monv1.Prometheus{}
//nolint
err = wait.Poll(5*time.Second, framework.CustomForeverTestTimeout, func() (bool, error) {
if err := f.K8sClient.Get(context.Background(), types.NamespacedName{Name: updatedMS.Name, Namespace: updatedMS.Namespace}, &prometheus); errors.IsNotFound(err) {
return false, nil
Expand All @@ -160,6 +161,7 @@ func nilResrouceSelectorPropagatesToPrometheus(t *testing.T) {
return true, nil
})

//nolint
if err == wait.ErrWaitTimeout {
t.Fatal(fmt.Errorf("nil ResourceSelector did not propagate to Prometheus object"))
}
Expand Down Expand Up @@ -297,6 +299,7 @@ func reconcileRevertsManualChanges(t *testing.T) {
err = f.K8sClient.Update(context.Background(), modified)
assert.NilError(t, err, "failed to update a prometheus")

//nolint
err = wait.Poll(5*time.Second, time.Minute, func() (bool, error) {
reconciled := monv1.Prometheus{}
key := types.NamespacedName{Name: ms.Name, Namespace: ms.Namespace}
Expand Down Expand Up @@ -413,6 +416,7 @@ func assertPrometheusScrapesItself(t *testing.T) {

stopChan := make(chan struct{})
defer close(stopChan)
//nolint
if err := wait.Poll(5*time.Second, 2*time.Minute, func() (bool, error) {
err = f.StartServicePortForward("self-scrape-prometheus", e2eTestNamespace, "9090", stopChan)
return err == nil, nil
Expand All @@ -425,6 +429,7 @@ func assertPrometheusScrapesItself(t *testing.T) {
"prometheus_build_info": 2, // scrapes from both endpoints
"alertmanager_build_info": 2,
}
//nolint
if err := wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) {
correct := 0
for query, value := range expectedResults {
Expand Down Expand Up @@ -530,13 +535,15 @@ func assertAlertmanagerReceivesAlerts(t *testing.T) {

stopChan := make(chan struct{})
defer close(stopChan)
//nolint
if err := wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) {
err := f.StartServicePortForward("alerting-alertmanager", e2eTestNamespace, "9093", stopChan)
return err == nil, nil
}); err != nil {
t.Fatal(err)
}

//nolint
if err := wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) {
alerts, err := getAlertmanagerAlerts()
if err != nil {
Expand Down Expand Up @@ -584,6 +591,7 @@ func prometheusScaleDown(t *testing.T) {
ms.Spec.PrometheusConfig.Replicas = &numOfRep
err = f.K8sClient.Update(context.Background(), ms)
assert.NilError(t, err, "failed to update a monitoring stack")
//nolint
err = wait.Poll(5*time.Second, framework.CustomForeverTestTimeout, func() (bool, error) {
if err := f.K8sClient.Get(context.Background(), key, &prom); errors.IsNotFound(err) {
return false, nil
Expand All @@ -595,6 +603,7 @@ func prometheusScaleDown(t *testing.T) {
return true, nil
})

//nolint
if err == wait.ErrWaitTimeout {
t.Fatal(fmt.Errorf("Prometheus was not scaled down"))
}
Expand Down Expand Up @@ -819,6 +828,7 @@ func newMonitoringStack(t *testing.T, name string, mods ...stackModifier) *stack
}

func waitForStackDeletion(name string) error {
//nolint
return wait.Poll(5*time.Second, framework.CustomForeverTestTimeout, func() (bool, error) {
key := types.NamespacedName{Name: name, Namespace: e2eTestNamespace}
var ms stack.MonitoringStack
Expand Down Expand Up @@ -856,6 +866,7 @@ func namespaceSelectorTest(t *testing.T) {

stopChan := make(chan struct{})
defer close(stopChan)
//nolint
if pollErr := wait.Poll(5*time.Second, 2*time.Minute, func() (bool, error) {
err := f.StartServicePortForward(ms.Name+"-prometheus", e2eTestNamespace, "9090", stopChan)
return err == nil, nil
Expand All @@ -864,6 +875,7 @@ func namespaceSelectorTest(t *testing.T) {
}

promClient := framework.NewPrometheusClient("http://localhost:9090")
//nolint
if pollErr := wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) {
query := `version{pod="prometheus-example-app",namespace=~"test-ns-.*"}`
result, err := promClient.Query(query)
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/thanos_querier_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func singleStackWithSidecar(t *testing.T) {
// Assert prometheus instance can be queried
stopChan := make(chan struct{})
defer close(stopChan)
//nolint
if err := wait.Poll(5*time.Second, 2*time.Minute, func() (bool, error) {
err = f.StartServicePortForward(name, e2eTestNamespace, "9090", stopChan)
return err == nil, nil
Expand All @@ -86,6 +87,7 @@ func singleStackWithSidecar(t *testing.T) {
expectedResults := map[string]int{
"prometheus_build_info": 2, // must return from both prometheus pods
}
//nolint
if err := wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) {
correct := 0
for query, value := range expectedResults {
Expand Down Expand Up @@ -137,6 +139,7 @@ func newThanosQuerier(t *testing.T, name string, selector map[string]string) *ms
}

func waitForThanosQuerierDeletion(tq *msov1.ThanosQuerier) error {
//nolint
return wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
err := f.K8sClient.Get(context.Background(),
types.NamespacedName{Name: tq.Name, Namespace: tq.Namespace},
Expand All @@ -146,6 +149,7 @@ func waitForThanosQuerierDeletion(tq *msov1.ThanosQuerier) error {
}

func waitForDeploymentDeletion(name string) error {
//nolint
return wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
var dep appsv1.Deployment
err := f.K8sClient.Get(context.Background(),
Expand All @@ -156,6 +160,7 @@ func waitForDeploymentDeletion(name string) error {
}

func waitForServiceDeletion(name string) error {
//nolint
return wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
var svc corev1.Service
err := f.K8sClient.Get(context.Background(),
Expand Down

0 comments on commit 526803f

Please sign in to comment.