Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Runner

Every runner instance manages a single container. There can be only one code file at the same time in each container. There can be multiple runners active simultaneously.

Hierarchy

  • Runner

Index

Constructors

constructor

  • new Runner(dockerOptions?: Docker.DockerOptions, imageName?: string): Runner
  • Creates a Runner instance.

    Parameters

    • Optional dockerOptions: Docker.DockerOptions

      Options passed to dockerode constructor.

    • Default value imageName: string = "dominikkorsa/runner:2.1.1"

      Container image to use instead of the default one.

    Returns Runner

Properties

Readonly docker

docker: Docker

Private exitHandlers

exitHandlers: (() => unknown)[] = []

Private Optional extension

extension: Extension

Private Readonly imageName

imageName: string

Private Optional instance

instance: undefined | { container: Docker.Container; rl: readline.ReadLine; stream: ReadWriteStream }

Private resultsQueue

resultsQueue: ((result: Result) => unknown)[] = []

Methods

Private execCommand

  • execCommand(cmd: string[]): Promise<void>

getOutput

  • getOutput(outputContainerPath: string): Promise<Buffer>

Private handleLine

  • handleLine(line: string): Promise<void>

isImagePulled

  • isImagePulled(): Promise<boolean>
  • Checks if container image is pulled.

    Returns Promise<boolean>

isStarted

  • isStarted(): boolean
  • Returns true if the container has been started and false otherwise

    Returns boolean

Private onEnd

  • onEnd(): Promise<void>

ping

  • ping(): Promise<boolean>
  • Attempts to connect to the Docker daemon. Returns true if successful, false otherwise.

    Returns Promise<boolean>

pullImage

  • pullImage(): Promise<void>
  • Pulls the container image to the machine running Docker. Returns when completed.

    Returns Promise<void>

removeImage

  • removeImage(): Promise<void>
  • Removes the container image from the machine running Docker.

    Returns Promise<void>

run

  • run(inputContainerPath: string, timeout: number): Promise<Result>
  • Adds the input to the run queue, then tests the sent code against an input.

    Parameters

    • inputContainerPath: string

      Path to input file on the container. Return value of sendInput.

    • timeout: number

      Time in seconds after which the test will fail.

    Returns Promise<Result>

sendCode

  • sendCode(data: string | Buffer, extension: string): Promise<void>
  • Sends code to be used for testing. There can only be one code file at the same time.

    throws

    UnknownExtensionError

    Parameters

    • data: string | Buffer

      Content of the code to send.

    • extension: string

      Extension of the code file, for example: .cpp. Supported languages: Extension.

    Returns Promise<void>

sendInput

  • sendInput(data: string | Buffer): Promise<string>
  • Sends input to the container There can be multiple input files on the docker container

    Parameters

    • data: string | Buffer

      input data to be sent

    Returns Promise<string>

    Path to input file on the container.

sendInputs

  • sendInputs(inputs: (string | Buffer)[]): Promise<string[]>
  • Sends multiple inputs to the container There can be multiple input files on the docker container

    Parameters

    • inputs: (string | Buffer)[]

      array of inputs data to be sent

    Returns Promise<string[]>

    Path to input files on the container, in the same order as inputs

start

  • start(): Promise<void>
  • Starts the docker container. Does nothing if already started.

    Returns Promise<void>

stop

  • stop(): Promise<void>
  • Stops the docker container. Does nothing if not started.

    Returns Promise<void>

Generated using TypeDoc