Product Support > Chauffeur-WDK

Running bash scripts as transaction behaviour

(1/4) > >>

TheKahn:
Hello,

my name is Kamil Filar and I am currently working on my master thesis in Computer Science with the topic "Energy efficiency metrics for virtualized network functions". at the University of Würzburg (Germany). And I am using the Chauffeur WDK for the energy measurement, as you might have guessed.

The problem with my topic is, that my workloads are not generated on the SUT's processor but rather the network card.  I use Ostinato in order to generate custom traffic, which is send to the SUT's network card. I know that Chauffeur was designed to facilitate energy measurements for processor workloads but I need to ask you if the following transaction behaviour would be possible in Chauffeurs current implementation (1.1.0).

I plan to build a transaction that acts as follows.


* On the host computer (in my case a Linux environment) a simple command is being executed . The transaction will then actively wait for the ending of the command.
* After the transaction is finished, the listener will gather the screen output in order to compute the performance metrics.
I am using the following commands to limit the spawning of multiple transactions


--- Code: ---<num-transaction-threads>1</num-transaction-threads>
<max-per-client-users>1</max-per-client-users>
--- End code ---


My questions are now the following ones:


* How can I reduce the spawning of transactions in Chauffeur to exact one transaction?
* How can I tell the host to run a bash command and print out everything on screen? I orientated myself on the List<String> getLscpuEntries() method but somehow the transaction is spawned multiple times before it can even finish one complete run and there is no response from the comand prompt on the host's screen.

Please tell me if you need more information.

Thank you very much in advance.

Yours Sincerely

Kamil

JeremyArnold:
Hi,
The type of transaction you describe should run just fine in Chauffeur.  As you say, your transaction code will need to launch the command, wait for it to return, and then collect the output.

In addition to setting <num-transaction-threads> and <max-per-client-users> in config.xml, you'll probably want to set the client count to 1 (in <client-configuration>).  If you have done those three things, and your Transaction code properly blocks until the command completes, there should only be one copy of your transaction code running at a time.  If you are seeing the transaction return immediately without waiting for the command to complete, then there is an issue in your Transaction code, or the script you are executing is returning without waiting for the workload to complete.  The getLscpuEntries() code should be a reasonable example.  If you're having trouble with it, feel free to post your code and I'll see if I can help.

It sounds like you also want to only run one transaction total.  To do this, you'll want to use a FixedIterationsDirectorSequence.  Instead of <sequence>, use:
   <sequence className="org.spec.chauffeur.director.FixedIterationsDirectorSequence">
      <interval-iterations>1</interval-iterations>
      ...
   </sequence>

Another alternative is the MinIterationsDirectorSequence -- this is useful when there are multiple threads and/or clients, because it will keep running transactions in all clients until the last one has completed the minimum number you specify.  That way you can ensure that the system continues running at a steady load while collecting power data.

The drawback of either of these approaches is that they can't generate graduated loads like the default behavior can.  For example, you won't be able to generate a 25% or 50% load this way.

You may also be interested in the ScoreCalculator interface, which would allow you to base the worklet's score on the output returned by your command, instead of the default throughput-based score.  You'll need to implement the org.spec.chauffeur.ScoreCalculator interface.  There are two implementations in Chauffeur that you can look at for examples:  the ThroughputCalculator (the default) and TransactionResultsScoreCalculator.  It may even be possible to use the TransactionResultsScoreCalculator directly: just define your transaction to return a numeric value, and the TransactionResultsScoreCalculator will use that value as the worklet score.  Whether you use this implementation or your own custom implementation, you'll need to define it in your worklet xml file:
    <score-calculator-factory implClass="org.spec.chauffeur.TransactionResultsScoreCalculator"/>

I hope that helps.  If you have any further questions, please respond and I'll try to reply more quickly.

TheKahn:
Hello and thank you for your input.

After I changed the sequence the transaction has been executed only once. However, somehow it looks that my transaction does not work. I tried even a very simple transaction consisting of a simple printline command. Nevertheless, neither on the director nor on the host console the printline command worked. I tried to orientate myself on the available tutorial. I will post my configuration files and my code snippets and try to explain what I tried to achieve with them.


My configuration:


--- Code: ---<?xml version="1.0" encoding="UTF-8"?>
<chauffeur xmlns="http://spec.org/power_chauffeur"
   xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="test-environment.xml"/>


<suite>
<client-configuration>
<clients key="Test">
<count>1</count>
<option-set/>
</clients>
</client-configuration>

<description className="org.spec.chauffeur.test.ChauffeurTest"/>
classpath="lib/chauffeurTest.jar"/>


<xi:include href="listeners.xml"/>

<workload enabled="true">
<name>Energy Efficiency Metrics Test</name>
<worklet enabled="true">

<launch-definition id="launchDef">
<configuration-key>Test</configuration-key>
</launch-definition>

<workletDefinition>
<location>org/spec/chauffeur/energyEfficiencyMetrics/testWorklet.xml</location>
<classpath>
<entry>lib/energy.jar</entry>
</classpath>
<parameters>
<parameter name="minimum-sleep-time">500ms</parameter>
<parameter name="maximum-sleep-time">5000ms</parameter>
</parameters>
</workletDefinition>

<warmup-phase>
<sequence className="org.spec.chauffeur.director.FixedIterationsDirectorSequence">
<interval-series className="NoDelaySeries">
<scenario-mix-factory>energyEfficiencyScenarioMix</scenario-mix-factory>
</interval-series>
<interval-iterations>1</interval-iterations>
</sequence>
</warmup-phase>

<calibration-phase>
<sequence className="org.spec.chauffeur.director.FixedIterationsDirectorSequence">
<interval-series className="NoDelaySeries">
<scenario-mix-factory>energyEfficiencyScenarioMix</scenario-mix-factory>
</interval-series>
<interval-iterations>1</interval-iterations>
</sequence>
<calibrator className="AverageThroughputCalibrator">
<average-intervals>2</average-intervals>
</calibrator>
</calibration-phase>

<measurement-phase>
<sequence className="org.spec.chauffeur.director.FixedIterationsDirectorSequence">
<interval-series className="GraduatedMeasurementSeries">
<scenario-mix-factory>energyEfficiencyScenarioMix</scenario-mix-factory>
</interval-series>
<interval-iterations>1</interval-iterations>
</sequence>
</measurement-phase>

<num-transaction-threads>1</num-transaction-threads>
<max-per-client-users>1</max-per-client-users>

</worklet>
</workload>
</suite>
</chauffeur>
--- End code ---





My worklet definition:


--- Code: ---<?xml version="1.0" encoding="UTF-8"?>
<workletDefinition xmlns="http://spec.org/power_chauffeur">
<name>Energy Efficiency Test Worklet</name>
<user-factory className="org.spec.chauffeur.energyEfficiencyMetrics.EnergyEfficiencyUserFactory"/>
<launch-customizer className="CpuLaunchCustomizer"/>

<default-scenario-mix-factory>energyEfficiencyScenarioMix</default-scenario-mix-factory>
<scenario-mix-factories>
<scenario-mix-factory name="energyEfficiencyScenarioMix">
<scenarios>
<weighted-scenario>
<weight>1</weight>
<scenario-factory implClass="org.spec.chauffeur.Scenario">
<batch-size>1</batch-size>
<macro-transaction-size>1</macro-transaction-size>
<transaction-mix-factory>
<weighted-transaction>
<transaction-factory implClass="org.spec.chauffeur.energyEfficiencyMetrics.EnergyEfficiencyMetricsTransaction"/>
<weight>1</weight>
</weighted-transaction>
</transaction-mix-factory>
</scenario-factory>
</weighted-scenario>
</scenarios>
</scenario-mix-factory>
</scenario-mix-factories>
</workletDefinition>
--- End code ---


My UserFactory (As the user does not play a role in my test scenario because I generate my network traffic with a differnt application, the factory does nothing):



--- Code: ---public class EnergyEfficiencyUserFactory extends
AbstractUserFactory<EnergyEfficiencyUser> {

public EnergyEfficiencyUserFactory() throws IOException {
}

@Override
public synchronized EnergyEfficiencyUser createUser(
WorkletContext<EnergyEfficiencyUser> workletContext, int userId)
throws InvalidConfigurationException, FatalWorkletException {
return new EnergyEfficiencyUser(workletContext.getWorklet(), userId);
}
}
--- End code ---


My user (As said before, users are not important in my setup):



--- Code: ---public class EnergyEfficiencyUser extends AbstractUser {
public EnergyEfficiencyUser(Worklet<EnergyEfficiencyUser> worklet, int userId) throws InvalidConfigurationException {
super(worklet, userId);
}
}
--- End code ---


And my reduced test transaction (All will play here. As I said before, I plan to start bash commands here, wait for the result and then collect the results. This reduced transaction consists only of one print command as I want simply see that the transaction works and displays the string on the host (and director) console.  Also the result verification is not implemented yet. Also I plan to parameterize the static class variables in the future).



--- Code: ---public class EnergyEfficiencyMetricsTransaction extends
Transaction<EnergyEfficiencyUser, String, Boolean> {

private static final String command = "echo 'password' | sudo -S python";
private static final String path = " /usr/local/lib/python2.7/dist-packages/ostinato/";

@Override
public String generateInput(EnergyEfficiencyUser user)
throws TransactionFailedException, FatalWorkletException {

return "Nothing";
}

@Override
public Boolean process(EnergyEfficiencyUser user, String word)
throws TransactionFailedException, FatalWorkletException {

String finalCommand = command + path + "firewallTest0" + ".py";

System.out.println("It's working!");

return true;
}

@Override
public boolean verifyResults(EnergyEfficiencyUser user, String input,
Boolean results) {
return true;
}

@Override
public String getTransactionName() {
return "Firewall";
}
}
--- End code ---


I personally do not know where my error lies. According to the tutorial, the transaction should work. But it has no effect on the console.

Have I made some mistakes in the configuration or does simple print commands not work. However, by looking through the other code, there are plenty of other print commands, which clearly works.

Thank you very much in advance.

JeremyArnold:
The transaction will run in the Chauffeur Client JVM, so your println output won't appear in the Director or Host console.  It should go to the client.0.out file.

At a glance, your code looks like it should be okay.  I can take a closer look if you're not seeing the output in client.0.out

TheKahn:
Hi,

I looked at my client.0.out but the no entry in the log.

Here is the log by the way, as my host runs on a Ubuntu Server 14.04.2  the lspu command does not work, the numactl alternative works however.



--- Code: ---Connecting to Host at localhost:58792
Nov 14, 2015 1:41:50 PM org.spec.chauffeur.client.ClientJvm main
INFORMATION: Connection established to Host at localhost:58792
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.env.LinuxEnvironment getNodeList
WARNUNG: Exception occurred while discovering CPU topology via lscpu.  Attempting to use numactl / cpuinfo.
java.io.IOException: Output on stderr while running 'lscpu -a -p=CPU,CORE,SOCKET,NODE,CACHE,ONLINE': lscpu: $
        at org.spec.chauffeur.env.LinuxEnvironment.getLscpuEntries(LinuxEnvironment.java:347)
        at org.spec.chauffeur.env.LinuxEnvironment.initNodeListViaLscpu(LinuxEnvironment.java:196)
        at org.spec.chauffeur.env.LinuxEnvironment.getNodeList(LinuxEnvironment.java:184)
        at org.spec.chauffeur.env.LinuxEnvironment.getNumaNodeCount(LinuxEnvironment.java:178)
        at org.spec.chauffeur.env.AbstractEnvironment.toString(AbstractEnvironment.java:661)
        at java.lang.String.valueOf(String.java:2994)
        at java.lang.StringBuilder.append(StringBuilder.java:131)
        at org.spec.chauffeur.client.ClientJvm.main(ClientJvm.java:145)

Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [Chauffeur, 4, org.spec.chauffeur.host.ClientInfo@ca001df6]' to Host 'send$
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.AbstractSuite checkClasspathSignatures
WARNUNG: Signature verification failed because signature information not available
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.AbstractSuite verifySignatures
WARNUNG: Signature verification failed because signature information not available
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Running suite ChauffeurTest with Chauffeur 1.1.0 (20150505)
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Running workload Energy Efficiency Metrics Test
ClientWorklet.maxUsers: 1
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Running worklet Energy Efficiency Test Worklet
Forcing GC before worklet
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.AbstractSuite verifySignatures
WARNUNG: Signature verification failed because signature information not available
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Started ClientPhase[warmup]
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Started sequence ClientSequence[sequence]
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@1c53fd30]' to Host 'sender'
Completed sequence ClientSequence[sequence]
Nov 14, 2015 1:41:51 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@282ba1e]' to Host 'sender'
Completed ClientPhase[warmup]
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Started ClientPhase[calibration]
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0]' to Host 'sender'
Started sequence ClientSequence[sequence]
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@13b6d03]' to Host 'sender'
Completed sequence ClientSequence[sequence]
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@f5f2bb7]' to Host 'sender'
Completed ClientPhase[calibration]
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@73035e27]' to Host 'sender'
Worklet Energy Efficiency Test Worklet completed
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@64c64813]' to Host 'sender'
Workload Energy Efficiency Metrics Test completed
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.common.Communicator sendRequest
INFORMATION: Sending request 'OutputMessage: [0, org.spec.chauffeur.metrics.Metrics@3ecf72fd]' to Host 'sender'
Suite ChauffeurTest completed
Nov 14, 2015 1:41:52 PM org.spec.chauffeur.AbstractSuite verifySignatures
WARNUNG: Signature verification failed because signature information not available
--- End code ---

Thank you very much in advance.

Navigation

[0] Message Index

[#] Next page

Go to full version