mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-09 14:41:31 +02:00
This includes a healthy refactor of the networkd code as well. - Move netlink functionality to nic package - Networkd facilitates the orchestration of the underlying interface configuration - Networkd now stores the state of each interface configuration. This should allow us to expose this information via api in the future. Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
108 lines
2.1 KiB
Go
108 lines
2.1 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package nic
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/talos-systems/talos/internal/app/networkd/pkg/address"
|
|
)
|
|
|
|
type NicSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func TestNicSuite(t *testing.T) {
|
|
suite.Run(t, new(NicSuite))
|
|
}
|
|
|
|
func (suite *NicSuite) TestIgnoreNic() {
|
|
mynic, err := New(WithName("yolo"), WithIgnore())
|
|
|
|
suite.Require().NoError(err)
|
|
suite.Assert().True(mynic.IsIgnored())
|
|
}
|
|
|
|
func (suite *NicSuite) TestNoName() {
|
|
_, err := New()
|
|
suite.Require().Error(err)
|
|
}
|
|
|
|
func (suite *NicSuite) TestBond() {
|
|
testSettings := [][]Option{
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("balance-xor"),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("802.3ad"),
|
|
WithHashPolicy("layer3+4"),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("balance-tlb"),
|
|
WithHashPolicy("encap3+4"),
|
|
WithLACPRate("fast"),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("balance-alb"),
|
|
WithHashPolicy("encap2+3"),
|
|
WithLACPRate("slow"),
|
|
WithUpDelay(200),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("broadcast"),
|
|
WithHashPolicy("layer2+3"),
|
|
WithLACPRate("fast"),
|
|
WithUpDelay(300),
|
|
WithDownDelay(400),
|
|
WithMIIMon(500),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("balance-rr"),
|
|
WithHashPolicy("layer2"),
|
|
WithLACPRate("slow"),
|
|
WithUpDelay(300),
|
|
WithDownDelay(400),
|
|
WithMIIMon(500),
|
|
WithSubInterface("lo", "lo"),
|
|
},
|
|
{
|
|
WithName("yolobond"),
|
|
WithBond(true),
|
|
WithBondMode("active-backup"),
|
|
WithHashPolicy("layer2"),
|
|
WithLACPRate("slow"),
|
|
WithUpDelay(300),
|
|
WithDownDelay(400),
|
|
WithMIIMon(500),
|
|
WithSubInterface("lo", "lo"),
|
|
WithAddressing(&address.Static{}),
|
|
},
|
|
}
|
|
|
|
for _, test := range testSettings {
|
|
mynic, err := New(test...)
|
|
suite.Require().NoError(err)
|
|
suite.Assert().True(mynic.Bonded)
|
|
}
|
|
}
|