Skip to content

Commit

Permalink
upgrade test(LTS): add segments to version 1.10 (#19861)
Browse files Browse the repository at this point in the history
  • Loading branch information
huikang authored Dec 8, 2023
1 parent d4fda94 commit 0ca070b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 73 deletions.
70 changes: 0 additions & 70 deletions test-integ/upgrade/usage_profiles/sd_wan_segments_test.go

This file was deleted.

2 changes: 2 additions & 0 deletions testing/deployer/sprawl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ agent_prefix "" {
node_prefix "" {
policy = "write"
}
operator = "read"
`
policy, _, err := acl.PolicyCreate(
&api.ACLPolicy{
Expand Down
4 changes: 2 additions & 2 deletions testing/deployer/sprawl/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (s *Sprawl) createFirstTime() error {
}
for _, cluster := range s.topology.Clusters {
if err := s.waitForClientAntiEntropyOnce(cluster); err != nil {
return fmt.Errorf("waitForClientAntiEntropyOnce[%s]: %w", cluster.Name, err)
return fmt.Errorf("create first time - waitForClientAntiEntropyOnce[%s]: %w", cluster.Name, err)
}
}

Expand Down Expand Up @@ -447,7 +447,7 @@ func (s *Sprawl) postRegenTasks(firstTime bool) error {

for _, cluster := range s.topology.Clusters {
if err := s.waitForClientAntiEntropyOnce(cluster); err != nil {
return fmt.Errorf("waitForClientAntiEntropyOnce[%s]: %w", cluster.Name, err)
return fmt.Errorf("post regenerate waitForClientAntiEntropyOnce[%s]: %w", cluster.Name, err)
}
}

Expand Down
18 changes: 17 additions & 1 deletion testing/deployer/sprawl/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"strconv"
"strings"
"text/tabwriter"
"time"

retry "github.com/avast/retry-go"
"github.com/hashicorp/consul/api"
)

// PrintDetails will dump relevant addressing and naming data to the logger for
Expand All @@ -22,7 +26,19 @@ func (s *Sprawl) PrintDetails() error {
for _, cluster := range s.topology.Clusters {
client := s.clients[cluster.Name]

cfg, err := client.Operator().RaftGetConfiguration(nil)
var cfg *api.RaftConfiguration
var err error
err = retry.Do(
func() error {
cfg, err = client.Operator().RaftGetConfiguration(nil)
if err != nil {
return fmt.Errorf("error get raft config: %w", err)
}
return nil
},
retry.MaxDelay(5*time.Second),
retry.Attempts(15),
)
if err != nil {
return fmt.Errorf("could not get raft config for cluster %q: %w", cluster.Name, err)
}
Expand Down
18 changes: 18 additions & 0 deletions testing/deployer/sprawl/internal/tfgen/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func (g *Generator) generateAgentHCL(node *topology.Node, enableV2, enableV2Tena
b.add("retry_interval", "1s")
// }

if node.Segment != nil {
b.add("segment", node.Segment.Name)
b.addSlice("retry_join", []string{
fmt.Sprintf("server.%s-consulcluster.lan:%d", node.Cluster, node.Segment.Port),
})
}

if node.Images.GreaterThanVersion(topology.MinVersionPeering) {
if node.IsServer() {
b.addBlock("peering", func() {
Expand Down Expand Up @@ -209,6 +216,17 @@ func (g *Generator) generateAgentHCL(node *topology.Node, enableV2, enableV2Tena
}
})
}

if cluster.Segments != nil {
b.format("segments = [")
for name, port := range cluster.Segments {
b.format("{")
b.add("name", name)
b.add("port", port)
b.format("},")
}
b.format("]")
}
} else {
if cluster.Enterprise && node.Images.GreaterThanVersion(topology.MinVersionAgentTokenPartition) {
b.add("partition", node.Partition)
Expand Down
11 changes: 11 additions & 0 deletions testing/deployer/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ type Cluster struct {
// EnableV2Tenancy activates V2 tenancy on the servers. If not enabled,
// V2 resources are bridged to V1 tenancy counterparts.
EnableV2Tenancy bool `json:",omitempty"`

// Segments is a map of network segment name and the ports
Segments map[string]int
}

func (c *Cluster) inheritFromExisting(existing *Cluster) {
Expand Down Expand Up @@ -485,6 +488,11 @@ const (
NodeVersionV2 NodeVersion = "v2"
)

type NetworkSegment struct {
Name string
Port int
}

// TODO: rename pod
type Node struct {
Kind NodeKind
Expand Down Expand Up @@ -530,6 +538,9 @@ type Node struct {

// AutopilotConfig of the server agent
AutopilotConfig map[string]string

// Network segment of the agent - applicable to client agent only
Segment *NetworkSegment
}

func (n *Node) DockerName() string {
Expand Down

0 comments on commit 0ca070b

Please sign in to comment.