From ab4f997283e8880f5055322fa1cf6d686a019933 Mon Sep 17 00:00:00 2001 From: Bruno Moura Date: Mon, 2 Mar 2020 12:10:35 +0000 Subject: [PATCH] Fixes for 0.2.1 (#21) * remove stale config example * update docker-compose to relect new configuration using flags * update readme to reflect execution mode changes and remove gitlab-ci badge which is not visible to everyone * documentation updates for running replicant * make explicit commment about runnning for test development --- README.md | 52 +++++++++++++++++++++++++++++++++------------ docker-compose.yaml | 14 ++++-------- example-config.yaml | 42 ------------------------------------ 3 files changed, 42 insertions(+), 66 deletions(-) delete mode 100644 example-config.yaml diff --git a/README.md b/README.md index 708bbcc..bc14439 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/Unbabel/replicant?style=flat-square)](https://goreportcard.com/report/github.com/Unbabel/replicant) [![GoDoc](https://img.shields.io/badge/api-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/Unbabel/replicant) [![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/unbabel/replicant?style=flat-square)](https://hub.docker.com/r/unbabel/replicant) -[![pipeline status](https://gitlab.com/Unbabel/sre-team/replicant/badges/master/pipeline.svg)](https://gitlab.com/Unbabel/sre-team/replicant/-/commits/master)
- Replicant is a synthetic testing service named after the bioengineered androids from Blade Runner. (all synthetics came from Blade Runner :) @@ -14,25 +12,48 @@ It allows web application testing using chromedp, and api application testing us ***Under heavy development and API changes are expected. Please file an issue if anything breaks.*** -## Requirements +## Runing replicant + +The replicant binary packs all functionality needed to run the server, executor and run local execution of tests for development or CI/CD purposes. + +### Locally for test development purposes + +```bash +/path/to/replicant run --file api-test.yaml +``` + +If running locally from with the replicant binary a local chrome web browser with the development protocol can be specified: + +```bash +/path/to/replicant run --chrome-remote-url http://127.0.0.1:9222 --file web-test.yaml +``` + +To have the local chrome browser started with the developer protocol enabled: + +```bash +/path/to/chrome --remote-debugging-port=9222 +``` + +### Configuration options -* Go 1.13 -* External URL for API tests that require webhook based callbacks -* Chrome with remote debugging (CDP) either in headless mode or in foreground (useful for testing) +Please see: -## Examples +```bash +/path/to/replicant --help +``` -## Running the replicant server locally with docker +### Replicant server and executor locally with docker -Using [example config](https://github.com/Unbabel/replicant/blob/master/example-config.yaml) from the project root dir. +The unbabel/replicant docker image packs everything needed to run and manage tests for both web apps and APIs. +See the example `docker-compose.yaml` for more information. ```bash docker stack deploy -c $PWD/docker-compose.yaml replicant ``` -This will deploy the replicant server and 2 chrome-headless nodes for web tests, persisting data under /data. +This will deploy the replicant server and 2 replicant executor nodes for web tests. -### Web application testing (local development) +### Web application testing Web application testing support is based on the FQL (Ferret Query Language), [documentation](https://github.com/MontFerret/ferret). @@ -98,14 +119,16 @@ script: | } ``` -### API testing (local development) +### API testing ##### Using the javascript driver The following API is exposed by the javascript driver in order to perform HTTP calls and logging: * `replicant.Log(string)` log messages from the javascript test on the replicant server log. -* `replicant.NewResponse()` create a new response object to be returned as a result of the test, which should be modified accordingly to reflect the test result. The response must be returned as a serialized JSON object by calling its bounded method `Response.JSON`, E.g. `return response.JSON()`. -Response type attributes: + +* `replicant.NewResult()` create a new response object to be returned as a result of the test, which should be modified accordingly to reflect the test result. The response must be returned as a serialized JSON object by calling its bounded method `Response.JSON`, E.g. `return response.JSON()`. + +Result type attributes: ```js { Data: "", @@ -113,6 +136,7 @@ Response type attributes: Failed: false, } ``` + * `replicant.http.NewRequest()` creates a new HTTP request object for performing HTTP calls. HttpRequest attributes: diff --git a/docker-compose.yaml b/docker-compose.yaml index 177487f..c8aa0ed 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,21 +3,15 @@ version: "3.7" services: server: image: docker.io/unbabel/replicant:latest + command: /app/replicant server --listen-address 0.0.0.0:8080 --executor-url http://executor:8080 ports: - "8080:8080" - volumes: - - data:/data - configs: - - config.yaml - command: /app/replicant -config /config.yaml - cdp: - image: docker.io/unbabel/replicant:replicant-cdp-latest + executor: + image: docker.io/unbabel/replicant:latest + command: /app/replicant executor --listen-address 0.0.0.0:8080 --chrome-enable-local --server-url http://server:8080 deploy: mode: replicated replicas: 2 volumes: data: null -configs: - config.yaml: - file: ./example-config.yaml diff --git a/example-config.yaml b/example-config.yaml deleted file mode 100644 index d7839bd..0000000 --- a/example-config.yaml +++ /dev/null @@ -1,42 +0,0 @@ -debug: false # Register server profiling endpoints -log_level: INFO # Log level -api_prefix: /api # API prefix for the api endpoints -store_uri: "s3://AKIAXL6UM6PK6GGRIKEN:bsbvn7o5pTgUp1CC9w3tUbgFt6UidP3EU9NQssEm@thisismyawesomebucket/testy?region=eu-west-1" -server: - listen_address: 0.0.0.0:8080 # Address to listen on - write_timeout: 5m # API write timeout - read_timeout: 5m # Read timeout - read_header_timeout: 5m # Header read timeout -drivers: - web: - server_url: http://replicant_cdp:9222 # URL of the CDP server for web application transactions, can by overridden by the cdp_address in transaction inputs - dns_discovery: true # Discover servers IP address from DNS - proxied: true # Proxy chromedp to a replicant executor -emitters: - stdout: # Emit results to standard output in JSON format - pretty: false # Pretty printing of JSON results - prometheus: - path: /metrics # Path for prometheus endpoint - labels: # Prometheus metrics labels, must be specified in transactions metadata - - transaction - - application - - environment - - component - gauges: true # Record gauges - summaries: true # Record summaries - summary_objectives: # Summary objectives to record - 0.5: 0.05 - 0.9: 0.01 - 0.99: 0.001 - elasticsearch: # Emit result data for elasticsearch - username: "" # Elasticsearch username - password: "" # Elasticsearch password - urls: [] # Elasticsearch nodes URL - index: "" # Elasticsearch index to write to - max_pending_bytes: 0 # Maximum number of pending bytes to buffer before sending data - max_pending_results: 0 # Maximum number of pending results to buffer before sending data - max_pending_time: 0s # Maximum time to buffer before sending data -callbacks: - webhook: # Listen for asynchronous transaction responses via webhooks - advertise_url: http://0.0.0.0:8080 # External URL to advertise for webhooks - path_prefix: /api/callback # Path prefix for webhooks, transaction uid will be appended to it