mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
testenv: configure metrics address (#5368)
This commit is contained in:
parent
135e737d7c
commit
3e51b4f905
1 changed files with 28 additions and 24 deletions
|
@ -302,14 +302,15 @@ func New(t testing.TB, opts ...EnvironmentOption) Environment {
|
||||||
require: require.New(t),
|
require: require.New(t),
|
||||||
tempDir: t.TempDir(),
|
tempDir: t.TempDir(),
|
||||||
ports: Ports{
|
ports: Ports{
|
||||||
ProxyHTTP: values.Deferred[int](),
|
ProxyHTTP: values.Deferred[int](),
|
||||||
ProxyGRPC: values.Deferred[int](),
|
ProxyGRPC: values.Deferred[int](),
|
||||||
GRPC: values.Deferred[int](),
|
ProxyMetrics: values.Deferred[int](),
|
||||||
HTTP: values.Deferred[int](),
|
GRPC: values.Deferred[int](),
|
||||||
Outbound: values.Deferred[int](),
|
HTTP: values.Deferred[int](),
|
||||||
Metrics: values.Deferred[int](),
|
Outbound: values.Deferred[int](),
|
||||||
Debug: values.Deferred[int](),
|
Metrics: values.Deferred[int](),
|
||||||
ALPN: values.Deferred[int](),
|
Debug: values.Deferred[int](),
|
||||||
|
ALPN: values.Deferred[int](),
|
||||||
},
|
},
|
||||||
workspaceFolder: workspaceFolder,
|
workspaceFolder: workspaceFolder,
|
||||||
silent: silent,
|
silent: silent,
|
||||||
|
@ -360,14 +361,15 @@ type WithCaller[T any] struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Ports struct {
|
type Ports struct {
|
||||||
ProxyHTTP values.MutableValue[int]
|
ProxyHTTP values.MutableValue[int]
|
||||||
ProxyGRPC values.MutableValue[int]
|
ProxyGRPC values.MutableValue[int]
|
||||||
GRPC values.MutableValue[int]
|
ProxyMetrics values.MutableValue[int]
|
||||||
HTTP values.MutableValue[int]
|
GRPC values.MutableValue[int]
|
||||||
Outbound values.MutableValue[int]
|
HTTP values.MutableValue[int]
|
||||||
Metrics values.MutableValue[int]
|
Outbound values.MutableValue[int]
|
||||||
Debug values.MutableValue[int]
|
Metrics values.MutableValue[int]
|
||||||
ALPN values.MutableValue[int]
|
Debug values.MutableValue[int]
|
||||||
|
ALPN values.MutableValue[int]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *environment) TempDir() string {
|
func (e *environment) TempDir() string {
|
||||||
|
@ -448,7 +450,7 @@ func (e *environment) Start() {
|
||||||
cfg := &config.Config{
|
cfg := &config.Config{
|
||||||
Options: config.NewDefaultOptions(),
|
Options: config.NewDefaultOptions(),
|
||||||
}
|
}
|
||||||
ports, err := netutil.AllocatePorts(8)
|
ports, err := netutil.AllocatePorts(9)
|
||||||
require.NoError(e.t, err)
|
require.NoError(e.t, err)
|
||||||
atoi := func(str string) int {
|
atoi := func(str string) int {
|
||||||
p, err := strconv.Atoi(str)
|
p, err := strconv.Atoi(str)
|
||||||
|
@ -459,13 +461,14 @@ func (e *environment) Start() {
|
||||||
}
|
}
|
||||||
e.ports.ProxyHTTP.Resolve(atoi(ports[0]))
|
e.ports.ProxyHTTP.Resolve(atoi(ports[0]))
|
||||||
e.ports.ProxyGRPC.Resolve(atoi(ports[1]))
|
e.ports.ProxyGRPC.Resolve(atoi(ports[1]))
|
||||||
e.ports.GRPC.Resolve(atoi(ports[2]))
|
e.ports.ProxyMetrics.Resolve(atoi(ports[2]))
|
||||||
e.ports.HTTP.Resolve(atoi(ports[3]))
|
e.ports.GRPC.Resolve(atoi(ports[3]))
|
||||||
e.ports.Outbound.Resolve(atoi(ports[4]))
|
e.ports.HTTP.Resolve(atoi(ports[4]))
|
||||||
e.ports.Metrics.Resolve(atoi(ports[5]))
|
e.ports.Outbound.Resolve(atoi(ports[5]))
|
||||||
e.ports.Debug.Resolve(atoi(ports[6]))
|
e.ports.Metrics.Resolve(atoi(ports[6]))
|
||||||
e.ports.ALPN.Resolve(atoi(ports[7]))
|
e.ports.Debug.Resolve(atoi(ports[7]))
|
||||||
cfg.AllocatePorts(*(*[6]string)(ports[2:]))
|
e.ports.ALPN.Resolve(atoi(ports[8]))
|
||||||
|
cfg.AllocatePorts(*(*[6]string)(ports[3:]))
|
||||||
|
|
||||||
cfg.Options.AutocertOptions = config.AutocertOptions{Enable: false}
|
cfg.Options.AutocertOptions = config.AutocertOptions{Enable: false}
|
||||||
cfg.Options.Services = "all"
|
cfg.Options.Services = "all"
|
||||||
|
@ -473,6 +476,7 @@ func (e *environment) Start() {
|
||||||
cfg.Options.ProxyLogLevel = config.LogLevelInfo
|
cfg.Options.ProxyLogLevel = config.LogLevelInfo
|
||||||
cfg.Options.Addr = fmt.Sprintf("127.0.0.1:%d", e.ports.ProxyHTTP.Value())
|
cfg.Options.Addr = fmt.Sprintf("127.0.0.1:%d", e.ports.ProxyHTTP.Value())
|
||||||
cfg.Options.GRPCAddr = fmt.Sprintf("127.0.0.1:%d", e.ports.ProxyGRPC.Value())
|
cfg.Options.GRPCAddr = fmt.Sprintf("127.0.0.1:%d", e.ports.ProxyGRPC.Value())
|
||||||
|
cfg.Options.MetricsAddr = fmt.Sprintf("127.0.0.1:%d", e.ports.ProxyMetrics.Value())
|
||||||
cfg.Options.CAFile = filepath.Join(e.tempDir, "certs", "ca.pem")
|
cfg.Options.CAFile = filepath.Join(e.tempDir, "certs", "ca.pem")
|
||||||
cfg.Options.CertFile = filepath.Join(e.tempDir, "certs", "trusted.pem")
|
cfg.Options.CertFile = filepath.Join(e.tempDir, "certs", "trusted.pem")
|
||||||
cfg.Options.KeyFile = filepath.Join(e.tempDir, "certs", "trusted-key.pem")
|
cfg.Options.KeyFile = filepath.Join(e.tempDir, "certs", "trusted-key.pem")
|
||||||
|
|
Loading…
Add table
Reference in a new issue