summaryrefslogtreecommitdiffstats
path: root/src/tests/modules/sql/acct_start_conflict.unlang
blob: 65e69e02b9e71f3c840e42d61ee3e5183612a9c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
#  Check that conflicting unique IDs triggers failover to alternative query
#

#
#  Clear out old data
#
update {
	Tmp-String-0 := "%{sql:DELETE FROM radacct WHERE AcctSessionId = '00000003'}"
}
if (!&Tmp-String-0) {
	test_fail
}
else {
	test_pass
}

#
#  Insert the Accounting-Request start
#
sql.accounting
if (ok) {
	test_pass
}
else {
	test_fail
}

#
#  Check the database has at least one row
#
update {
	Tmp-Integer-0 := "%{sql:SELECT count(*) FROM radacct WHERE AcctSessionId = '00000003'}"
}
if (!&Tmp-Integer-0 || (&Tmp-Integer-0 != 1)) {
	test_fail
}
else {
	test_pass
}

#
#  Check acctsessiontime matches the value in the request
#
update {
	Tmp-Integer-0 := "%{sql:SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000003'}"
}
if (!&Tmp-Integer-0 || (&Tmp-Integer-0 != 0)) {
	test_fail
}
else {
	test_pass
}

#
#  Change acctsessiontime and verify it's updated
#
update request {
	Connect-Info = 'updated'
}
sql.accounting
if (ok) {
	test_pass
}
else {
	test_fail
}
update {
	Tmp-String-0 := "%{sql:SELECT connectinfo_start FROM radacct WHERE AcctSessionId = '00000003'}"
}
if (!&Tmp-Integer-0 || (&Tmp-String-0 != 'updated')) {
	test_fail
}
else {
	test_pass
}