Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): add federated integ test for multi-ue to ci #13243

Merged
merged 5 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docusaurus/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
"feg/docker_setup": {
"title": "FeG Docker Setup"
},
"feg/s1ap_federated_test": {
"title": "S1AP Federated Integration Test"
"feg/s1ap_federated_tests": {
"title": "S1AP Federated Integration Tests"
},
"feg/session_proxy": {
"title": "feg/session_proxy"
Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
"label": "Federation Gateway",
"ids": [
"feg/dev_testing",
"feg/s1ap_federated_test"
"feg/s1ap_federated_tests"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
---
id: s1ap_federated_test
title: S1AP Federated Integration Test
id: s1ap_federated_tests
title: S1AP Federated Integration Tests
hide_title: true
---

# S1AP Federated Integration Test
# S1AP Federated Integration Tests

The S1AP Integration Test only tests the AGW. The objective of the **S1AP
Federated Integration Test** is to provide a test platform
to run Magma with all of its components. That is, an end-to-end test with all
Federated Integration Tests** is to provide a test platform
to run Magma with all of its components. That is, end-to-end tests with all
components of Magma: AGW, Orc8r and FeG.

Currently, this test is in an experimental phase, so we are only testing the connectivity of
AGW - Orc8r - FeG, and we are able to run an attach/detach test using the S1AP tester
Currently, these tests are in an experimental phase, so we are only testing the connectivity of
AGW - Orc8r - FeG, and we are able to run the following tests using the S1AP tester
and our mock HSS.

- An attach/detach test
- An attach/detach test with multiple UEs (for 32 UEs)

## Architecture

As the diagram indicates, this test spins up **AGW**, **FeG**, and **Orc8r**
and uses `S1AP` and `magma_trfserver` as an eNb and SGi emulator to run tests.
As the diagram indicates, these tests spin up **AGW**, **FeG**, and **Orc8r**
and use `S1AP` and `magma_trfserver` as an eNb and SGi emulator to run tests.

```mermaid
graph LR;
Expand Down Expand Up @@ -57,6 +60,7 @@ This script will
- Configure Orc8r with AGW and FeG
- Run connectivity tests between all three components
- Run a basic attach/detach test
- Run an attach/detach test with multiple UEs (for 32 UEs)

To execute the script, run:

Expand Down Expand Up @@ -111,7 +115,7 @@ vagrant up magma_test
vagrant up magma_trfserver
```

You can then [run the test manually](#run-test-manually).
You can then [run the tests manually](#run-tests-manually).

### Manual build

Expand Down Expand Up @@ -186,19 +190,23 @@ cd magma/lte/gateway
vagrant up magma_trfserver
```

#### Run test manually
#### Run tests manually

Once you have built all of the VMs, you can try to run the test from the
`magma_test` VM. It is a simple attach-detach test:
Once you have built all of the VMs, you can try to run the tests from the
`magma_test` VM.

```bash
cd magma/lte/gateway
vagrant ssh magma_test

# inside vagrant vm
cd magma/lte/gateway/python/integ_tests
make integ_test TESTS=federated_tests/s1aptests/test_attach_detach.py
## Individual test(s), e.g.:
make fed_integ_test TESTS=federated_tests/s1aptests/test_attach_detach.py

## All tests
make fed_integ_test

# once the test is done, you can exit the vagrant vm
# once the tests are done, you can exit the vagrant vm
exit
```
18 changes: 12 additions & 6 deletions lte/gateway/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def federated_integ_test(
)
execute(_make_integ_tests)
sleep(20)
execute(run_integ_tests, "federated_tests/s1aptests/test_attach_detach.py")
execute(run_integ_tests, federated_mode=True)


def integ_test(
Expand Down Expand Up @@ -381,7 +381,7 @@ def integ_test(
env.hosts = [gateway_host]


def run_integ_tests(tests=None):
def run_integ_tests(tests=None, federated_mode=False):
"""
Function is required to run tests only in pre-configured Jenkins env.

Expand All @@ -394,17 +394,19 @@ def run_integ_tests(tests=None):

In case of selecting specific test like follows:
$ fab run_integ_tests:tests=s1aptests/test_attach_detach.py
$ fab run_integ_tests:tests=federated_tests/s1aptests/test_attach_detach.py,federated_mode=True

The specific test will be executed as a result of the execution of following
command in test machine:
$ make integ_test TESTS=s1aptests/test_attach_detach.py
$ make fed_integ_test TESTS=federated_tests/s1aptests/test_attach_detach.py
"""
test_host = vagrant_setup("magma_test", destroy_vm=False)
gateway_ip = '192.168.60.142'
if tests:
tests = "TESTS=" + tests

execute(_run_integ_tests, gateway_ip, tests)
execute(_run_integ_tests, gateway_ip, tests, federated_mode)


def get_test_summaries(
Expand Down Expand Up @@ -718,7 +720,7 @@ def _make_integ_tests():
run('make')


def _run_integ_tests(gateway_ip='192.168.60.142', tests=None):
def _run_integ_tests(gateway_ip='192.168.60.142', tests=None, federated_mode=False):
""" Run the integration tests

For now, just run a single basic test
Expand All @@ -728,6 +730,10 @@ def _run_integ_tests(gateway_ip='192.168.60.142', tests=None):
port = env.hosts[0].split(':')[1]
key = env.key_filename
tests = tests or ''
test_mode = 'integ_test'
if federated_mode:
test_mode = 'fed_integ_test'

"""
NOTE: the s1aptester produces a bunch of output which the python ssh
library, and thus fab, has trouble processing quickly. Instead, we manually
Expand All @@ -750,8 +756,8 @@ def _run_integ_tests(gateway_ip='192.168.60.142', tests=None):
' sudo ethtool --offload eth1 rx off tx off; sudo ethtool --offload eth2 rx off tx off;'
' source ~/build/python/bin/activate;'
' export GATEWAY_IP=%s;'
' make -i integ_test enable-flaky-retry=true %s\''
% (key, host, port, gateway_ip, tests),
' make -i %s enable-flaky-retry=true %s\''
% (key, host, port, gateway_ip, test_mode, tests),
)


Expand Down
10 changes: 10 additions & 0 deletions lte/gateway/python/integ_tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ else
$(foreach test,$(EXTENDED_TESTS) $(PRECOMMIT_TESTS),$(call execute_test,$(test));)
endif

.PHONY: fed_integ_test
fed_integ_test: $(PYTHON_BUILD)/setupinteg_env $(BIN)/pytest
. $(PYTHON_BUILD)/bin/activate
ifdef TESTS
$(call execute_test,$(TESTS))
else
echo "pass" > $(MAGMA_ROOT)/test_status.txt
$(foreach test,$(FEDERATED_TESTS),$(call execute_test,$(test));)
endif

.PHONY: nonsanity
nonsanity: $(PYTHON_BUILD)/setupinteg_env $(BIN)/pytest
. $(PYTHON_BUILD)/bin/activate
Expand Down
4 changes: 4 additions & 0 deletions lte/gateway/python/integ_tests/defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ s1aptests/test_restore_config_after_non_sanity.py
# s1aptests/test_enb_complete_reset.py \ GitHubIssue 12583
#---------------

# Add the s1aptester integration tests with federation gateway
FEDERATED_TESTS = federated_tests/s1aptests/test_attach_detach.py \
federated_tests/s1aptests/test_attach_detach_multi_ue.py

CLOUD_TESTS = cloud_tests/checkin_test.py \
cloud_tests/metrics_export_test.py \
cloud_tests/config_test.py
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Copyright 2022 The Magma Authors.

This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import sys

sys.path.append("./s1aptests")

import unittest

import s1ap_types
from integ_tests.s1aptests import s1ap_wrapper


class TestAttachDetachMultiUe(unittest.TestCase):

def setUp(self):
self._s1ap_wrapper = s1ap_wrapper.TestWrapper(federated_mode=True)

def tearDown(self):
self._s1ap_wrapper.cleanup()

def test_attach_detach_multi_ue(self):
""" Same as attach detach but for 32 UEs """
ue_ids = []
num_ues = 32
self._s1ap_wrapper.configUEDevice(num_ues)
for _ in range(num_ues):
req = self._s1ap_wrapper.ue_req
print(
"************************* Calling attach for UE id ",
req.ue_id,
)
self._s1ap_wrapper.s1_util.attach(
req.ue_id,
s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST,
s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND,
s1ap_types.ueAttachAccept_t,
)
# Wait on EMM Information from MME
self._s1ap_wrapper._s1_util.receive_emm_info()
ue_ids.append(req.ue_id)

for ue in ue_ids:
print("************************* Calling detach for UE id ", ue)
self._s1ap_wrapper.s1_util.detach(
ue,
s1ap_types.ueDetachType_t.UE_NORMAL_DETACH.value,
)


if __name__ == "__main__":
unittest.main()