ci: swap freeport for portal in packages (#15661)

This commit is contained in:
Seth Hoenig
2023-01-03 11:25:20 -06:00
committed by GitHub
parent 99ab6d439c
commit dab4d7ed7a
24 changed files with 201 additions and 1041 deletions

View File

@@ -16,7 +16,6 @@ import (
"github.com/hashicorp/nomad/ci"
client "github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/testutil"
"github.com/hashicorp/nomad/helper/freeport"
"github.com/hashicorp/nomad/helper/pointer"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/nomad/structs/config"
@@ -660,8 +659,7 @@ func TestConfig_Listener(t *testing.T) {
}
// Works with valid inputs
ports := freeport.MustTake(2)
defer freeport.Return(ports)
ports := ci.PortAllocator.Grab(2)
ln, err := config.Listener("tcp", "127.0.0.1", ports[0])
if err != nil {

View File

@@ -15,10 +15,10 @@ import (
metrics "github.com/armon/go-metrics"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
client "github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/fingerprint"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/freeport"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad"
"github.com/hashicorp/nomad/nomad/mock"
@@ -269,8 +269,6 @@ func (a *TestAgent) Shutdown() {
}
a.shutdown = true
defer freeport.Return(a.ports)
defer func() {
if a.DataDir != "" {
_ = os.RemoveAll(a.DataDir)
@@ -332,7 +330,7 @@ func (a *TestAgent) Client() *api.Client {
// Instead of relying on one set of ports to be sufficient we retry
// starting the agent with different ports on port conflict.
func (a *TestAgent) pickRandomPorts(c *Config) {
ports := freeport.MustTake(3)
ports := ci.PortAllocator.Grab(3)
a.ports = append(a.ports, ports...)
c.Ports.HTTP = ports[0]

View File

@@ -30,8 +30,7 @@ func TestHTTP_Variables(t *testing.T) {
httpTest(t, cb, func(s *TestAgent) {
// These tests are run against the same running server in order to reduce
// the costs of server startup and allow as much parallelization as possible
// given the port reuse issue that we have seen with the current freeport
// the costs of server startup and allow as much parallelization as possible.
t.Run("error_badverb_list", func(t *testing.T) {
req, err := http.NewRequest("LOLWUT", "/v1/vars", nil)
require.NoError(t, err)