diff options
author | Maros Ondrejicka <mondreji@cisco.com> | 2023-02-07 20:40:27 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-02-10 05:23:32 +0000 |
commit | 7550dd268f80334cbb9127feefe35319b9c7e572 (patch) | |
tree | 08350b3d4dcf5453941312565c63303d95735903 /extras/hs-test/actions.go | |
parent | 2908f8cf07c21f385f80d83fdad826a0eea98977 (diff) |
hs-test: refactor test cases from no-topo suite
This converts remaining tests to configation of VPP from test context.
Type: test
Change-Id: I386714f6b290e03d1757c2a033a25fae0340f5d6
Signed-off-by: Maros Ondrejicka <mondreji@cisco.com>
Diffstat (limited to 'extras/hs-test/actions.go')
-rw-r--r-- | extras/hs-test/actions.go | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/extras/hs-test/actions.go b/extras/hs-test/actions.go deleted file mode 100644 index 9233e2d1ea2..00000000000 --- a/extras/hs-test/actions.go +++ /dev/null @@ -1,82 +0,0 @@ -package main - -import ( - "context" - "os" - - "git.fd.io/govpp.git/api" - interfaces "github.com/edwarnicke/govpp/binapi/interface" - "github.com/edwarnicke/govpp/binapi/interface_types" - ip_types "github.com/edwarnicke/govpp/binapi/ip_types" - "github.com/edwarnicke/govpp/binapi/session" - "github.com/edwarnicke/govpp/binapi/tapv2" - "github.com/edwarnicke/vpphelper" -) - -var ( - workDir, _ = os.Getwd() -) - -type ConfFn func(context.Context, api.Connection) error - -type Actions struct { -} - -func (a *Actions) ConfigureTap(args []string) *ActionResult { - var startup Stanza - startup. - NewStanza("session"). - Append("enable"). - Append("use-app-socket-api").Close() - - ctx, cancel := newVppContext() - defer cancel() - con, vppErrCh := vpphelper.StartAndDialContext(ctx, - vpphelper.WithRootDir(workDir), - vpphelper.WithVppConfig(configTemplate+startup.ToString())) - exitOnErrCh(ctx, cancel, vppErrCh) - ifaceClient := interfaces.NewServiceClient(con) - - pref, err := ip_types.ParseIP4Prefix("10.10.10.2/24") - if err != nil { - return NewActionResult(err, ActionResultWithDesc("failed to parse ip4 address")) - } - createTapReply, err := tapv2.NewServiceClient(con).TapCreateV2(ctx, &tapv2.TapCreateV2{ - HostIfNameSet: true, - HostIfName: "tap0", - HostIP4PrefixSet: true, - HostIP4Prefix: ip_types.IP4AddressWithPrefix(pref), - }) - if err != nil { - return NewActionResult(err, ActionResultWithDesc("failed to configure tap")) - } - ipPrefix, err := ip_types.ParseAddressWithPrefix("10.10.10.1/24") - if err != nil { - return NewActionResult(err, ActionResultWithDesc("parsing ip address failed")) - } - ipAddress := &interfaces.SwInterfaceAddDelAddress{ - IsAdd: true, - SwIfIndex: createTapReply.SwIfIndex, - Prefix: ipPrefix, - } - _, errx := ifaceClient.SwInterfaceAddDelAddress(ctx, ipAddress) - if errx != nil { - return NewActionResult(err, ActionResultWithDesc("configuring ip address failed")) - } - _, err = ifaceClient.SwInterfaceSetFlags(ctx, &interfaces.SwInterfaceSetFlags{ - SwIfIndex: createTapReply.SwIfIndex, - Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, - }) - if err != nil { - return NewActionResult(err, ActionResultWithDesc("failed to set interface state")) - } - _, err = session.NewServiceClient(con).SessionEnableDisable(ctx, &session.SessionEnableDisable{ - IsEnable: true, - }) - if err != nil { - return NewActionResult(err, ActionResultWithDesc("configuration failed")) - } - writeSyncFile(OkResult()) - <-ctx.Done() - return nil -} |