Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubernetes_cluster_* - fix tests with ctx deadline #24886

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"strings"
"testing"
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
Expand Down Expand Up @@ -1129,6 +1130,7 @@ func (KubernetesClusterNodePoolResource) scaleNodePool(nodeCount int) acceptance
nodePoolName := state.Attributes["name"]
kubernetesClusterId := state.Attributes["kubernetes_cluster_id"]
parsedK8sId, err := commonids.ParseKubernetesClusterID(kubernetesClusterId)

if err != nil {
return fmt.Errorf("parsing kubernetes cluster id: %+v", err)
}
Expand All @@ -1152,6 +1154,9 @@ func (KubernetesClusterNodePoolResource) scaleNodePool(nodeCount int) acceptance

nodePool.Model.Properties.Count = utils.Int64(int64(nodeCount))

ctx, cancel := context.WithDeadline(clients.StopContext, time.Now().Add(1*time.Hour))
defer cancel()

err = clients.Containers.AgentPoolsClient.CreateOrUpdateThenPoll(ctx, parsedAgentPoolId, *nodePool.Model)
if err != nil {
return fmt.Errorf("Bad: updating node pool %q: %+v", nodePoolName, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
Expand Down Expand Up @@ -237,6 +238,9 @@ func (KubernetesClusterResource) updateDefaultNodePoolAgentCount(nodeCount int)

nodePool.Model.Properties.Count = utils.Int64(int64(nodeCount))

ctx, cancel := context.WithDeadline(clients.StopContext, time.Now().Add(1*time.Hour))
defer cancel()

err = clients.Containers.AgentPoolsClient.CreateOrUpdateThenPoll(ctx, agentPoolId, *nodePool.Model)
if err != nil {
return fmt.Errorf("Bad: updating node pool %q: %+v", nodePoolName, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"regexp"
"testing"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
Expand Down Expand Up @@ -73,6 +74,9 @@ func TestAccKubernetesCluster_updateVmSizeAfterFailureWithTempAndDefault(t *test
profile.Name = &tempNodePoolName
profile.Properties.VMSize = pointer.To("Standard_DS3_v2")

ctx, cancel := context.WithDeadline(clients.StopContext, time.Now().Add(1*time.Hour))
defer cancel()

tempNodePoolId := agentpools.NewAgentPoolID(id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, tempNodePoolName)
if err := client.CreateOrUpdateThenPoll(ctx, tempNodePoolId, *profile); err != nil {
return fmt.Errorf("creating %s: %+v", tempNodePoolId, err)
Expand Down Expand Up @@ -126,6 +130,9 @@ func TestAccKubernetesCluster_updateVmSizeAfterFailureWithTempWithoutDefault(t *
profile.Name = &tempNodePoolName
profile.Properties.VMSize = pointer.To("Standard_DS3_v2")

ctx, cancel := context.WithDeadline(clients.StopContext, time.Now().Add(1*time.Hour))
defer cancel()

tempNodePoolId := agentpools.NewAgentPoolID(id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, tempNodePoolName)
if err := client.CreateOrUpdateThenPoll(ctx, tempNodePoolId, *profile); err != nil {
return fmt.Errorf("creating %s: %+v", tempNodePoolId, err)
Expand Down
Loading