Pau Espin Pedrol | bc1ed88 | 2018-05-17 16:59:58 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | import os |
| 3 | from mako.template import Template |
| 4 | |
| 5 | from osmo_gsm_tester.testenv import * |
| 6 | |
| 7 | hlr_dummy = suite.hlr() |
| 8 | mgw_dummy = suite.mgw() |
| 9 | stp_dummy = suite.stp() |
| 10 | msc_dummy = suite.msc(hlr_dummy, mgw_dummy, stp_dummy) |
| 11 | ggsn_dummy = suite.ggsn() |
| 12 | sgsn_dummy = suite.sgsn(hlr_dummy, ggsn_dummy) |
| 13 | bsc = suite.bsc(msc_dummy, mgw_dummy, stp_dummy) |
| 14 | bts = suite.bts() |
| 15 | osmocon = suite.osmocon() |
| 16 | |
| 17 | bts.set_num_trx(1) |
| 18 | bts.set_trx_phy_channel(0, 0, 'CCCH+SDCCH4') |
| 19 | bts.set_trx_phy_channel(0, 1, 'TCH/F') |
| 20 | bts.set_trx_phy_channel(0, 2, 'TCH/F') |
| 21 | bts.set_trx_phy_channel(0, 3, 'TCH/F_PDCH') |
| 22 | bts.set_trx_phy_channel(0, 4, 'TCH/F_TCH/H_PDCH') |
| 23 | bts.set_trx_phy_channel(0, 5, 'TCH/H') |
| 24 | bts.set_trx_phy_channel(0, 6, 'SDCCH8') |
| 25 | bts.set_trx_phy_channel(0, 7, 'PDCH') |
| 26 | |
| 27 | print('Starting CNI') |
| 28 | hlr_dummy.start() |
| 29 | stp_dummy.start() |
| 30 | msc_dummy.start() |
| 31 | mgw_dummy.start() |
| 32 | |
| 33 | bsc.set_rsl_ip('172.18.9.10') |
| 34 | bsc.bts_add(bts) |
| 35 | sgsn_dummy.bts_add(bts) |
| 36 | |
| 37 | bsc.start() |
| 38 | bts.start(keepalive=True) |
| 39 | |
| 40 | print('Starting osmocon') |
| 41 | osmocon.start() |
| 42 | |
| 43 | own_dir = os.path.dirname(os.path.realpath(__file__)) |
| 44 | script_file = os.path.join(own_dir, 'scripts', 'run_ttcn3_docker.sh') |
| 45 | bts_tmpl_file = os.path.join(own_dir, 'scripts', 'BTS_Tests.cfg.tmpl') |
| 46 | script_run_dir = test.get_run_dir().new_dir('ttcn3') |
| 47 | bts_cfg_file = os.path.join(str(script_run_dir), 'BTS_Tests.cfg') |
| 48 | junit_ttcn3_dst_file = os.path.join(str(suite.trial.get_run_dir()), 'trial-') + suite.name() + '.xml' |
Pau Espin Pedrol | f616614 | 2018-10-11 17:49:34 +0200 | [diff] [blame^] | 49 | if bts.bts_type() == 'osmo-bts-trx': |
| 50 | pcu_available = True |
| 51 | pcu_sk = bts.pcu_socket_path() |
| 52 | else: # PCU unix socket not available locally |
| 53 | pcu_available = False |
| 54 | pcu_sk = '' |
| 55 | docker_cmd = (script_file, str(script_run_dir), junit_ttcn3_dst_file, osmocon.l2_socket_path(), pcu_sk) |
Pau Espin Pedrol | bc1ed88 | 2018-05-17 16:59:58 +0200 | [diff] [blame] | 56 | |
| 57 | print('Creating template') |
| 58 | mytemplate = Template(filename=bts_tmpl_file) |
Pau Espin Pedrol | f616614 | 2018-10-11 17:49:34 +0200 | [diff] [blame^] | 59 | r = mytemplate.render(btsvty_ctrl_hostname=bts.remote_addr(), pcu_available=pcu_available) |
Pau Espin Pedrol | bc1ed88 | 2018-05-17 16:59:58 +0200 | [diff] [blame] | 60 | with open(bts_cfg_file, 'w') as f: |
| 61 | f.write(r) |
| 62 | |
| 63 | |
| 64 | print('Starting TTCN3 tests') |
| 65 | proc = process.Process('ttcn3', script_run_dir, docker_cmd) |
| 66 | try: |
| 67 | proc.launch() |
| 68 | print('Starting TTCN3 launched, waiting until it finishes') |
| 69 | proc.wait(timeout=3600) |
| 70 | except Exception as e: |
| 71 | proc.terminate() |
| 72 | raise e |
| 73 | |
| 74 | if proc.result != 0: |
| 75 | raise RuntimeError("run_ttcn3_docker.sh exited with error code %d" % proc.result) |
| 76 | |
| 77 | print('Done') |