8 "github.com/edwarnicke/exechelper"
9 "github.com/stretchr/testify/assert"
10 "github.com/stretchr/testify/suite"
13 type HstSuite struct {
16 containers []*Container
20 func (s *HstSuite) TearDownSuite() {
26 func (s *HstSuite) hstFail() {
30 func (s *HstSuite) assertNil(object interface{}, msgAndArgs ...interface{}) {
31 if !assert.Nil(s.T(), object, msgAndArgs...) {
36 func (s *HstSuite) assertNotNil(object interface{}, msgAndArgs ...interface{}) {
37 if !assert.NotNil(s.T(), object, msgAndArgs...) {
42 func (s *HstSuite) assertEqual(expected, actual interface{}, msgAndArgs ...interface{}) {
43 if !assert.Equal(s.T(), expected, actual, msgAndArgs...) {
48 func (s *HstSuite) assertNotEqual(expected, actual interface{}, msgAndArgs ...interface{}) {
49 if !assert.NotEqual(s.T(), expected, actual, msgAndArgs...) {
54 func (s *HstSuite) assertContains(testString, contains interface{}, msgAndArgs ...interface{}) {
55 if !assert.Contains(s.T(), testString, contains, msgAndArgs...) {
60 func (s *HstSuite) assertNotContains(testString, contains interface{}, msgAndArgs ...interface{}) {
61 if !assert.NotContains(s.T(), testString, contains, msgAndArgs...) {
66 func (s *HstSuite) NewContainer(name string) (*Container, error) {
68 return nil, fmt.Errorf("creating container failed: name must not be blank")
71 container := new(Container)
74 s.containers = append(s.containers, container)
79 func (s *HstSuite) StopContainers() {
80 for _, container := range s.containers {
85 func (s *HstSuite) NewVolume(name string) error {
86 err := exechelper.Run(fmt.Sprintf("docker volume create --name=%s", name))
91 s.volumes = append(s.volumes, name)
95 func (s *HstSuite) RemoveVolumes() {
96 for _, volumeName := range s.volumes {
97 exechelper.Run("docker volume rm " + volumeName)
101 type TapSuite struct {
105 func (s *TapSuite) SetupSuite() {
106 time.Sleep(1 * time.Second)
107 s.teardownSuite = setupSuite(&s.Suite, "tap")
110 type VethsSuite struct {
114 func (s *VethsSuite) SetupSuite() {
115 time.Sleep(1 * time.Second)
116 s.teardownSuite = setupSuite(&s.Suite, "2peerVeth")
119 type NsSuite struct {
123 func (s *NsSuite) SetupSuite() {
124 s.teardownSuite = setupSuite(&s.Suite, "ns")
127 func setupSuite(s *suite.Suite, topologyName string) func() {
129 topology, err := LoadTopology(TopologyDir, topologyName)
131 t.Fatalf("error on loading topology '%s': %v", topologyName, err)
133 err = topology.Configure()
135 t.Fatalf("failed to configure %s: %v", topologyName, err)
138 t.Logf("topo %s loaded", topologyName)
140 topology.Unconfigure()
144 func TestTapSuite(t *testing.T) {
149 func TestNs(t *testing.T) {
154 func TestVeths(t *testing.T) {