ryos-io / Rhino

Rhino: Dockerized Distributed Load and Performance Testing Framework
http://ryos.io
Apache License 2.0
18 stars 3 forks source link

Reactive DSL continues #44

Closed reevik closed 5 years ago

reevik commented 5 years ago

@luxmeter This PR is a milestone for reactive implementation. It comprises a new design as well as newer concepts like injectors. The framework is now capable to inject new providers into injection points instead of values provided by these providers. It is important because the DSLs may want to access these fields/providers respectively and every access must give a new object to the DSL via provider. Inject-a-value still works for scenario approach.

DSL now offers a new Spec that is "SomeSpec" which enables developers add custom lambdas and arbitrary code snippet to execute. This is very handy for sleep tests, that do not require any connectivity.

A new concept "SimulationInjectors" have been introduced. SimulationInjectors are the implementations which take on injection implementation. They depend on the runner's implementation, so reactive injectors injects providers whereas the default runner's provides the values at injection points.

An example DSL may look as follows: https://github.com/bagdemir/Rhino/pull/44/files#diff-037ff9e140088255a0bca0cc11cc1ee3R38

@Simulation(name = "Reactive Sleep Test")
@Runner(clazz = ReactiveHttpSimulationRunner.class)
public class ReactiveSleepTestSimulation {

  @Feeder(factory = UUIDProvider.class)
  private UUIDProvider provider;

  @Dsl(name = "Sleep Test")
  public LoadDsl testSleep() {
    return Start
        .spec()
        .run(some("Sleeping 1 sec.").is((userSession, measurement) -> {
          waitASec();
          measurement.measure("1. measurement", "OK");
          userSession.add("random", new Random().nextInt());
          return userSession;
        }))
        .run(some("2. measurement").is((userSession, measurement) -> {
          waitASec();
          measurement.measure("2. measurement", "OK");
          userSession.get("uuid").map(a -> (Integer) a).map(a -> a++)
              .ifPresent(System.out::println);
          return userSession;
        }));
  }

Another new concept is the user sessions which are passed from one spec to another one in the DSL chain. The session is a context being forwarded to the next spec containing contextual data.

The PR is targeting following points:

Still open: