Shopify / Shopify/toxiproxy

how to specify multiple attributes? incorrect handling of errors

Open
#139 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
12.4k
Forks
510
PR merge metrics
No merged PRs in 30d

Description

problem 1) it's unclear how to specify multiple attributes when adding a toxic.
the example in the readme only uses one attribute
(https://github.com/Shopify/toxiproxy#cli-example)
and the cli help docs don't specify how to specify multiple attributes (see help msg below). as a user I'm guessing either specify -a key=val,key2=val2 or -a key=val -a key2=val2

cli toxic add                                                                                                                                                          
NAME:
   toxiproxy-cli toxic add - add a new toxic

USAGE:
   toxiproxy-cli toxic add [command options] <proxyName>

OPTIONS:
   --toxicName value, -n value    name of the toxic
   --type value, -t value         type of toxic
   --toxicity value, --tox value  toxicity of toxic
   --attribute value, -a value    toxic attribute in key=value format
   --upstream, -u                 add toxic to upstream
   --downstream, -d               add toxic to downstream

Proxy name is required as the first argument.

problem 2) either approach i guessed above seems to work sort of, but things aren't exactly working.

approach 1 - comma separated items - seems to be the right way, see this run in the latest docker container...

$ toxiproxy-cli create cassandra -l 0.0.0.0:9042 -u cassandra:9042
Created new proxy cassandra
$ toxiproxy-cli list
root@toxiproxy:/app/src/github.com/Shopify/toxiproxy# toxiproxy-cli list
Listen          Upstream        Name    Enabled Toxics
======================================================================
[::]:9042       cassandra:9042  cassandra       true    None

Hint: inspect toxics with `toxiproxy-cli inspect <proxyName>`
$ toxiproxy-cli toxic add -t latency -a latency=1000,jitter=500 cassandra                                                                 
Added downstream latency toxic 'latency_downstream' on proxy 'cassandra'
$ toxiproxy-cli list                                                     
Listen          Upstream        Name    Enabled Toxics
======================================================================
[::]:9042       cassandra:9042  cassandra       true    1

Hint: inspect toxics with `toxiproxy-cli inspect <proxyName>`
$ toxiproxy-cli inspect cassandra
Name: cassandra Listen: [::]:9042       Upstream: cassandra:9042
======================================================================
Upstream toxics:
Proxy has no Upstream toxics enabled.

Downstream toxics:
latency_downstream: type=latency stream=downstream toxicity=1.00 attributes=[ jitter=500 latency=1000 ]

Hint: add a toxic with `toxiproxy-cli toxic add`

... so the inspect output looks good. however, I'm having issues getting it to work. it seems to be deplaying requests some of the time but also long periods of undelayed, non-toxic proxying.

so I tried the other way but now latency is set to 0 for some reason, so maybe it's the comma separated approach after all?
edit: in testing the toxic does seem to work effectively

root@toxiproxy:/app/src/github.com/Shopify/toxiproxy# toxiproxy-cli list
Listen          Upstream        Name    Enabled Toxics
======================================================================
[::]:9042       cassandra:9042  cassandra       true    None

Hint: inspect toxics with `toxiproxy-cli inspect <proxyName>`
root@toxiproxy:/app/src/github.com/Shopify/toxiproxy# toxiproxy-cli toxic add -t latency -a latency=1000 -a jitter=500 cassandra                                                              
Added downstream latency toxic 'latency_downstream' on proxy 'cassandra'
root@toxiproxy:/app/src/github.com/Shopify/toxiproxy# toxiproxy-cli list                                                        
Listen          Upstream        Name    Enabled Toxics
======================================================================
[::]:9042       cassandra:9042  cassandra       true    1

Hint: inspect toxics with `toxiproxy-cli inspect <proxyName>`
root@toxiproxy:/app/src/github.com/Shopify/toxiproxy# toxiproxy-cli inspect cassandra
Name: cassandra Listen: [::]:9042       Upstream: cassandra:9042
======================================================================
Upstream toxics:
Proxy has no Upstream toxics enabled.

Downstream toxics:
latency_downstream: type=latency stream=downstream toxicity=1.00 attributes=[ jitter=500 latency=0 ]

Hint: add a toxic with `toxiproxy-cli toxic add`
root@toxiproxy:/app/src/github.com/Shopify/toxiproxy# 

When I try this outside of the docker container, using the latest code in git, the comma separated approach doesn't work at all and I have to switch to multiple -a args

$ ./cli toxic add -t latency -a latency=1000,jitter=500 web
Failed to add toxic: AddToxic: HTTP 400: bad request body: json: cannot unmarshal string into Go value of type int64

$ ./cli toxic add -t latency -a latency=1000 -a jitter=500 web
Added downstream latency toxic 'latency_downstream' on proxy 'web'

the first one submits json like:

{"name":"","type":"latency","stream":"downstream","toxicity":1,"attributes":{"latency":"1000,jitter=500"}}

which looks invalid. the second approach submits:

{"attributes":{"latency":1000,"jitter":500},"name":"latency_downstream","type":"latency","stream":"downstream","toxicity":1}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the README CLI example and the toxiproxy-cli toxic add help output, then compare the two JSON payloads shown for comma-separated and repeated -a arguments. Done means the supported syntax is documented and multiple toxic attributes are parsed consistently into valid numeric values.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.