From 23be9eeee815f983c5389f99de513c9a29eb80ac Mon Sep 17 00:00:00 2001 From: Katharina Renk <katharina.renk@stud.h-da.de> Date: Mon, 26 Feb 2024 22:45:59 +0100 Subject: [PATCH] func SetPathListRequestFromJsonImport can now process all paths --- .../lab_tests/lab01/lab01_test.go | 23 ++++++++++++++----- integration-tests/lab_tests/utils/labUtils.go | 6 ++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/integration-tests/lab_tests/lab01/lab01_test.go b/integration-tests/lab_tests/lab01/lab01_test.go index 3b5b63fe7..133fac764 100644 --- a/integration-tests/lab_tests/lab01/lab01_test.go +++ b/integration-tests/lab_tests/lab01/lab01_test.go @@ -29,6 +29,8 @@ const ( targetBInterfacePathEth2 = "switch1/s1-eth2.json" targetBRoutePath = "switch1/s1-route.json" relativePathToJSONSources = "../utils/json_sources/Lab01/" + pathToRouteConfig = "network-instances/network-instance" + pathToInterfaceConfig = "interfaces/interface" ) // Represents the yang models stored in JSON files. @@ -161,7 +163,7 @@ func TestLab01(t *testing.T) { for i := 0; i < len(mne.configEntries); i++ { // Interface change request if strings.Contains(mne.configEntries[i].leaf, "eth") { - interfacePathListRequest, err := lab_utils.SetInterfacePathListRequestSingleMne(mne.configEntries[i].leaf, mne.id, mnepb.ApiOperation_API_OPERATION_UPDATE, mne.configEntries[i].value, pndID) + interfacePathListRequest, err := lab_utils.SetPathListRequestFromJsonImport(pathToInterfaceConfig, mne.configEntries[i].leaf, mne.id, mnepb.ApiOperation_API_OPERATION_UPDATE, mne.configEntries[i].value, pndID) if err != nil { t.Error(err) } @@ -178,17 +180,26 @@ func TestLab01(t *testing.T) { // Route change request } else if strings.Contains(mne.configEntries[i].leaf, "route") { - fmt.Println("to be continued") + routePathListRequest, err := lab_utils.SetPathListRequestFromJsonImport(pathToRouteConfig, mne.configEntries[i].leaf, mne.id, mnepb.ApiOperation_API_OPERATION_UPDATE, mne.configEntries[i].value, pndID) + if err != nil { + t.Error(err) + } + setResp, err := mneService.SetPathList(ctx, routePathListRequest) + if err != nil { + t.Error(err) + } + + // Force-push changes + err = lab_utils.ForcePush(setResp.GetResponses()[0].GetId(), pndID, mneService, ctx) + if err != nil { + t.Error(err) + } } } } - // Commit Confirm - // Check if the network interface has been changed - // Modify the routing configuration of both managed network elements. - // Check if the routing configuration has been changed // Ping to check connection between both managed network elements. diff --git a/integration-tests/lab_tests/utils/labUtils.go b/integration-tests/lab_tests/utils/labUtils.go index 1a2d94cd3..ceb960871 100644 --- a/integration-tests/lab_tests/utils/labUtils.go +++ b/integration-tests/lab_tests/utils/labUtils.go @@ -104,10 +104,10 @@ func CreateAddListRequestSingleMne(addr, name, id, username, password string, pn return alr } -func SetInterfacePathListRequestSingleMne(networkInterface string, mneId string, operation mnepb.ApiOperation, newInterfaceConfig []byte, pndID string) (*mnepb.SetPathListRequest, error) { +func SetPathListRequestFromJsonImport(pathToLeaf string, leaf string, mneId string, operation mnepb.ApiOperation, newInterfaceConfig []byte, pndID string) (*mnepb.SetPathListRequest, error) { // Extract network interface - interfacePathString := "interfaces/interface[name=" + networkInterface + "]" - interfacePath, err := ygot.StringToStructuredPath(interfacePathString) + completePathToLeaf := pathToLeaf + "[name=" + leaf + "]" + interfacePath, err := ygot.StringToStructuredPath(completePathToLeaf) if err != nil { return nil, err } -- GitLab