diff --git a/dev_env_data/clab/integration-tests.yaml b/dev_env_data/clab/integration-tests.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d21b3f352cdd7fda5336b32d3cbbb3b458396411 --- /dev/null +++ b/dev_env_data/clab/integration-tests.yaml @@ -0,0 +1,125 @@ +name: gosdn_csbi_arista_base + +mgmt: + network: gosdn-csbi-arista-base-net + ipv4-subnet: 172.100.0.0/16 + ipv6-subnet: 2001:db8::/64 + mtu: 1500 + +topology: + nodes: + + plugin-registry: + kind: linux + image: plugin-registry + mgmt-ipv4: 172.100.0.16 + + gosdn: + kind: linux + image: gosdn + ports: + - 55055:55055 + - 8080:8080 + - 40000:40000 + cmd: + --config /app/configs/containerlab-gosdn.toml + mgmt-ipv4: 172.100.0.5 + env: + GOSDN_ADMIN_PASSWORD: TestPassword + binds: + - ../../artifacts/ssl/gosdn:/app/ssl + stages: + create: + wait-for: + - node: rabbitmq + stage: healthy + # Uncomment section if the endless loop in the creation process is investigated and fixed + # - node: gnmi-target_A + # stage: created + # - node: gnmi-target_B + # stage: created + # - node: mongodb + # stage: created + # - node: plugin-registry + # stage: created + + gnmi-target_A: + kind: linux + image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master + #only for local use + #image: gnmi-target:latest + binds: + - ../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl + ports: + - 3919:7030 + cmd: + start --ca_file /etc/gnmi-target/ssl/ca.crt --cert /etc/gnmi-target/ssl/certs/gnmi-target-selfsigned.crt --key /etc/gnmi-target/ssl/private/gnmi-target-selfsigned.key + mgmt-ipv4: 172.100.0.11 + startup-delay: 5 + + gnmi-target_B: + kind: linux + image: registry.code.fbi.h-da.de/danet/gnmi-target/debian:master + #only for local use + #image: gnmi-target:latest + binds: + - ../../artifacts/ssl/gnmi-target:/etc/gnmi-target/ssl + ports: + - 3920:7030 + cmd: + start --ca_file /etc/gnmi-target/ssl/ca.crt --cert /etc/gnmi-target/ssl/certs/gnmi-target-selfsigned.crt --key /etc/gnmi-target/ssl/private/gnmi-target-selfsigned.key + mgmt-ipv4: 172.100.0.12 + startup-delay: 5 + + centos0: + kind: linux + image: centos:8 + mgmt-ipv4: 172.100.0.3 + group: server + + centos1: + kind: linux + image: centos:8 + mgmt-ipv4: 172.100.0.4 + group: server + + mongodb: + kind: linux + image: mongo:7 + ports: + - 27017:27017 + env: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + mgmt-ipv4: 172.100.0.13 + + mongodb-express: + kind: linux + image: mongo-express:0.54.0 + ports: + - 8081:8081 + env: + ME_CONFIG_MONGODB_ADMINUSERNAME: root + ME_CONFIG_MONGODB_ADMINPASSWORD: example + ME_CONFIG_MONGODB_SERVER: mongodb + mgmt-ipv4: 172.100.0.14 + + rabbitmq: + kind: linux + image: rabbitmq:3-management + ports: + - 127.0.0.1:5672:5672 + - 127.0.0.1:15672:15672 + mgmt-ipv4: 172.100.0.15 + healthcheck: + test: + - CMD-SHELL + - rabbitmq-diagnostics -q ping + interval: 30 + timeout: 10 + retries: 5 + + links: + - endpoints: ["gnmi-target_A:eth1","gnmi-target_B:eth1"] + - endpoints: ["gnmi-target_A:eth2","centos0:eth1"] + - endpoints: ["gnmi-target_B:eth2","centos1:eth1"] diff --git a/integration-tests/lab_tests/lab01/lab01_test.go b/integration-tests/lab_tests/lab01/lab01_test.go index efa0e43ad0d8c5637b521f7acac4f73e814da829..3b5b63fe73491bb46087ad6592d73300e730c224 100644 --- a/integration-tests/lab_tests/lab01/lab01_test.go +++ b/integration-tests/lab_tests/lab01/lab01_test.go @@ -28,7 +28,7 @@ const ( targetBInterfacePathEth1 = "switch1/s1-eth1.json" targetBInterfacePathEth2 = "switch1/s1-eth2.json" targetBRoutePath = "switch1/s1-route.json" - relativePathToJSONSources = "../utils/json_sources/Lab01" + relativePathToJSONSources = "../utils/json_sources/Lab01/" ) // Represents the yang models stored in JSON files. @@ -36,7 +36,7 @@ const ( type configEntry struct { leaf string path string - value string + value []byte } // Represents the managed network elements. @@ -148,7 +148,7 @@ func TestLab01(t *testing.T) { // Cast JSON config files into strings for _, mne := range managedNetworkElements { for i := 0; i < len(mne.configEntries); i++ { - jsonValue, err := lab_utils.FileContentToString(relativePathToJSONSources + mne.configEntries[i].path) + jsonValue, err := lab_utils.ParseFileContent(relativePathToJSONSources + mne.configEntries[i].path) if err != nil { t.Error(err) } diff --git a/integration-tests/lab_tests/utils/json_sources/Lab01/switch0/s0-eth1.json b/integration-tests/lab_tests/utils/json_sources/Lab01/switch0/s0-eth1.json index 53aac83b93737fd7fc1ab4d28b4cfda1e9f64cd6..7c42ff3fd547b2aa9528f68cdb7e236d792018bf 100644 --- a/integration-tests/lab_tests/utils/json_sources/Lab01/switch0/s0-eth1.json +++ b/integration-tests/lab_tests/utils/json_sources/Lab01/switch0/s0-eth1.json @@ -1,36 +1,36 @@ { - "openconfig-interfaces:config":{ - "enabled":true, - "loopback-mode":false, - "mtu":1500, - "name":"eth1" - }, - "openconfig-interfaces:name":"eth1", - "openconfig-interfaces:subinterfaces":{ - "subinterface":[ - { - "config":{ - "enabled":true, - "index":0 - }, - "index":0, - "openconfig-if-ip:ipv4":{ - "addresses":{ - "address":[ - { - "config":{ - "ip":"10.50.0.1", - "prefix-length":30 - }, - "ip":"10.50.0.1" - } - ] - }, - "config":{ - "enabled":true - } - } - } - ] - } -} + "openconfig-interfaces:config":{ + "enabled":true, + "loopback-mode":false, + "mtu":1500, + "name":"eth1" + }, + "openconfig-interfaces:name":"eth1", + "openconfig-interfaces:subinterfaces":{ + "subinterface":[ + { + "config":{ + "enabled":true, + "index":0 + }, + "index":0, + "openconfig-if-ip:ipv4":{ + "addresses":{ + "address":[ + { + "config":{ + "ip":"10.50.0.1", + "prefix-length":30 + }, + "ip":"10.50.0.1" + } + ] + }, + "config":{ + "enabled":true + } + } + } + ] + } + } \ No newline at end of file diff --git a/integration-tests/lab_tests/utils/labUtils.go b/integration-tests/lab_tests/utils/labUtils.go index a3c30e08adabe44c6d201f22b934e8c00937c9a9..19e23b91c3116d0cb97762f02412885cfd99d799 100644 --- a/integration-tests/lab_tests/utils/labUtils.go +++ b/integration-tests/lab_tests/utils/labUtils.go @@ -105,7 +105,7 @@ func CreateAddListRequestSingleMne(addr, name, id, username, password string, pn return alr } -func SetInterfacePathListRequestSingleMne(networkInterface string, mneId string, operation mnepb.ApiOperation, newInterfaceConfig string, pndID string) (*mnepb.SetPathListRequest, error) { +func SetInterfacePathListRequestSingleMne(networkInterface 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) @@ -113,6 +113,13 @@ func SetInterfacePathListRequestSingleMne(networkInterface string, mneId string, return nil, err } + // Create the yang path + typedValue := &gnmi.TypedValue{ + Value: &gnmi.TypedValue_JsonIetfVal{ + JsonIetfVal: newInterfaceConfig, + }, + } + // Create PathListRequest splr := &mnepb.SetPathListRequest{ Timestamp: integration_test_utils.GetTimestamp(), @@ -120,24 +127,18 @@ func SetInterfacePathListRequestSingleMne(networkInterface string, mneId string, { Mneid: mneId, Path: interfacePath, - Value: &gnmi.TypedValue{ - Value: &gnmi.TypedValue_StringVal{ - StringVal: newInterfaceConfig, - }, - }, + Value: typedValue, ApiOp: operation, }, }, } - return splr, nil } -func FileContentToString(path string) (string, error) { +func ParseFileContent(path string) ([]byte, error) { fileContent, err := os.ReadFile(path) if err != nil { - return "", err + return nil, err } - - return string(fileContent), nil + return fileContent, nil } diff --git a/makefiles/clab/Makefile b/makefiles/clab/Makefile index 3280e90d4f52c8285027c74d2c4824b35e1aa70b..ced8dc85084a0899962f19a4d327c6ff9429642b 100644 --- a/makefiles/clab/Makefile +++ b/makefiles/clab/Makefile @@ -30,3 +30,13 @@ containerlab-slim-stop: create-clab-dir containerlab-graph: create-clab-dir cd $(CLAB_DIR) &&\ sudo containerlab graph --topo $(MAKEFILE_DIR)dev_env_data/clab/gosdn.clab.yaml + +# TODO fix gitlab test ci/cd runner - must use containerlab image + +containerlab-integration-tests-start: create-clab-dir containerize-all generate-all-certs + cd $(CLAB_DIR) &&\ + sudo containerlab deploy --topo $(MAKEFILE_DIR)dev_env_data/clab/integration-tests.yaml --log-level debug + +containerlab-integration-tests-stop: create-clab-dir + cd $(CLAB_DIR) &&\ + sudo containerlab destroy --topo $(MAKEFILE_DIR)dev_env_data/clab/integration-tests.yaml