diff --git a/inttest/airgap/airgap_test.go b/inttest/airgap/airgap_test.go index 790f59fbf299..c503b441c495 100644 --- a/inttest/airgap/airgap_test.go +++ b/inttest/airgap/airgap_test.go @@ -39,20 +39,6 @@ type AirgapSuite struct { common.FootlooseSuite } -const network = "airgap" - -// SetupSuite creates the required network before starting footloose. -func (s *AirgapSuite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *AirgapSuite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - func (s *AirgapSuite) TestK0sGetsUp() { err := (&common.Airgap{ SSH: s.SSH, @@ -122,10 +108,8 @@ func (s *AirgapSuite) TestK0sGetsUp() { func TestAirgapSuite(t *testing.T) { s := AirgapSuite{ common.FootlooseSuite{ - ControllerCount: 1, - WorkerCount: 1, - ControllerNetworks: []string{network}, - WorkerNetworks: []string{network}, + ControllerCount: 1, + WorkerCount: 1, AirgapImageBundleMountPoints: []string{"/var/lib/k0s/images/bundle.tar"}, }, diff --git a/inttest/ap-airgap/airgap_test.go b/inttest/ap-airgap/airgap_test.go index b30eeb10e307..a53b090bdc3a 100644 --- a/inttest/ap-airgap/airgap_test.go +++ b/inttest/ap-airgap/airgap_test.go @@ -31,20 +31,6 @@ type airgapSuite struct { common.FootlooseSuite } -const network = "ap-airgap" - -// SetupSuite creates the required network before starting footloose. -func (s *airgapSuite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *airgapSuite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - // SetupTest prepares the controller and filesystem, getting it into a consistent // state which we can run tests against. func (s *airgapSuite) SetupTest() { @@ -157,9 +143,6 @@ func TestAirgapSuite(t *testing.T) { LaunchMode: common.LaunchModeOpenRC, AirgapImageBundleMountPoints: []string{"/dist/bundle.tar"}, - - ControllerNetworks: []string{network}, - WorkerNetworks: []string{network}, }, }) } diff --git a/inttest/ap-ha3x3/ha3x3_test.go b/inttest/ap-ha3x3/ha3x3_test.go index 92d9fa152ba6..fbe2ef71c7e9 100644 --- a/inttest/ap-ha3x3/ha3x3_test.go +++ b/inttest/ap-ha3x3/ha3x3_test.go @@ -40,20 +40,6 @@ spec: externalAddress: %s ` -const network = "ha3x3net" - -// SetupSuite creates the required network before starting footloose. -func (s *ha3x3Suite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *ha3x3Suite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - // SetupTest prepares the controller and filesystem, getting it into a consistent // state which we can run tests against. func (s *ha3x3Suite) SetupTest() { @@ -195,9 +181,6 @@ func TestHA3x3Suite(t *testing.T) { WorkerCount: 3, WithLB: true, LaunchMode: common.LaunchModeOpenRC, - - ControllerNetworks: []string{network}, - WorkerNetworks: []string{network}, }, }) } diff --git a/inttest/ap-quorum/quorum_test.go b/inttest/ap-quorum/quorum_test.go index de879d874d2d..5891a2171e39 100644 --- a/inttest/ap-quorum/quorum_test.go +++ b/inttest/ap-quorum/quorum_test.go @@ -38,20 +38,6 @@ spec: externalAddress: %s ` -const network = "quorumnet" - -// SetupSuite creates the required network before starting footloose. -func (s *quorumSuite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *quorumSuite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - // SetupTest prepares the controller and filesystem, getting it into a consistent // state which we can run tests against. func (s *quorumSuite) SetupTest() { @@ -152,9 +138,6 @@ func TestQuorumSuite(t *testing.T) { ControllerCount: 3, WorkerCount: 0, LaunchMode: common.LaunchModeOpenRC, - - ControllerNetworks: []string{network}, - WorkerNetworks: []string{network}, }, }) } diff --git a/inttest/ap-quorumsafety/quorumsafety_test.go b/inttest/ap-quorumsafety/quorumsafety_test.go index 1330a6f3210b..314df04ab707 100644 --- a/inttest/ap-quorumsafety/quorumsafety_test.go +++ b/inttest/ap-quorumsafety/quorumsafety_test.go @@ -38,20 +38,6 @@ spec: externalAddress: %s ` -const network = "quorumsafetynet" - -// SetupSuite creates the required network before starting footloose. -func (s *quorumSafetySuite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *quorumSafetySuite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - // SetupTest prepares the controller and filesystem, getting it into a consistent // state which we can run tests against. func (s *quorumSafetySuite) SetupTest() { @@ -163,9 +149,6 @@ func TestQuorumSafetySuite(t *testing.T) { ControllerCount: 2, WorkerCount: 0, LaunchMode: common.LaunchModeOpenRC, - - ControllerNetworks: []string{network}, - WorkerNetworks: []string{network}, }, }) } diff --git a/inttest/ap-selector/selector_test.go b/inttest/ap-selector/selector_test.go index f1023517c072..a9f973ec8d5b 100644 --- a/inttest/ap-selector/selector_test.go +++ b/inttest/ap-selector/selector_test.go @@ -39,20 +39,6 @@ spec: externalAddress: %s ` -const network = "selectornet" - -// SetupSuite creates the required network before starting footloose. -func (s *selectorSuite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *selectorSuite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - // SetupTest prepares the controller and filesystem, getting it into a consistent // state which we can run tests against. func (s *selectorSuite) SetupTest() { diff --git a/inttest/common/footloosesuite.go b/inttest/common/footloosesuite.go index 929706bafd05..e65b59e08220 100644 --- a/inttest/common/footloosesuite.go +++ b/inttest/common/footloosesuite.go @@ -105,9 +105,6 @@ type FootlooseSuite struct { K0smotronWorkerCount int WithUpdateServer bool K0sUpdateVersion string - ControllerNetworks []string - WorkerNetworks []string - K0smotronNetworks []string FootLooseImage string ctx context.Context @@ -608,13 +605,7 @@ func (s *FootlooseSuite) getControllersIPAddresses() []string { s.Require().NoError(err) for i := 0; i < s.ControllerCount; i++ { - // If a network is supplied, the address will need to be obtained from there. - // Note that this currently uses the first network found. - if machines[i].Status().IP != "" { - addresses[i] = machines[i].Status().IP - } else if len(machines[i].Status().RuntimeNetworks) > 0 { - addresses[i] = machines[i].Status().RuntimeNetworks[0].IP - } + addresses[i] = machines[i].Status().IP } return addresses } @@ -1196,7 +1187,6 @@ func (s *FootlooseSuite) initializeFootlooseClusterInDir(dir string) error { Privileged: true, Volumes: volumes, PortMappings: portMaps, - Networks: s.ControllerNetworks, }, }, { @@ -1207,7 +1197,6 @@ func (s *FootlooseSuite) initializeFootlooseClusterInDir(dir string) error { Privileged: true, Volumes: volumes, PortMappings: portMaps, - Networks: s.WorkerNetworks, }, }, { @@ -1218,7 +1207,6 @@ func (s *FootlooseSuite) initializeFootlooseClusterInDir(dir string) error { Privileged: true, Volumes: volumes, PortMappings: portMaps, - Networks: s.K0smotronNetworks, }, }, }, @@ -1233,7 +1221,6 @@ func (s *FootlooseSuite) initializeFootlooseClusterInDir(dir string) error { Volumes: volumes, PortMappings: portMaps, Ignite: nil, - Networks: s.ControllerNetworks, }, Count: 1, }) @@ -1265,7 +1252,6 @@ func (s *FootlooseSuite) initializeFootlooseClusterInDir(dir string) error { ContainerPort: 80, }, }, - Networks: s.ControllerNetworks, }, Count: 1, }) @@ -1351,39 +1337,6 @@ func (s *FootlooseSuite) getIPAddress(nodeName string) string { return ipAddress } -// CreateNetwork creates a docker network with the provided name, destroying -// any network that has the same name first. -func (s *FootlooseSuite) CreateNetwork(name string) error { - // Don't create the network if it already exists as it might be in use from previous tests - // ran with K0S_KEEP_AFTER_TEST variable set. - if s.NetworkExists(name) { - return nil - } - - cmd := exec.Command("docker", "network", "create", name) - return cmd.Run() -} - -// MaybeDestroyNetwork removes a docker network with the provided name. -// The network might not get removed if there's still containers attached to it. -// This is the case for example when running the tests with K0S_KEEP_AFTER_TEST=always. -func (s *FootlooseSuite) MaybeDestroyNetwork(name string) error { - // If we're supposed to leave the footloose containers running, don't try to destroy the network - if keepEnvironment(s.T()) { - return nil - } - cmd := exec.Command("docker", "network", "rm", name) - return cmd.Run() -} - -// NetworkExists returns true if a docker network with the provided name exists. -func (s *FootlooseSuite) NetworkExists(name string) bool { - cmd := exec.Command("docker", "network", "inspect", name) - err := cmd.Run() - - return err == nil -} - // RunCommandController runs a command via SSH on a specified controller node func (s *FootlooseSuite) RunCommandController(idx int, command string) (string, error) { ssh, err := s.SSH(s.Context(), s.ControllerNode(idx)) diff --git a/inttest/kubeletcertrotate/kubeletcertrotate_test.go b/inttest/kubeletcertrotate/kubeletcertrotate_test.go index 95fd5a311143..896de2320fa9 100644 --- a/inttest/kubeletcertrotate/kubeletcertrotate_test.go +++ b/inttest/kubeletcertrotate/kubeletcertrotate_test.go @@ -35,20 +35,6 @@ type kubeletCertRotateSuite struct { common.FootlooseSuite } -const network = "kubeletcertrotatenet" - -// SetupSuite creates the required network before starting footloose. -func (s *kubeletCertRotateSuite) SetupSuite() { - s.Require().NoError(s.CreateNetwork(network)) - s.FootlooseSuite.SetupSuite() -} - -// TearDownSuite tears down the network created after footloose has finished. -func (s *kubeletCertRotateSuite) TearDownSuite() { - s.FootlooseSuite.TearDownSuite() - s.Require().NoError(s.MaybeDestroyNetwork(network)) -} - type statusJSON struct { WorkerToAPIConnectionStatus status.ProbeStatus } @@ -189,9 +175,6 @@ func TestKubeletCertRotateSuite(t *testing.T) { ControllerCount: 1, WorkerCount: 1, LaunchMode: common.LaunchModeOpenRC, - - ControllerNetworks: []string{network}, - WorkerNetworks: []string{network}, }, }) }