Class ExternalSutController

java.lang.Object
org.evomaster.client.java.controller.internal.SutController
org.evomaster.client.java.controller.ExternalSutController
All Implemented Interfaces:
CustomizationHandler, SutHandler

public abstract class ExternalSutController extends SutController
  • Field Details

    • PROP_MUTE_SUT

      public static final String PROP_MUTE_SUT
      System property to avoid printing the console output of the SUT.
      See Also:
    • process

      protected volatile Process process
  • Constructor Details

    • ExternalSutController

      public ExternalSutController()
  • Method Details

    • setJaCoCo

      public final ExternalSutController setJaCoCo(String jaCoCoAgentLocation, String jaCoCoCliLocation, String jaCoCoOutputFile, int port)
    • getWaitingSecondsForIncomingConnection

      public int getWaitingSecondsForIncomingConnection()
    • setupForGeneratedTest

      public final void setupForGeneratedTest()
      Description copied from interface: SutHandler
      There might be different settings based on when the SUT is run during the search of EvoMaster, and when it is later started in the generated tests.
    • setNeedsJdk17Options

      public final void setNeedsJdk17Options(boolean needsJdk17Options)
      Unfortunately, the use of --add-opens in JDK 17+ has broken many things... :( If you are using JDK 17 or above, you must set this to true
      Parameters:
      needsJdk17Options -
    • setInstrumentation

      public final void setInstrumentation(boolean instrumentation)
    • getInputParameters

      public abstract String[] getInputParameters()
      Returns:
      the input parameters with which the system under test should be started
    • getJVMParameters

      public abstract String[] getJVMParameters()
      Returns:
      the JVM parameters (eg -X and -D) with which the system under test should be started
    • getBaseURL

      public abstract String getBaseURL()
      Returns:
      the base URL of the running SUT, eg "http://localhost:8080". Note: this value will likely depend on how getInputParameters() has been implemented
    • getPathToExecutableJar

      public abstract String getPathToExecutableJar()
      Returns:
      a String representing either a relative or absolute path to the where the JAR of the system under test is located
    • getLogMessageOfInitializedServer

      public abstract String getLogMessageOfInitializedServer()
      Returns:
      a string subtext that should be present in the logs (std output) of the system under test to check if the server is up and ready. If there is the need to do something more sophisticated to check if the SUT has started, then this method should be left returning null, and rather override the method isSUTInitialized()
    • isSUTInitialized

      public Boolean isSUTInitialized()
      a customized interface to implement for checking if the system under test is started. by default (returning null), such check is performed based on messages in log.
      Returns:
      Boolean representing if the system under test is up and ready.
    • getMaxAwaitForInitializationInSeconds

      public abstract long getMaxAwaitForInitializationInSeconds()
      Returns:
      how long (in seconds) we should wait at most to check if SUT is ready and initialized (this related to the getLogMessageOfInitializedServer() method)
    • preStart

      public abstract void preStart()
      If the SUT needs some third-party processes (eg a non-embedded database), here they can be configured and started. This method is going to be called before we start the SUT.
    • postStart

      public abstract void postStart()
      This method is going to be called after the SUT is started.
    • preStop

      public abstract void preStop()
      This method is going to be called before the SUT is stopped.
    • postStop

      public abstract void postStop()
      If the SUT needs some third-party processes (eg a non-embedded database), here we can shut them down once the SUT has been stopped.
    • setJavaCommand

      public final ExternalSutController setJavaCommand(String command)
    • startSut

      public final String startSut()
      Description copied from interface: SutHandler

      Start a new instance of the SUT.

      This method must be blocking until the SUT is initialized.

      How this method is implemented depends on the library/framework in which the application is written. For example, in Spring applications you can use something like: SpringApplication.run()

      Returns:
      the base URL of the running SUT, eg "http://localhost:8080"
    • isSutRunning

      public final boolean isSutRunning()
      Description copied from class: SutController

      Check if the system under test (SUT) is running and fully initialized

      How to implement this method depends on the library/framework used to build the application. In Spring applications, this can be done with something like: ctx != null && ctx.isRunning(), where ctx is a field where ConfigurableApplicationContext should be stored when starting the application.

      Specified by:
      isSutRunning in class SutController
      Returns:
      true if the SUT is running
    • stopSut

      public final void stopSut()
      Description copied from interface: SutHandler

      Stop the SUT.

      How to implement this method depends on the library/framework in which the application is written. For example, in Spring applications you can save in a variable the ConfigurableApplicationContext returned when starting the application, and then call stop() on it here.

    • isInstrumentationActivated

      public final boolean isInstrumentationActivated()
      Description copied from class: SutController
      Check if bytecode instrumentation is on.
      Specified by:
      isInstrumentationActivated in class SutController
      Returns:
      true if the instrumentation is on
    • isConnectedToServerController

      public final boolean isConnectedToServerController()
    • newSearch

      public final void newSearch()
      Description copied from class: SutController
      Re-initialize all internal data to enable a completely new search phase which should be independent from previous ones
      Specified by:
      newSearch in class SutController
    • newTestSpecificHandler

      public final void newTestSpecificHandler()
      Specified by:
      newTestSpecificHandler in class SutController
    • getTargetInfos

      public final List<org.evomaster.client.java.instrumentation.TargetInfo> getTargetInfos(Collection<Integer> ids, boolean fullyCovered, boolean descriptiveIds)
      Specified by:
      getTargetInfos in class SutController
    • getAdditionalInfoList

      public final List<org.evomaster.client.java.instrumentation.AdditionalInfo> getAdditionalInfoList()
      Specified by:
      getAdditionalInfoList in class SutController
      Returns:
      additional info for each action in the test. The list is ordered based on the action index.
    • getBootTimeInfoDto

      public org.evomaster.client.java.controller.api.dto.BootTimeInfoDto getBootTimeInfoDto()
      Specified by:
      getBootTimeInfoDto in class SutController
    • newActionSpecificHandler

      public final void newActionSpecificHandler(org.evomaster.client.java.controller.api.dto.ActionDto dto)
      Specified by:
      newActionSpecificHandler in class SutController
    • newScheduleActionSpecificHandler

      public final void newScheduleActionSpecificHandler(org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationDto dto)
      Specified by:
      newScheduleActionSpecificHandler in class SutController
    • getUnitsInfoDto

      public final org.evomaster.client.java.controller.api.dto.UnitsInfoDto getUnitsInfoDto()
      Specified by:
      getUnitsInfoDto in class SutController
    • setKillSwitch

      public final void setKillSwitch(boolean b)
      Specified by:
      setKillSwitch in class SutController
    • setExecutingInitSql

      public final void setExecutingInitSql(boolean executingInitSql)
      Specified by:
      setExecutingInitSql in class SutController
    • setExecutingInitMongo

      public final void setExecutingInitMongo(boolean executingInitMongo)
      Specified by:
      setExecutingInitMongo in class SutController
    • setExecutingInitRedis

      public final void setExecutingInitRedis(boolean executingInitRedis)
      Specified by:
      setExecutingInitRedis in class SutController
    • setExecutingAction

      public final void setExecutingAction(boolean executingAction)
      Specified by:
      setExecutingAction in class SutController
    • bootingSut

      public final void bootingSut(boolean bootingSut)
      Description copied from class: SutController
      specify whether the SUT is booting (ie starting up), or not. this is needed because we don't want to handle targets covered at startup during the fitness evaluations
      Specified by:
      bootingSut in class SutController
    • getExecutableFullPath

      public final String getExecutableFullPath()
      Specified by:
      getExecutableFullPath in class SutController
    • getJvmDtoSchema

      public final void getJvmDtoSchema(List<String> dtoNames)
      Specified by:
      getJvmDtoSchema in class SutController
    • startExternalProcessPrinter

      protected void startExternalProcessPrinter(boolean checkSutInitializedWithLog)