Debian Codegraph @

tests/CI/setupRealtime.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 CIDIR=$(dirnamescip-shell system . . dirname. $(readlinkscip-shell system . . readlink. -fn $0))
3 INITIALIZE_DB=0
4 source $CIDIR/ci.functions
5 ASTTOP=$(readlinkscip-shell system . . readlink. -fn $CIDIR/../../)
6
7 set -e
8
9 POSTGRES_PID=`pidofscip-shell system . . pidof. postgres || : `
10
11 if [scip-shell system . . `[`. -z "$POSTGRES_PID" ] ; then
12 if [scip-shell system . . `[`. -x /usr/local/bin/postgresql-startscip-shell filesystem . . `/usr/local/bin/postgresql-start`. ] ; then
13 /usr/local/bin/postgresql-startscip-shell filesystem . . `/usr/local/bin/postgresql-start`.
14 fi
15 fi
16
17 POSTGRES_PID=`pidofscip-shell system . . pidof. postgres || : `
18 if [scip-shell system . . `[`. -z "$POSTGRES_PID" ] ; then
19 echoscip-shell system . . echo. "Postgres isn't running. It must be started manually before this test can continue."
20 exit 1
21 fi
22
23 if [scip-shell system . . `[`. $INITIALIZE_DB -gt 0 ] ; then
24 echoscip-shell system . . echo. "(re)Initializing Database"
25
26 sudoscip-shell system . . sudo. -u postgres dropdb -e asterisk_test >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || :
27 sudoscip-shell system . . sudo. -u postgres dropuser -e asterisk_test >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || :
28 sudoscip-shell system . . sudo. -u postgres createuser --username=postgres -RDIElS asterisk_test
29 sudoscip-shell system . . sudo. -u postgres createdb --username=postgres -E UTF-8 -O asterisk_test asterisk_test
30
31 echoscip-shell system . . echo. "Configuring ODBC"
32
33 sudoscip-shell system . . sudo. odbcinst -u -d -n "PostgreSQL-Asterisk-Test"
34
35 sudoscip-shell system . . sudo. odbcinst -i -d -n "PostgreSQL-Asterisk-Test" -f /dev/stdinscip-shell filesystem . . `/dev/stdin`. <<-EOF
36 [PostgreSQL-Asterisk-Test]
37 Description=PostgreSQL ODBC driver (Unicode version)
38 Driver=psqlodbcw.so
39 Setup=libodbcpsqlS.so
40 Debug=0
41 CommLog=1
42 UsageCount=1
43 EOF
44
45 sudoscip-shell system . . sudo. odbcinst -u -s -l -n asterisk-connector-test
46 sudoscip-shell system . . sudo. odbcinst -i -s -l -n asterisk-connector-test -f /dev/stdinscip-shell filesystem . . `/dev/stdin`. <<-EOF
47 [asterisk-connector-test]
48 Description = PostgreSQL connection to 'asterisk' database
49 Driver = PostgreSQL-Asterisk-Test
50 Database = asterisk_test
51 Servername = 127.0.0.1
52 UserName = asterisk_test
53 Port = 5432
54 Protocol = 9.1
55 ReadOnly = No
56 RowVersioning = No
57 ShowSystemTables = No
58 ShowOldColumn = No
59 FakeOldIndex = No
60 ConnSettings =
61 EOF
62 fi
63
64 catscip-shell system . . cat. >/tmp/config.iniscip-shell filesystem . . `/tmp/config.ini`. <<-EOF
65 [alembic]
66 script_location = config
67 sqlalchemy.url = postgresql://asterisk_test@localhost/asterisk_test
68
69 [loggers]
70 keys = root,sqlalchemy,alembic
71
72 [handlers]
73 keys = console
74
75 [formatters]
76 keys = generic
77
78 [logger_root]
79 level = WARN
80 handlers = console
81 qualname =
82
83 [logger_sqlalchemy]
84 level = WARN
85 handlers =
86 qualname = sqlalchemy.engine
87
88 [logger_alembic]
89 level = INFO
90 handlers =
91 qualname = alembic
92
93 [handler_console]
94 class = StreamHandler
95 args = (sys.stderr,)
96 level = NOTSET
97 formatter = generic
98
99 [formatter_generic]
100 format = %(levelname)-5.5s [%(name)s] %(message)s
101 datefmt = %H:%M:%S
102 EOF
103
104 pushd $ASTTOP/contrib/ast-db-manage
105
106 psql --username=asterisk_test --host=localhost --db=asterisk_test --command='DROP OWNED BY asterisk_test CASCADE'
107 alembic -c /tmp/config.iniscip-shell filesystem . . `/tmp/config.ini`. upgrade head
108 rmscip-shell system . . rm. -rf /tmp/config.iniscip-shell filesystem . . `/tmp/config.ini`. || :
109
110 popd
111
112 cpscip-shell system . . cp. test-config.yaml test-config.orig.yaml
113
114 catscip-shell system . . cat. >test-config.yaml <<-EOF
115 global-settings:
116 test-configuration: config-realtime
117
118 condition-definitions:
119 -
120 name: 'threads'
121 pre:
122 typename: 'thread_test_condition.ThreadPreTestCondition'
123 post:
124 typename: 'thread_test_condition.ThreadPostTestCondition'
125 related-type: 'thread_test_condition.ThreadPreTestCondition'
126 -
127 name: 'sip-dialogs'
128 pre:
129 typename: 'sip_dialog_test_condition.SipDialogPreTestCondition'
130 post:
131 typename: 'sip_dialog_test_condition.SipDialogPostTestCondition'
132 -
133 name: 'locks'
134 pre:
135 typename: 'lock_test_condition.LockTestCondition'
136 post:
137 typename: 'lock_test_condition.LockTestCondition'
138 -
139 name: 'file-descriptors'
140 pre:
141 typename: 'fd_test_condition.FdPreTestCondition'
142 post:
143 typename: 'fd_test_condition.FdPostTestCondition'
144 related-type: 'fd_test_condition.FdPreTestCondition'
145 -
146 name: 'channels'
147 pre:
148 typename: 'channel_test_condition.ChannelTestCondition'
149 post:
150 typename: 'channel_test_condition.ChannelTestCondition'
151 -
152 name: 'sip-channels'
153 pre:
154 typename: 'sip_channel_test_condition.SipChannelTestCondition'
155 post:
156 typename: 'sip_channel_test_condition.SipChannelTestCondition'
157 -
158 name: 'memory'
159 pre:
160 typename: 'memory_test_condition.MemoryPreTestCondition'
161 post:
162 typename: 'memory_test_condition.MemoryPostTestCondition'
163 related-type: 'memory_test_condition.MemoryPreTestCondition'
164
165 config-realtime:
166 test-modules:
167 modules:
168 -
169 typename: realtime_converter.RealtimeConverter
170 config-section: realtime-config
171
172 realtime-config:
173 username: "asterisk_test"
174 password: "asterisk_test"
175 host: "localhost"
176 db: "asterisk_test"
177 dsn: "asterisk-connector-test"
178 EOF
179