0

I was not able to find any information regarding configuration of AppDynamics agent for JUnit tests. I would like to test performance of Hibernate queries of Spring based web service backed by PostgreSQL database. Tests must be able to rollback the data at the termination.

Should it be unit or integration tests? What is the best way to accomplish it? How to make AppDynamics collect and display graphs of query execution times?

UPDATE:

I was not able to set up addDynamics agent for JUnit tests inside IDEA. The VM arguments is pointing to agent -javaagent:"C:\Tools\AppDynamicsAgent\javaagent.jar", the firewall is off but for some reason in appdynamics web based (SaaS) set up dialog shows that no agent able to connect:

enter image description here

J.Olufsen
  • 13,415
  • 44
  • 120
  • 185

2 Answers2

0

You need both unit tests and integration tests. Unit tests should not use in database or File, ect. I like to use Spring profiles for my tests. For instance, if I have a profile called integeration_test.

@ActiveProfiles("integeration_test")
@ContextConfiguration(locations = {
        "classpath:you-context.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class DaoTest
{

    @Autowired
    protected DataSource dataSource;

    // delete all your stuff here
    protected void clearDatabase()
    {
        JdbcTemplate jdbc = new JdbcTemplate(dataSource);
        jdbc.execute("delete table");
    }

    @Before
    public final void init()
    {
        clearDatabase();
    }

    @After
    public final void cleanup()
    {
        clearDatabase();
    }

}

(I'm using xml) then in your context do something like: <beans profile="test">TODO </beans> And configure your data-source in there.

I know there are ways to rollback all your transactions after running a test, but I like this better. Just don't delete everything in your real database haha, could even put some safety code in the clearDatabase to make sure that doesn't happen.

For performance testing you will really need to figure out what you want to achieve, and what is meaningful to display. If you have a specific question about performance testing you can ask that, otherwise it is too broader topic.

Maybe you can make a mini-webapp which does performance testing for you and has the results exposed as URL requests for displaying in HTML. Really just depends on how much effort you are willing to spend on it and what you want to test.

Derrops
  • 7,651
  • 5
  • 30
  • 60
0

Once the agent is attached you can use the AppDynamics Database Queries Window

Liam Williams
  • 676
  • 9
  • 16