# Series of tests to check for binary safe operation of the cache module
# both keys and values should be binary safe.
#
-&Tmp-Octets-0 := 0xaa00bb00cc00dd00
-&Tmp-String-1 := "foo\000bar\000baz"
+&Class := 0xaa00bb00cc00dd00
+&Callback-Id := "foo\000bar\000baz"
# 0. Sanity check
-if (&Tmp-String-1 != "foo\000bar\000baz") {
+if (&Callback-Id != "foo\000bar\000baz") {
test_fail
}
}
# Now add a second entry, with the value diverging after the first null byte
-&Tmp-Octets-0 := 0xaa00bb00cc00ee00
-&Tmp-String-1 := "bar\000baz"
+&Class := 0xaa00bb00cc00ee00
+&Callback-Id := "bar\000baz"
# 2. Should create a *new* entry and not update the existing one
cache_bin_key_octets.store
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# If the key is binary safe, we should now be able to retrieve the first entry
# if it's not, the above test will likely fail, or we'll get the second entry.
-&Tmp-Octets-0 := 0xaa00bb00cc00dd00
+&Class := 0xaa00bb00cc00dd00
cache_bin_key_octets
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 11) {
+if (%(length:%{Callback-Id}) != 11) {
test_fail
}
-if (&Tmp-String-1 != "foo\000bar\000baz") {
+if (&Callback-Id != "foo\000bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Now try and get the second entry
-&Tmp-Octets-0 := 0xaa00bb00cc00ee00
+&Class := 0xaa00bb00cc00ee00
cache_bin_key_octets
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 7) {
+if (%length(%{Callback-Id}) != 7) {
test_fail
}
-if (&Tmp-String-1 != "bar\000baz") {
+if (&Callback-Id != "bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
#
# We should also be able to use any fixed length data type as a key
# though there are no guarantees this will be portable.
#
-&Tmp-IP-Address-0 := 192.168.0.1
-&Tmp-String-1 := "foo\000bar\000baz"
+&Framed-IP-Address := 192.168.0.1
+&Callback-Id := "foo\000bar\000baz"
cache_bin_key_ipaddr
if (!ok) {
}
# Now add a second entry
-&Tmp-IP-Address-0:= 192.168.0.2
-&Tmp-String-1 := "bar\000baz"
+&Framed-IP-Address:= 192.168.0.2
+&Callback-Id := "bar\000baz"
cache_bin_key_ipaddr
if (!ok) {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Now retrieve the first entry
-&Tmp-IP-Address-0 := 192.168.0.1
+&Framed-IP-Address := 192.168.0.1
cache_bin_key_ipaddr
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 11) {
+if (%length(%{Callback-Id}) != 11) {
test_fail
}
-if (&Tmp-String-1 != "foo\000bar\000baz") {
+if (&Callback-Id != "foo\000bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Now try and get the second entry
-&Tmp-IP-Address-0 := 192.168.0.2
+&Framed-IP-Address := 192.168.0.2
cache_bin_key_ipaddr
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 7) {
+if (%length(%{Callback-Id}) != 7) {
test_fail
}
-if (&Tmp-String-1 != "bar\000baz") {
+if (&Callback-Id != "bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
test_pass
#
# PRE:
#
-&Tmp-String-0 := 'testkey'
+&Filter-Id := 'testkey'
#
# 0. Basic store and retrieve
#
-&control.Tmp-String-1 := 'cache me'
+&control.Callback-Id := 'cache me'
cache
if (!ok) {
}
# 1. Check the module didn't perform a merge
-if (&Tmp-String-1) {
+if (&Callback-Id) {
test_fail
}
}
# 5.
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
# 6. Retrieving the entry should not expire it
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
cache
if (!updated) {
}
# 7.
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
else {
}
# 17.
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
-&control.Tmp-String-1 := 'cache me2'
+&control.Callback-Id := 'cache me2'
# 18. Updating the Cache-TTL shouldn't make things go boom (we can't really check if it works)
&control.Cache-TTL := 30
test_fail
}
-# 19. Request Tmp-String-1 shouldn't have been updated yet
-if (&Tmp-String-1 == &control.Tmp-String-1) {
+# 19. Request Callback-Id shouldn't have been updated yet
+if (&Callback-Id == &control.Callback-Id) {
test_fail
}
test_fail
}
-# 21. Request Tmp-String-1 still shouldn't have been updated yet
-if (&Tmp-String-1 == &control.Tmp-String-1) {
+# 21. Request Callback-Id still shouldn't have been updated yet
+if (&Callback-Id == &control.Callback-Id) {
test_fail
}
test_fail
}
-# 23. Request Tmp-String-1 should now have been updated
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+# 23. Request Callback-Id should now have been updated
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
# 24. Check Cache-Merge = yes works as expected (should update current request)
-&control.Tmp-String-1 := 'cache me3'
+&control.Callback-Id := 'cache me3'
&control.Cache-TTL := -2
&control.Cache-Merge-New := yes
test_fail
}
-# 25. Request Tmp-String-1 should now have been updated
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+# 25. Request Callback-Id should now have been updated
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
# Series of tests to check for binary safe operation of the cache module
# both keys and values should be binary safe.
#
-&Tmp-Octets-0 := 0xaa11bb00cc00dd00
-&Tmp-String-1 := "foo\000bar\000baz"
+&Class := 0xaa11bb00cc00dd00
+&Callback-Id := "foo\000bar\000baz"
# 0. Sanity check
-if (&Tmp-String-1 != "foo\000bar\000baz") {
+if (&Callback-Id != "foo\000bar\000baz") {
test_fail
}
}
# Now add a second entry, with the value diverging after the first null byte
-&Tmp-Octets-0 := 0xaa11bb00cc00ee00
-&Tmp-String-1 := "bar\000baz"
+&Class := 0xaa11bb00cc00ee00
+&Callback-Id := "bar\000baz"
# 2. Should create a *new* entry and not update the existing one
cache_bin_key_octets.store
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# If the key is binary safe, we should now be able to retrieve the first entry
# if it's not, the above test will likely fail, or we'll get the second entry.
-&Tmp-Octets-0 := 0xaa11bb00cc00dd00
+&Class := 0xaa11bb00cc00dd00
cache_bin_key_octets.load
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 11) {
+if (%length(%{Callback-Id}) != 11) {
test_fail
}
-if (&Tmp-String-1 != "foo\000bar\000baz") {
+if (&Callback-Id != "foo\000bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Now try and get the second entry
-&Tmp-Octets-0 := 0xaa11bb00cc00ee00
+&Class := 0xaa11bb00cc00ee00
cache_bin_key_octets.load
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 7) {
+if (%length(%{Callback-Id}) != 7) {
test_fail
}
-if (&Tmp-String-1 != "bar\000baz") {
+if (&Callback-Id != "bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
#
# We should also be able to use any fixed length data type as a key
# though there are no guarantees this will be portable.
#
-&Tmp-IP-Address-0 := 192.168.1.1
-&Tmp-String-1 := "foo\000bar\000baz"
+&Framed-IP-Address := 192.168.1.1
+&Callback-Id := "foo\000bar\000baz"
cache_bin_key_ipaddr.store
if (!updated) {
}
# Now add a second entry
-&Tmp-IP-Address-0:= 192.168.1.2
-&Tmp-String-1 := "bar\000baz"
+&Framed-IP-Address:= 192.168.1.2
+&Callback-Id := "bar\000baz"
cache_bin_key_ipaddr.store
if (!updated) {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Now retrieve the first entry
-&Tmp-IP-Address-0 := 192.168.1.1
+&Framed-IP-Address := 192.168.1.1
cache_bin_key_ipaddr.load
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 11) {
+if (%length(%{Callback-Id}) != 11) {
test_fail
}
-if (&Tmp-String-1 != "foo\000bar\000baz") {
+if (&Callback-Id != "foo\000bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
# Now try and get the second entry
-&Tmp-IP-Address-0 := 192.168.1.2
+&Framed-IP-Address := 192.168.1.2
cache_bin_key_ipaddr.load
if (!updated) {
test_fail
}
-if (%length(%{Tmp-String-1}) != 7) {
+if (%length(%{Callback-Id}) != 7) {
test_fail
}
-if (&Tmp-String-1 != "bar\000baz") {
+if (&Callback-Id != "bar\000baz") {
test_fail
}
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
test_pass
#
# PRE:
#
-&Tmp-String-0 := 'testkey1'
+&Filter-Id := 'testkey1'
#
# 0. Basic store and retrieve
#
-&control.Tmp-String-1 := 'cache me'
+&control.Callback-Id := 'cache me'
cache.store
if (!updated) {
}
# 1. Check the module didn't perform a merge
-if (&Tmp-String-1) {
+if (&Callback-Id) {
test_fail
}
}
# 4.
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
# 5. Retrieving the entry should not expire it
-&request -= &Tmp-String-1[*]
+&request -= &Callback-Id[*]
cache.load
if (!updated) {
}
# 6.
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
}
# 14.
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
-&control.Tmp-String-1 := 'cache me2'
+&control.Callback-Id := 'cache me2'
# 18. Updating the Cache-TTL shouldn't make things go boom (we can't really check if it works)
&control.Cache-TTL := 666
test_fail
}
-# 19. Request Tmp-String-1 shouldn't have been updated yet
-if (&Tmp-String-1 == &control.Tmp-String-1) {
+# 19. Request Callback-Id shouldn't have been updated yet
+if (&Callback-Id == &control.Callback-Id) {
test_fail
}
test_fail
}
-# 21. Request Tmp-String-1 still shouldn't have been updated yet
-if (&Tmp-String-1 == &control.Tmp-String-1) {
+# 21. Request Callback-Id still shouldn't have been updated yet
+if (&Callback-Id == &control.Callback-Id) {
test_fail
}
test_fail
}
-# 23. Request Tmp-String-1 should now have been updated
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+# 23. Request Callback-Id should now have been updated
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
# 24. Check Cache-Merge = yes works as expected (should update current request)
-&control.Tmp-String-1 := 'cache me3'
+&control.Callback-Id := 'cache me3'
&control.Cache-TTL := -2
&control.Cache-Merge-New := yes
test_fail
}
-# 25. Request Tmp-String-1 should now have been updated
-if (&Tmp-String-1 != &control.Tmp-String-1) {
+# 25. Request Callback-Id should now have been updated
+if (&Callback-Id != &control.Callback-Id) {
test_fail
}
#
# PRE: cache-logic
#
-&Tmp-String-0 := 'testkey3'
+&Filter-Id := 'testkey3'
# Reply attributes
&reply.Reply-Message := 'hello'
# Request attributes
&request += {
- &Tmp-Integer-0 = 10
- &Tmp-Integer-0 = 20
- &Tmp-Integer-0 = 30
+ &NAS-Port = 10
+ &NAS-Port = 20
+ &NAS-Port = 30
}
#
# Basic store and retrieve
#
-&control.Tmp-String-1 := 'cache me'
+&control.Callback-Id := 'cache me'
cache_update.store
if (!updated) {
test_fail
}
-# Tmp-String-1 should hold the result of the exec
-if (&Tmp-String-1 != 'echo test') {
+# Callback-Id should hold the result of the exec
+if (&Callback-Id != 'echo test') {
test_pass
}
# Literal values should be foo, rad, baz
-if ("%{Tmp-String-2[#]}" != 3) {
+if ("%{Login-LAT-Service[#]}" != 3) {
test_fail
}
-if (&Tmp-String-2[0] != 'foo') {
+if (&Login-LAT-Service[0] != 'foo') {
test_fail
}
debug_request
-if (&Tmp-String-2[1] != 'rab') {
+if (&Login-LAT-Service[1] != 'rab') {
test_fail
}
-if (&Tmp-String-2[2] != 'baz') {
+if (&Login-LAT-Service[2] != 'baz') {
test_fail
}
#
# PRE: cache-logic
#
-&Tmp-String-0 := 'testkey2'
+&Filter-Id := 'testkey2'
# Reply attributes
&reply.Reply-Message := 'hello'
# Request attributes
&request += {
- &Tmp-Integer-0 = 10
- &Tmp-Integer-0 = 20
- &Tmp-Integer-0 = 30
+ &NAS-Port = 10
+ &NAS-Port = 20
+ &NAS-Port = 30
}
#
# Basic store and retrieve
#
-&control.Tmp-String-1 := 'cache me'
+&control.Callback-Id := 'cache me'
cache_update
if (!ok) {
test_fail
}
-# Tmp-String-1 should hold the result of the exec
-if (&Tmp-String-1 != 'echo test') {
+# Callback-Id should hold the result of the exec
+if (&Callback-Id != 'echo test') {
test_fail
}
# Literal values should be foo, rad, baz
-if ("%{Tmp-String-2[#]}" != 3) {
+if ("%{Login-LAT-Service[#]}" != 3) {
test_fail
}
-if (&Tmp-String-2[0] != 'foo') {
+if (&Login-LAT-Service[0] != 'foo') {
test_fail
}
debug_request
-if (&Tmp-String-2[1] != 'rab') {
+if (&Login-LAT-Service[1] != 'rab') {
test_fail
}
-if (&Tmp-String-2[2] != 'baz') {
+if (&Login-LAT-Service[2] != 'baz') {
test_fail
}
#
# PRE: cache-logic
#
-&Tmp-String-0 := 'testkey'
-&control.Tmp-String-1 := 'cache me'
+&Filter-Id := 'testkey'
+&control.Callback-Id := 'cache me'
cache
if (!ok) {
test_fail
}
-&request.Tmp-String-2 := %cache(request.Tmp-String-1)
+&request.Login-LAT-Service := %cache(request.Callback-Id)
-if (&Tmp-String-2 != &control.Tmp-String-1) {
+if (&Login-LAT-Service != &control.Callback-Id) {
test_fail
}
-&Tmp-String-3 := "%cache(request.Tmp-String-4)"
-if (&Tmp-String-3 != "") {
+&Login-LAT-Node := %cache(request.Login-LAT-Port)
+
+if (&Login-LAT-Node) {
test_fail
}
# Regression test for deadlock on notfound
-&Tmp-String-0 := 'testkey0'
+&Filter-Id := 'testkey0'
-&Tmp-String-3 := %cache(request.Tmp-String-4)
+&Login-LAT-Node := %cache(request.Login-LAT-Port)
# Would previously deadlock
-&Tmp-String-4 := %cache(request.Tmp-String-4)
+&Login-LAT-Port := %cache(request.Login-LAT-Port)
test_pass
cache {
driver = "rbtree"
- key = "%{Tmp-String-0}"
+ key = "%{Filter-Id}"
ttl = 5
update {
- &Tmp-String-1 := &control.Tmp-String-1[0]
- &Tmp-Integer-0 := &control.Tmp-Integer-0[0]
+ &Callback-Id := &control.Callback-Id[0]
+ &NAS-Port := &control.NAS-Port[0]
&control += &reply
}
cache cache_update {
driver = "rbtree"
- key = "%{Tmp-String-0}"
+ key = "%{Filter-Id}"
ttl = 5
#
&session-state += &reply
# Implicit cast between types (and multivalue copy)
- &Tmp-String-0 += &Tmp-Integer-0[*]
+ &Filter-Id += &NAS-Port[*]
# Cache the result of an exec
- &Tmp-String-1 := `/bin/echo 'echo test'`
+ &Callback-Id := `/bin/echo 'echo test'`
# Create three string values and overwrite the middle one
- &Tmp-String-2 += 'foo'
- &Tmp-String-2 += 'bar'
- &Tmp-String-2 += 'baz'
+ &Login-LAT-Service += 'foo'
+ &Login-LAT-Service += 'bar'
+ &Login-LAT-Service += 'baz'
- &Tmp-String-2[1] := 'rab'
+ &Login-LAT-Service[1] := 'rab'
# Create three string values, then remove one
- &Tmp-String-3 += 'foo'
- &Tmp-String-3 += 'bar'
- &Tmp-String-3 += 'baz'
+ &Login-LAT-Node += 'foo'
+ &Login-LAT-Node += 'bar'
+ &Login-LAT-Node += 'baz'
- &Tmp-String-3 -= 'bar'
+ &Login-LAT-Node -= 'bar'
}
}
cache cache_bin_key_octets {
driver = "rbtree"
- key = &Tmp-Octets-0
+ key = &Class
ttl = 5
update {
- &Tmp-String-1 := &Tmp-String-1[0]
+ &Callback-Id := &Callback-Id[0]
}
}
cache cache_bin_key_ipaddr {
driver = "rbtree"
- key = &Tmp-IP-Address-0
+ key = &Framed-IP-Address
ttl = 5
update {
- &Tmp-String-1 := &Tmp-String-1[0]
+ &Callback-Id := &Callback-Id[0]
}
}
server = $ENV{CACHE_REDIS_TEST_SERVER}:30006
}
- key = "$ENV{MODULE_TEST_UNLANG}%{Tmp-String-0}"
+ key = "$ENV{MODULE_TEST_UNLANG}%{Filter-Id}"
ttl = 5
update {
- &Tmp-String-1 := &control.Tmp-String-1[0]
- &Tmp-Integer-0 := &control.Tmp-Integer-0[0]
+ &Callback-Id := &control.Callback-Id[0]
+ &NAS-Port := &control.NAS-Port[0]
&control += &reply
}
server = $ENV{CACHE_REDIS_TEST_SERVER}:30006
}
- key = "$ENV{MODULE_TEST_UNLANG}%{Tmp-String-0}"
+ key = "$ENV{MODULE_TEST_UNLANG}%{Filter-Id}"
ttl = 5
#
&session-state += &reply
# Implicit cast between types (and multivalue copy)
- &Tmp-String-0 += &Tmp-Integer-0[*]
+ &Filter-Id += &NAS-Port[*]
# Cache the result of an exec
- &Tmp-String-1 := `/bin/echo 'echo test'`
+ &Callback-Id := `/bin/echo 'echo test'`
# Create three string values and overwrite the middle one
- &Tmp-String-2 += 'foo'
- &Tmp-String-2 += 'bar'
- &Tmp-String-2 += 'baz'
+ &Login-LAT-Service += 'foo'
+ &Login-LAT-Service += 'bar'
+ &Login-LAT-Service += 'baz'
- &Tmp-String-2[1] := 'rab'
+ &Login-LAT-Service[1] := 'rab'
# Create three string values, then remove one
- &Tmp-String-3 += 'foo'
- &Tmp-String-3 += 'bar'
- &Tmp-String-3 += 'baz'
+ &Login-LAT-Node += 'foo'
+ &Login-LAT-Node += 'bar'
+ &Login-LAT-Node += 'baz'
- &Tmp-String-3 -= 'bar'
+ &Login-LAT-Node -= 'bar'
}
}
server = $ENV{CACHE_REDIS_TEST_SERVER}:30006
}
- key = &Tmp-Octets-0
+ key = &Class
ttl = 5
update {
- &Tmp-String-1 := &Tmp-String-1[0]
+ &Callback-Id := &Callback-Id[0]
}
}
server = $ENV{CACHE_REDIS_TEST_SERVER}:30006
}
- key = &Tmp-IP-Address-0
+ key = &Framed-IP-Address
ttl = 5
update {
- &Tmp-String-1 := &Tmp-String-1[0]
+ &Callback-Id := &Callback-Id[0]
}
}