Skip to content

Commit

Permalink
chore: update golangci-lint to v1.60.2, fix misleading test (opendata…
Browse files Browse the repository at this point in the history
…hub-io#1195)

* chore: update golangci-lint to v1.60.2

Signed-off-by: Luca Burgazzoli <[email protected]>

* chore: rework UpdateComponentReconcile test

---------

Signed-off-by: Luca Burgazzoli <[email protected]>
(cherry picked from commit 6acf1db)
  • Loading branch information
lburgazzoli authored and openshift-merge-bot[bot] committed Aug 30, 2024
1 parent cf466ad commit 242004f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: v1.59.1
skip-cache: true
version: v1.60.2
args: --timeout 5m0s
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ YQ ?= $(LOCALBIN)/yq
KUSTOMIZE_VERSION ?= v5.0.2
CONTROLLER_GEN_VERSION ?= v0.9.2
OPERATOR_SDK_VERSION ?= v1.31.0
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.60.2
YQ_VERSION ?= v4.12.2
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24.2
Expand Down
64 changes: 34 additions & 30 deletions tests/e2e/dsc_creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,37 +426,41 @@ func (tc *testContext) testUpdateComponentReconcile() error {
if err != nil {
return err
}
if len(appDeployments.Items) != 0 {
testDeployment := appDeployments.Items[0]
expectedReplica := 3
patchedReplica := &autoscalingv1.Scale{
ObjectMeta: metav1.ObjectMeta{
Name: testDeployment.Name,
Namespace: testDeployment.Namespace,
},
Spec: autoscalingv1.ScaleSpec{
Replicas: 3, // rhoai has 5 pods
},
Status: autoscalingv1.ScaleStatus{},
}
updatedDep, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).UpdateScale(tc.ctx, testDeployment.Name, patchedReplica, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("error patching component resources : %w", err)
}
if updatedDep.Spec.Replicas != patchedReplica.Spec.Replicas {
return fmt.Errorf("failed to patch replicas : expect to be %v but got %v", patchedReplica.Spec.Replicas, updatedDep.Spec.Replicas)
}

// Sleep for 40 seconds to allow the operator to reconcile
// we expect it should not revert back to original value because of AllowList
time.Sleep(4 * tc.resourceRetryInterval)
reconciledDep, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).Get(tc.ctx, testDeployment.Name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("error getting component resource after reconcile: %w", err)
}
if *reconciledDep.Spec.Replicas != int32(expectedReplica) {
return fmt.Errorf("failed to revert back replicas : expect to be %v but got %v", expectedReplica, *reconciledDep.Spec.Replicas)
}
if len(appDeployments.Items) != 1 {
return fmt.Errorf("error getting deployment for component %s", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
}

const expectedReplica int32 = 3

testDeployment := appDeployments.Items[0]
patchedReplica := &autoscalingv1.Scale{
ObjectMeta: metav1.ObjectMeta{
Name: testDeployment.Name,
Namespace: testDeployment.Namespace,
},
Spec: autoscalingv1.ScaleSpec{
Replicas: expectedReplica,
},
Status: autoscalingv1.ScaleStatus{},
}
updatedDep, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).UpdateScale(tc.ctx, testDeployment.Name, patchedReplica, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("error patching component resources : %w", err)
}
if updatedDep.Spec.Replicas != patchedReplica.Spec.Replicas {
return fmt.Errorf("failed to patch replicas : expect to be %v but got %v", patchedReplica.Spec.Replicas, updatedDep.Spec.Replicas)
}

// Sleep for 40 seconds to allow the operator to reconcile
// we expect it should not revert back to original value because of AllowList
time.Sleep(4 * tc.resourceRetryInterval)
reconciledDep, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).Get(tc.ctx, testDeployment.Name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("error getting component resource after reconcile: %w", err)
}
if *reconciledDep.Spec.Replicas != expectedReplica {
return fmt.Errorf("failed to revert back replicas : expect to be %v but got %v", expectedReplica, *reconciledDep.Spec.Replicas)
}

return nil
Expand Down

0 comments on commit 242004f

Please sign in to comment.