landro / TesTcl

when you don't have the balls to test your F5 BIG-IP iRules directly in production
https://testcl.com
BSD 3-Clause "New" or "Revised" License
98 stars 30 forks source link

irules withour rule name { } #62

Closed olanystrom closed 4 years ago

olanystrom commented 4 years ago

I use a lot of iRules with ansibles bigip_irule and the irules and not wrapped in rule name { IRULE } Is there a way to use testcl to test them?

Or do I have to make a builder-script to wrap the files in rule NAME {} to be able to test them?

landro commented 4 years ago

Currently this is not directly supported. Have you tried wrapping using the tcl source command?

  1. okt. 2019 kl. 12:20 skrev olanystrom notifications@github.com:

 I use a lot of iRules with ansibles bigip_irule and the irules and not wrapped in rule name { IRULE } Is there a way to use testcl to test them?

Or do I have to make a builder-script to wrap the files in rule NAME {} to be able to test them?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

olanystrom commented 4 years ago

That works fine. I have a tests-directory with the test and a .tcl that wraps with


rule name {
   source ../real_irule
}```

Now I have to figure out how to test my class-based stuff
landro commented 4 years ago

Have you checked https://github.com/landro/TesTcl/blob/master/examples/example_irule_classes.tcl

  1. okt. 2019 kl. 14:43 skrev olanystrom notifications@github.com:

 That works fine. I have a tests-directory with the test and a .tcl that wraps with

rule name { source ../real_irule }```

Now I have to figure out how to test my class-based stuff — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

olanystrom commented 4 years ago

Have you checked https://github.com/landro/TesTcl/blob/master/examples/example_irule_classes.tcl Yes, and that makes it mostly succesful.

I had to rewrite some irules to be allowed with testcl.

if{ $lower_host eq "example.com"}
{
   do_something
}

that we have in production in F5:s are not allowed in the test, it has to be rewritten as

if{ $lower_host eq "example.com"} {
   do_something
}

also, it didnt like my use of [HTTP::host] inside strings. For example it didn't like

log local0. "Access to [HTTP::host] with uri [HTTP::uri]" 

At least I think that was the problem.