Skip to content
Snippets Groups Projects
Commit 23be9eee authored by Katharina Renk's avatar Katharina Renk
Browse files

func SetPathListRequestFromJsonImport can now process all paths

parent b9328cf3
No related branches found
No related tags found
2 merge requests!784Draft: Resolve "Integration test for Lab01",!757Draft: Resolve "Integration test for Lab01"
......@@ -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.
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment