-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into NET-1723/update-docs
- Loading branch information
Showing
48 changed files
with
4,424 additions
and
1,349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
libcluster "github.com/hashicorp/consul/test/integration/consul-container/libs/cluster" | ||
"github.com/hashicorp/consul/test/integration/consul-container/libs/utils" | ||
"github.com/stretchr/testify/require" | ||
"github.com/testcontainers/testcontainers-go" | ||
) | ||
|
||
type TestLogConsumer struct { | ||
Msgs []string | ||
} | ||
|
||
func (g *TestLogConsumer) Accept(l testcontainers.Log) { | ||
g.Msgs = append(g.Msgs, string(l.Content)) | ||
} | ||
|
||
// Creates a cluster with options for basic customization. All args except t | ||
// are optional and will use sensible defaults when not provided. | ||
func CreateCluster( | ||
t *testing.T, | ||
cmd string, | ||
logConsumer *TestLogConsumer, | ||
buildOptions *libcluster.BuildOptions, | ||
applyDefaultProxySettings bool) *libcluster.Cluster { | ||
|
||
// optional | ||
if buildOptions == nil { | ||
buildOptions = &libcluster.BuildOptions{ | ||
InjectAutoEncryption: true, | ||
InjectGossipEncryption: true, | ||
} | ||
} | ||
ctx := libcluster.NewBuildContext(t, *buildOptions) | ||
|
||
conf := libcluster.NewConfigBuilder(ctx).ToAgentConfig(t) | ||
|
||
// optional | ||
if logConsumer != nil { | ||
conf.LogConsumer = logConsumer | ||
} | ||
|
||
t.Logf("Cluster config:\n%s", conf.JSON) | ||
|
||
// optional custom cmd | ||
if cmd != "" { | ||
conf.Cmd = append(conf.Cmd, cmd) | ||
} | ||
|
||
cluster, err := libcluster.New(t, []libcluster.Config{*conf}) | ||
require.NoError(t, err) | ||
|
||
client, err := cluster.GetClient(nil, true) | ||
|
||
require.NoError(t, err) | ||
libcluster.WaitForLeader(t, cluster, client) | ||
libcluster.WaitForMembers(t, client, 1) | ||
|
||
if applyDefaultProxySettings { | ||
ok, err := utils.ApplyDefaultProxySettings(client) | ||
require.NoError(t, err) | ||
require.True(t, ok) | ||
} | ||
|
||
return cluster | ||
} |
Oops, something went wrong.