An HTTP server instance that allows to control the tool using a REST interface. Moreover, it allows to aggregate stats data coming from multiple running tool instances.

Constructors

  • Server instance. All the HTTP endpoints are protected by basic authentication with user admin and password Server.serverSecret.

    Parameters

    • __namedParameters: {
          pageLogPath: undefined | string;
          serverData: undefined | string;
          serverPort: undefined | number;
          serverSecret: undefined | string;
          serverUseHttps: undefined | boolean;
      } = {}
      • pageLogPath: undefined | string
      • serverData: undefined | string
      • serverPort: undefined | number
      • serverSecret: undefined | string
      • serverUseHttps: undefined | boolean
    • stats: Stats

      A Stats class instance.

    Returns Server

Properties

pageLogPath: string

The file path that will be used to serve the /view/page.log requests.

serverData: string

An optional path that the HTTP server will expose with the /data endpoint.

serverPort: number

The server listening port.

serverSecret: string

The basic auth secret.

serverUseHttps: boolean

If HTTPS protocol should be used.

stats: Stats

A Stats class instance.

Methods

  • DELETE /session endpoint.

    Delete the Session instance identified by the body.id param.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • DELETE /sessions endpoint.

    Delete the Session instances specified by the body.ids array.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • GET /download/alert-rules endpoint.

    Downloads the alert rules report stored into the Stats.alertRulesFilename.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • GET /collected-stats endpoint.

    Returns a JSON array of the last statistics collected from external running tools.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • GET /data/* endpoint.

    Returns the file content relative to the Config serverData path. If the requested path points to a directory, it returns the directory content in tar.gz format.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • GET /download/detailed-stats endpoint.

    Returns the Stats.detailedStatsWriter file content.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • GET /view/docker.log endpoint.

    Returns the Docker logs related to the container running the tool. It requires to run the Docker container with the following options:

      --cidfile /tmp/docker.id
    -v /tmp/docker.id:/root/.webrtcperf/docker.id:ro
    -v /var/lib/docker:/var/lib/docker:ro

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • GET /empty-page endpoint.

    Returns an empty HTML page. Useful for running tests with raw Javascript content without any DOM rendering.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>

    Returns void

  • GET /view/page.log endpoint.

    Returns the page log file content as specified in Config pageLogPath.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • GET /screenshot/ endpoint.

    Returns the page screenshot running inside the Session identified by sessionID. Additional query params:

    • page: the page number (starting from 0) running inside the Session.
    • format: the image format (jpeg, png, webp). Default: webp.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • GET /stats endpoint.

    Returns a JSON array of the last statistics for each running Session.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • GET /download/stats endpoint.

    Returns the Stats.statsWriter file content.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • PUT /collected-stats endpoint.

    Allows to inject Stats metrics coming from an external tool.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns void

  • PUT /session endpoint.

    Starts a new Session. The request body format will be parsed as a SessionParams object.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • PUT /sessions endpoint.

    Starts multiple Session instances as specified into the body.sessions value. The request body will be parsed as a SessionParams object.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • next: NextFunction

    Returns Promise<void>

  • Starts a new Session instance.

    Parameters

    • id: number

      The session unique id.

    • config: SessionParams

      The session configuration.

    Returns Promise<Session>

  • Stops a new Session instance.

    Parameters

    • id: number

      The session unique id.

    Returns Promise<void>