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