summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/redundant-load-balance
blob: 27721f189acc4342d789264de77afa314417f325 (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
# PRE: update if foreach
#
#  Redundant blocks.
#
#  The first one fails, so the second one is used
#
update request {
    Tmp-Integer-0 := 0
    Tmp-Integer-1 += 0
    Tmp-Integer-1 += 1
    Tmp-Integer-1 += 2
    Tmp-Integer-1 += 3
    Tmp-Integer-1 += 4
    Tmp-Integer-1 += 5
    Tmp-Integer-1 += 6
    Tmp-Integer-1 += 7
    Tmp-Integer-1 += 8
    Tmp-Integer-1 += 9

}

#
#  Loop 0..9
#
foreach &Tmp-Integer-1 {
    redundant-load-balance {
        group {
	    # fail on even numbered values, succeed on odd numbered ones
            if ("%{expr:%{Foreach-Variable-0} %% 2}" == 0) {
                fail
            }
            else {
                update request {
                    Tmp-Integer-0 := "%{expr:%{Tmp-Integer-0} + 1}"
		    Filter-Id += "SUCCEED ODD %{Foreach-Variable-0} %{Tmp-Integer-0}"
                }
                ok
            }
        }
        group {
	    # succeed on even-numbered values, fail on off-numbered ones.
            if ("%{expr:%{Foreach-Variable-0} %% 2}" == 1) {
	        fail
            }
            else {
                update request {
                    Tmp-Integer-0 := "%{expr:%{Tmp-Integer-0} + 1}"
		    Filter-Id += "SUCCEED EVEN %{Foreach-Variable-0} %{Tmp-Integer-0}"
                }
                ok
            }
        }
    }
}

if (&Tmp-Integer-0 != "%{Tmp-Integer-1[#]}") {
    update reply {
        Filter-Id += "fail 2 (passed %{Tmp-Integer-0}/%{Tmp-Integer-1[#]})"
    }
}
else {
     update reply {
	Filter-Id := 'filter'
     }
}