I am automating testing of componenet that recieves Diameter protocol messages using Seagull.
The Diameter message is set up using an XML template below. I want to be able to update the fields in the file, run the test, and then reset the file back to its original form during clean down. The cleandown bit I am currently achieving by taking a copy of the file at the start of the test and then using this backup file to replace the changed XML file.
Seagull sits on a Linux Box (Redhat) which I SSH into as part of my automated test. My tests are written in Python and are stored in a different location to the various systems under test so any actions need to be completed via the Command line on my Linux Box.
A colleague has suggested I use runcmmd and then sed to replace the individual lines however I can see a number of potential issues with this approach and would rather do somthing a bit neater.
What is the best way to automate upadating the fields in an XML file on Linux? Currently I am only testing 2 of the fields but I want an approach that allows the tests to be easy to expand to cover additional fields in future.
XML file under test
> <?xml version="1.0" encoding="ISO-8859-1" ?> <scenario>
>
> <counter> <counterdef name="HbH-counter" init="1000"> </counterdef>
> <counterdef name="EtE-counter" init="2000"> </counterdef>
> <counterdef name="session-counter" init="0"> </counterdef> </counter>
>
> <init> <send channel="channel-1">
> <command name="CER">
> <avp name="Session-Id" value="test-seesion"> </avp>
> <avp name="Auth-Application-Id" value="16777238"> </avp>
> <avp name="Origin-Host" value="sp-test-host"> </avp>
> <avp name="Origin-Realm" value="sp-test-host-realm"> </avp>
> <avp name="Destination-Realm" value="sp-test-dest-realm"> </avp>
> <avp name="CC-Request-Type" value="1"> </avp>
> <avp name="CC-Request-Number" value="0"> </avp>
> <avp name="Destination-Host" value="sp-test-dest-host"> </avp>
> <avp name="Origin-State-Id" value="1505899589"> </avp>
> <avp name="Subscription-Id">
> <avp name="Subscription-Id-Type" value="0"> </avp>
> <avp name="Subscription-Id-Data" value="79161529998"> </avp>
> </avp>
> <avp name="Subscription-Id" value="">
> <avp name="Subscription-Id-Type" value="1"> </avp>
> <avp name="Subscription-Id-Data" value="250016371458760"> </avp>
> </avp>
> <avp name="Framed-IP-Address" value="0x0a1x019a"> </avp>
> <avp name="Vendor-Id" value="11"> </avp>
> <avp name="Product-Name" value="HP"> </avp>
> <avp name="Supported-Vendor-Id" value="10415"> </avp>
> <avp name="Vendor-Specific-Application-Id">
> <avp name="Vendor-Id" value="10415"></avp>
> <avp name="Auth-Application-Id" value="4"></avp>
> </avp>
> <avp name="Firmware-Revision" value="1030006"></avp>
> </command> </send>
> <receive channel="channel-1">
> <command name="CEA">
> </command> </receive> </init>
>
> <!-- Traffic --> <traffic> <send channel="channel-1">
> <action>
> <!-- For each new call, increment the session-ID counter -->
> <inc-counter name="HbH-counter"> </inc-counter>
> <inc-counter name="EtE-counter"> </inc-counter>
> <inc-counter name="session-counter"> </inc-counter>
> <set-value name="HbH-id"
> format="$(HbH-counter)"></set-value>
> <set-value name="EtE-id"
> format="$(EtE-counter)"></set-value>
> <set-value name="Session-Id"
> format="seagull.mydomain.com;1096298391;$(session-counter)"></set-value>
> </action>
> <command name="CCR">
> <avp name="Session-Id" value="value_is_replaced"> </avp>
> <avp name="Origin-Host" value="seagull.mydomain.com"> </avp>
> <avp name="Origin-Realm" value="ExampleRealm"> </avp>
> <avp name="Destination-Realm" value="ExampleRealm"> </avp>
> <avp name="Vendor-Specific-Application-Id">
> <avp name="Vendor-Id" value="10415"></avp>
> <avp name="Auth-Application-Id" value="4"></avp>
> </avp>
> <avp name="Auth-Application-Id" value="4"></avp>
> <avp name="Service-Context-Id" value="32260@3gpp.org"> </avp>
> <avp name="CC-Request-Type" value="0x00000001"> </avp>
> <avp name="CC-Request-Number" value="0"> </avp>
> </command>
> <action>
> <start-timer></start-timer>
> </action> </send>
> <receive channel="channel-1">
> <action>
> <stop-timer></stop-timer>
> </action>
> <command name="CCA">
> </command> </receive> </traffic> </scenario>
User contributions licensed under CC BY-SA 3.0