summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/load-balance
blob: d07939afcc606a07dc978e84f4d2e6afd3532b1c (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# PRE: update if foreach
#
#  Load-Balance blocks.
#
#  Should distribute load between the modules.
#
update request {
    Tmp-Integer-0 := 0
    Tmp-Integer-1 := 0

    Tmp-Integer-2 += 0		# 0
    Tmp-Integer-2 += 1
    Tmp-Integer-2 += 2
    Tmp-Integer-2 += 3
    Tmp-Integer-2 += 4
    Tmp-Integer-2 += 5
    Tmp-Integer-2 += 6
    Tmp-Integer-2 += 7
    Tmp-Integer-2 += 8
    Tmp-Integer-2 += 9		# 10
    Tmp-Integer-2 += 0
    Tmp-Integer-2 += 1
    Tmp-Integer-2 += 2
    Tmp-Integer-2 += 3
    Tmp-Integer-2 += 4
    Tmp-Integer-2 += 5
    Tmp-Integer-2 += 6
    Tmp-Integer-2 += 7
    Tmp-Integer-2 += 8
    Tmp-Integer-2 += 9		# 20
    Tmp-Integer-2 += 0
    Tmp-Integer-2 += 1
    Tmp-Integer-2 += 2
    Tmp-Integer-2 += 3
    Tmp-Integer-2 += 4
    Tmp-Integer-2 += 5
    Tmp-Integer-2 += 6
    Tmp-Integer-2 += 7
    Tmp-Integer-2 += 8
    Tmp-Integer-2 += 9		# 30
    Tmp-Integer-2 += 0
    Tmp-Integer-2 += 1
    Tmp-Integer-2 += 2
    Tmp-Integer-2 += 3
    Tmp-Integer-2 += 4
    Tmp-Integer-2 += 5
    Tmp-Integer-2 += 6
    Tmp-Integer-2 += 7
    Tmp-Integer-2 += 8
    Tmp-Integer-2 += 9		# 40
    Tmp-Integer-2 += 0
    Tmp-Integer-2 += 1
    Tmp-Integer-2 += 2
    Tmp-Integer-2 += 3
    Tmp-Integer-2 += 4
    Tmp-Integer-2 += 5
    Tmp-Integer-2 += 6
    Tmp-Integer-2 += 7
    Tmp-Integer-2 += 8
    Tmp-Integer-2 += 9		# 49
}

#
#  Loop 0..9
#
foreach &Tmp-Integer-2 {
	load-balance {
		group {
			update request {
				Tmp-Integer-0 := "%{expr:%{Tmp-Integer-0} + 1}"
				Filter-Id += "PICKED GROUP 1 %{Tmp-Integer-0} TIME(S)"
			}
			ok
		}
		group {
			update request {
				Tmp-Integer-1 := "%{expr:%{Tmp-Integer-1} + 1}"
				Filter-Id += "PICKED GROUP 2 %{Tmp-Integer-1} TIME(S)"
			}
			ok
		}
	}
}

# The chances of one group being used over another 50 times by random occurrence
# is quite small, and if this happens repeatedly, it's likely there's a bug in
# the load-balance code or random number generator.
if ((&Tmp-Integer-0 == 0) || (&Tmp-Integer-1 == 0)) {
	update reply {
		Filter-Id += "fail 1 %{Tmp-Integer-0}/%{Tmp-Integer-1})"
	}
}
else {
	update reply {
		Filter-Id := 'filter'
	}
}