github.com/pingcap/chaos@v0.0.0-20190710112158-c86faf4b3719/pkg/util/net/iptables_test.go (about)

     1  package net
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  )
     7  
     8  func TestIPTables(t *testing.T) {
     9  	t.Log("test can only be run in the chaos docker")
    10  
    11  	iptables := IPTables{}
    12  	ctx := context.Background()
    13  
    14  	// should apt-get install iptables manually.
    15  	if err := iptables.Drop(ctx, "n1", "n2"); err != nil {
    16  		t.Fatalf("drop network failed %v", err)
    17  	}
    18  
    19  	if err := iptables.Heal(ctx, "n1"); err != nil {
    20  		t.Fatalf("heal netwrok failed %v", err)
    21  	}
    22  
    23  	if err := iptables.Fast(ctx, "n1"); err != nil {
    24  		t.Fatalf("fast netwrok failed %v", err)
    25  	}
    26  
    27  	if err := iptables.Slow(ctx, "n1", DefaultSlowOptions()); err != nil {
    28  		t.Fatalf("slow netwrok failed %v", err)
    29  	}
    30  
    31  	if err := iptables.Fast(ctx, "n1"); err != nil {
    32  		t.Fatalf("fast netwrok failed %v", err)
    33  	}
    34  
    35  	if err := iptables.Flaky(ctx, "n1"); err != nil {
    36  		t.Fatalf("flaky netwrok failed %v", err)
    37  	}
    38  
    39  	if err := iptables.Fast(ctx, "n1"); err != nil {
    40  		t.Fatalf("fast netwrok failed %v", err)
    41  	}
    42  }