1 2 Previous Next 23 Replies Latest reply on May 15, 2012 11:38 AM by ziuziu

    Basic configuration

      I am new to Byteman and I am trying to configure it to do some fault injection in my application.

       

      I have a question about how to do it in a way that i can inject the faults during runtime.

       

      I would like my application for example to run normally and that I can login it using the authentication mechanism.

      Then inject and fault and that the authentication mechanism throws and execption of no access to database.

       

      I would like to do it without adding extra code or annotations. Is it possible to do it using rules?

       

      Regards,

      Albert

        • 1. Re: Basic configuration
          funnyrajj

          hii,

             I am also looking forward to fix extra code or annotations problem ...

          • 2. Re: Basic configuration
            adinn

            Hi Albert,

            Albert Tresens wrote:

             

            I am new to Byteman and I am trying to configure it to do some fault injection in my application.

             

            I have a question about how to do it in a way that i can inject the faults during runtime.

             

            I would like my application for example to run normally and that I can login it using the authentication mechanism.

            Then inject and fault and that the authentication mechanism throws and execption of no access to database.

             

            I would like to do it without adding extra code or annotations. Is it possible to do it using rules?

             

            This sounds like exactly the sort of thing Byteman was built to do. You should be able to start your application and then load the Byteman agent and one or two simple Byteman rules to force an authentication failure. You don't need to have any annotations in your code and you don't need to recompile any of your code to use Byteman.

             

            You do need to idenitfy exactly which bit of code you would like to throw an exception or return a FAILURE value in order to be able to write the rule(s) you need. Perhaps you can describe what you want to do in a little more detail -- I might be able to help you write your rules. Alternatively, look at the User Guide and work through Byteman Tutorials Part 1 and Part 2. These are all available on the project documentation page.

             

            It sounds like you definitely should read Tutorial Part 1: Getting Started as it covers loading the Byteman agent and Byteman rules into a running program. Part 2: Fault Injection would also be useful for showing you how to write rules which generate faults. It mostly covers injecting faults into tests run using JUnit and TestNG which you may not want to do but I think you would benefit from reading both tutorials. Please do download the code and rule examples so you can actually try running Byteman.

             

            regards,

             

             

            Andrew Dinn

            • 3. Re: Basic configuration

              Hi Andrew,

              First of all thanks a lot for you input. I will describe my current situation and what I am trying to achieve.

               

              In first place I have an application running in a Jetty server using Akka actors. Byteman seems to be a good tool for fault injection and to test edge cases in an application like that that uses multithreading (correct me if I am wrong as is the first tiem I use it).

              My initial plan is  to creat a .btm script to creat fault injections. My first trial will be with the Login function.

              I guess the way to proceed is to first attach the byteman agent to the PID of the Java process. In my case is running in Jetty.

              I can after check if the .bm scripts are correct and inject them during runtime. I will try to do this experiment at first stage before defining more complex scenarios.

              • 4. Re: Basic configuration
                adinn

                HI Albert

                Albert Tresens wrote:

                 

                In first place I have an application running in a Jetty server using Akka actors. Byteman seems to be a good tool for fault injection and to test edge cases in an application like that that uses multithreading (correct me if I am wrong as is the first tiem I use it).

                My initial plan is  to creat a .btm script to creat fault injections. My first trial will be with the Login function.

                I guess the way to proceed is to first attach the byteman agent to the PID of the Java process. In my case is running in Jetty.

                I can after check if the .bm scripts are correct and inject them during runtime. I will try to do this experiment at first stage before defining more complex scenarios.

                Yes, proceed as described above and pist here if you have any problems with the scripts. Before you upload your scripts (using $BYTEMAN_HOME/bin/bmsubmit.sh) it is a good idea to check them for parse/type errors (using $BYTEMAN_HOME/bin/bmcheck.sh).

                • 5. Re: Basic configuration

                  Any idea what is can be the reason to that:

                   

                  albert@albert:/opt/byteman-download-2.0.1/bin$ ./bminstall.sh 19718

                  com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

                   

                  I am using Tomcat:

                   

                  albert@albert:/opt/byteman-download-2.0.1/bin$ ps -elf | grep java

                  0 S albert    3204  2819  0  80   0 -  2716 pipe_w 17:22 pts/4    00:00:00 grep --color=auto java

                  0 S albert   19718     1  0  80   0 - 1645807 futex_ May04 pts/8  00:02:21 /usr/lib/jvm/java-1.6.0-openjdk/bin/java -Djava.util.logging.config.file=/opt/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat6/endorsed -classpath /opt/tomcat6/bin/bootstrap.jar -Dcatalina.base=/opt/tomcat6 -Dcatalina.home=/opt/tomcat6 -Djava.io.tmpdir=/opt/tomcat6/temp org.apache.catalina.startup.Bootstrap start

                   

                  and the BYTEMAN_HOME enviromental variable is set correctly:

                   

                  albert@albert:/opt/byteman-download-2.0.1/bin$ echo $BYTEMAN_HOME

                  /opt/byteman-download-2.0.1

                   

                  Java version:

                   

                  albert@albert:/opt/byteman-download-2.0.1/bin$ java -version

                  java version "1.7.0_02"

                  Java(TM) SE Runtime Environment (build 1.7.0_02-b13)

                  Java HotSpot(TM) Server VM (build 22.0-b10, mixed mode)

                  • 6. Re: Basic configuration
                    adinn

                    HI Albert,

                    Albert Tresens wrote:

                     

                    Any idea what is can be the reason to that:

                     

                    albert@albert:/opt/byteman-download-2.0.1/bin$ ./bminstall.sh 19718

                    com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

                     

                    I am using Tomcat:

                     

                    albert@albert:/opt/byteman-download-2.0.1/bin$ ps -elf | grep java

                    0 S albert    3204  2819  0  80   0 -  2716 pipe_w 17:22 pts/4    00:00:00 grep --color=auto java

                    0 S albert   19718     1  0  80   0 - 1645807 futex_ May04 pts/8  00:02:21 /usr/lib/jvm/java-1.6.0-openjdk/bin/java -Djava.util.logging.config.file=/opt/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat6/endorsed -classpath /opt/tomcat6/bin/bootstrap.jar -Dcatalina.base=/opt/tomcat6 -Dcatalina.home=/opt/tomcat6 -Djava.io.tmpdir=/opt/tomcat6/temp org.apache.catalina.startup.Bootstrap start

                     

                    and the BYTEMAN_HOME enviromental variable is set correctly:

                     

                    albert@albert:/opt/byteman-download-2.0.1/bin$ echo $BYTEMAN_HOME

                    /opt/byteman-download-2.0.1

                     

                    Java version:

                     

                    albert@albert:/opt/byteman-download-2.0.1/bin$ java -version

                    java version "1.7.0_02"

                    Java(TM) SE Runtime Environment (build 1.7.0_02-b13)

                    Java HotSpot(TM) Server VM (build 22.0-b10, mixed mode)

                     

                    Thanks very much for reporting this problem and providing all the relevant configuration and program output.

                     

                    I am not sure why this has happened but there are several things which might provide the information needed to work out what is going on.

                     

                    Firstly, could you define the verbose system property when you run the bminstall command i.e.

                     

                    $ ./bminstall.sh -Dorg.jboss.byteman.verbose 19781

                     

                    This may provide some useful information when the agent starts up to show why it is not initializing.

                     

                    Second, could you trry starting the Byteman agent on the command line when you start Tomcat. The java command line needs to include extra arguments as shown below

                     

                    java -Dorg,jboss.byteman.verbose -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=listener:true -Djava.util.logging.config.file=/opt/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat6/endorsed -classpath /opt/tomcat6/bin/bootstrap.jar -Dcatalina.base=/opt/tomcat6 -Dcatalina.home=/opt/tomcat6 -Djava.io.tmpdir=/opt/tomcat6/temp org.apache.catalina.startup.Bootstrap start

                     

                    If you are starting tomcat witrh a startup script then you may need to edit the script. Alternatively, you may be able to include the argumets by executing

                     

                    JAVA_OPTS="-Dorg,jboss.byteman.verbose -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=listener:true"

                    export JAVA_OPTS

                     

                    I'll be interested to see any Byteman output written to System.out.

                     

                     

                    Also, did you manage to run the examples from Part 1 of the tutorial? If so then this woudl indicate a Tomcat-specific problem. If not then it might be worth trying it ought.

                     

                    Thanks for any further information you can provide to help identify this problem.

                     

                    regards,

                     

                     

                    Andrew Dinn

                    • 7. Re: Basic configuration

                      The verbose options doesn't seem to add any aditional information;

                       

                      albert@albert:/opt/byteman-download-2.0.1/bin$ ./bminstall.sh -Dorg.jboss.byteman.verbose 19718

                      com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

                      • 8. Re: Basic configuration
                        adinn

                        Hi Albert,

                        Albert Tresens wrote:

                         

                        The verbose options doesn't seem to add any aditional information;

                         

                        albert@albert:/opt/byteman-download-2.0.1/bin$ ./bminstall.sh -Dorg.jboss.byteman.verbose 19718

                        com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

                         

                        Could you try installing the agent by passing  the -javaagent argument on the java command line.

                         

                        Also, you didn't mention whether you could run the tutorial examples. Answering that question will probably make it easier to pin down what is going wrong.

                         

                        regards,

                         

                         

                        Andrew Dinn

                        • 9. Re: Basic configuration

                          Hi Andrew,

                          Did user Jetty with Byteman as well at some point for automated fault injection tests?

                           

                          Regards,

                          Albert

                          • 10. Re: Basic configuration

                            I am trying to configure Jetty to load the agent listener when maven is run.

                            I added the MAVEN_OPTS into the .bashrc so the JVM opts are loaded:

                             

                            export MAVEN_OPTS=-Dorg.jboss.byteman.verbose -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=listener:true

                             

                            However

                             

                            -bash: export: `-javaagent:/opt/byteman-download-2.0.1/lib/byteman.jar=listener:true': not a valid identifier

                            • 11. Re: Basic configuration
                              adinn

                              Hi Albert

                              Albert Tresens wrote:

                               

                              export MAVEN_OPTS=-Dorg.jboss.byteman.verbose -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=listener:true

                               

                              However

                               

                              -bash: export: `-javaagent:/opt/byteman-download-2.0.1/lib/byteman.jar=listener:true': not a valid identifier

                               

                              If you want to put that assignment in your .bashrc you will need to quote it

                               

                              export MAVEN_OPTS="-Dorg.jboss.byteman.verbose -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=listener:true"

                               

                              However, I don't quite understand why you are trying to set MAVEN_OPTS.

                               

                              Are you trying to inject Byteman rules into maven or into Jetty?

                               

                              If you are using maven to run Jetty then setting MAVEN_OPTS will load the byteman agent into the JVM which runs maven when you run mvn from the command line. However, it will not cause the agent to be loaded into the JVM spawend by maven to run Jetty.

                               

                              If you are using Jetty to spawn a JVM which runs maven (which sounds unlikely to me but . . .) then setting MAVEN_OPTS will not work either. MAVEN_OPTS is processed by the mvn shell script. So, ths would only work if Jetty had been programmed to bundle in the value of MAVEN_OPTS is into the Java command line when it created a JVM to run maven.

                              • 12. Re: Basic configuration

                                Hi Andrew,

                                Yes as you say I am trying to load rules in Jetty while Jetty is started by maven: mvn run:jetty.

                                I want to test the rules using the agent so I can load and unload them.

                                 

                                Which is the best way to proceed in this situation.

                                I guess having the agent attached to the Java process is the best solution and then use bmsubmit.sh to load the .btm files.

                                I see its also possiblet to pass the .btm files as parameters in the JVM.

                                 

                                I would like to inject some faults to instruct the application to behaves different when doing some actions.

                                Do you know any simple example I could use?

                                 

                                Thanks

                                • 13. Re: Basic configuration
                                  adinn

                                  HI Albert

                                  Albert Tresens wrote:

                                   

                                  Yes as you say I am trying to load rules in Jetty while Jetty is started by maven: mvn run:jetty.

                                  I want to test the rules using the agent so I can load and unload them.

                                  Ok, it looks to me like maven creates a new JVM to run Jetty. So in that case I think you are limited by the maven Jetty plug-in. It does not appear to allow you to specify Java command line arguments for the JVM it creates to run Jetty. Which means you will not be able to install the agent when the Jetty JVM is started.

                                   

                                  Albert Tresens wrote:

                                   

                                  Which is the best way to proceed in this situation.

                                  I guess having the agent attached to the Java process is the best solution and then use bmsubmit.sh to load the .btm files.

                                  I see its also possible to pass the .btm files as parameters in the JVM.

                                  Assuming the plugin works as above your only option is to load the agent after Jetty has started. So, you need to find the process id of the Jetty JVM. The best way to do that is to execute

                                   

                                  jps -l

                                   

                                  Then you can install the byteman agent using script bminstall.sh

                                   

                                  bminstall.sh -Dorg.jboss.byteman.verbose <pid>

                                   

                                  (replace <pid> with the process id returned by jps).

                                   

                                  After that you should be able to use bmsubmit.sh to load and unload your rules.

                                  • 14. Re: Basic configuration

                                    Hi Andrew,

                                    I get then to the initial point. An then the exception is fired:

                                     

                                    [altr@test-newyork-002 ~]$ jps -l

                                    4042 sun.tools.jps.Jps

                                    29415 org.codehaus.plexus.classworlds.launcher.Launcher

                                    [altr@test-newyork-002 ~]$ $BYTEMAN_HOME/bin/bminstall.sh -Dorg.jboss.byteman.verbose 29415

                                    com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

                                    1 2 Previous Next