summaryrefslogtreecommitdiff
path: root/libnetwork
diff options
context:
space:
mode:
authorCory Snider <csnider@mirantis.com>2023-05-09 18:27:40 -0400
committerCory Snider <csnider@mirantis.com>2023-05-09 19:13:17 -0400
commit4e0319c87857f180b01f9b072603cc385d7fcee1 (patch)
treedf2c768e59021f4877da624311a8f1cfc75610d5 /libnetwork
parent563fc92dd46794dd8b8f846896aceda60dc36d5c (diff)
downloaddocker-4e0319c87857f180b01f9b072603cc385d7fcee1.tar.gz
[chore] clean up reexec.Init() calls
Now that most uses of reexec have been replaced with non-reexec solutions, most of the reexec.Init() calls peppered throughout the test suites are unnecessary. Furthermore, most of the reexec.Init() calls in test code neglects to check the return value to determine whether to exit, which would result in the reexec'ed subprocesses proceeding to run the tests, which would reexec another subprocess which would proceed to run the tests, recursively. (That would explain why every reexec callback used to unconditionally call os.Exit() instead of returning...) Remove unneeded reexec.Init() calls from test and example code which no longer needs it, and fix the reexec.Init() calls which are not inert to exit after a reexec callback is invoked. Signed-off-by: Cory Snider <csnider@mirantis.com>
Diffstat (limited to 'libnetwork')
-rw-r--r--libnetwork/cmd/readme_test/readme.go5
-rw-r--r--libnetwork/drivers/bridge/port_mapping_test.go9
-rw-r--r--libnetwork/libnetwork_test.go11
-rw-r--r--libnetwork/osl/sandbox_linux_test.go8
4 files changed, 0 insertions, 33 deletions
diff --git a/libnetwork/cmd/readme_test/readme.go b/libnetwork/cmd/readme_test/readme.go
index 7e008a9aa9..80cfae3a6c 100644
--- a/libnetwork/cmd/readme_test/readme.go
+++ b/libnetwork/cmd/readme_test/readme.go
@@ -8,14 +8,9 @@ import (
"github.com/docker/docker/libnetwork/config"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/options"
- "github.com/docker/docker/pkg/reexec"
)
func main() {
- if reexec.Init() {
- return
- }
-
// Select and configure the network driver
networkType := "bridge"
diff --git a/libnetwork/drivers/bridge/port_mapping_test.go b/libnetwork/drivers/bridge/port_mapping_test.go
index dab375e96b..17d6e19b51 100644
--- a/libnetwork/drivers/bridge/port_mapping_test.go
+++ b/libnetwork/drivers/bridge/port_mapping_test.go
@@ -4,23 +4,14 @@
package bridge
import (
- "os"
"testing"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/ns"
"github.com/docker/docker/libnetwork/testutils"
"github.com/docker/docker/libnetwork/types"
- "github.com/docker/docker/pkg/reexec"
)
-func TestMain(m *testing.M) {
- if reexec.Init() {
- return
- }
- os.Exit(m.Run())
-}
-
func TestPortMappingConfig(t *testing.T) {
defer testutils.SetupTestOSContext(t)()
d := newDriver()
diff --git a/libnetwork/libnetwork_test.go b/libnetwork/libnetwork_test.go
index 3707952ab9..e3207d4f5c 100644
--- a/libnetwork/libnetwork_test.go
+++ b/libnetwork/libnetwork_test.go
@@ -10,7 +10,6 @@ import (
"net/http/httptest"
"os"
"path/filepath"
- "runtime"
"testing"
"github.com/docker/docker/libnetwork"
@@ -23,19 +22,9 @@ import (
"github.com/docker/docker/libnetwork/testutils"
"github.com/docker/docker/libnetwork/types"
"github.com/docker/docker/pkg/plugins"
- "github.com/docker/docker/pkg/reexec"
- "github.com/sirupsen/logrus"
)
func TestMain(m *testing.M) {
- if runtime.GOOS == "windows" {
- logrus.Info("Test suite does not currently support windows")
- os.Exit(0)
- }
- if reexec.Init() {
- return
- }
-
// Cleanup local datastore file
_ = os.Remove(datastore.DefaultScope("").Client.Address)
diff --git a/libnetwork/osl/sandbox_linux_test.go b/libnetwork/osl/sandbox_linux_test.go
index acda5eee9e..0dd8b1e8a5 100644
--- a/libnetwork/osl/sandbox_linux_test.go
+++ b/libnetwork/osl/sandbox_linux_test.go
@@ -15,7 +15,6 @@ import (
"github.com/docker/docker/libnetwork/ns"
"github.com/docker/docker/libnetwork/testutils"
"github.com/docker/docker/libnetwork/types"
- "github.com/docker/docker/pkg/reexec"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netlink/nl"
"github.com/vishvananda/netns"
@@ -382,13 +381,6 @@ func TestLiveRestore(t *testing.T) {
}
}
-func TestMain(m *testing.M) {
- if reexec.Init() {
- return
- }
- os.Exit(m.Run())
-}
-
func TestSandboxCreate(t *testing.T) {
defer testutils.SetupTestOSContext(t)()