artillery-engine-grpc icon indicating copy to clipboard operation
artillery-engine-grpc copied to clipboard

Using config variables

Open samisagit opened this issue 4 years ago • 2 comments

It appears that, when using the grpc engine, variables are used literally. In this case I would expect {{ email }} to be replaced with [email protected] however my server receives the string of {{ email }}. Is this expected when using the grpc engine? It would be really useful to be able to use variables, especially when combined with tools like faker to create randomish test data.

(Apologies if there are any yaml formatting inconsistencies, GitHub didn't handle pasting too well)

config:                                                                                                                                                                                                     
  target: 0.0.0.0:8080                                                                                                                                                                                      
  phases:                                                                                                                                                                                                   
    - duration: 5                                                                                                                                                                                           
      arrivalRate: 1                                                                                                                                                                                        
  variables:                                                                                                                                                                                                
    email: "[email protected]"                                                                                                                                                                                   
  engines:                                                                                                                                                                                                  
    grpc:                                                                                                                                                                                                   
      channelOpts:                                                                                                                                                                                          
        grpc.client_idle_timeout_ms: 1000                                                                                                                                                                   
      protobufDefinition:                                                                                                                                                                                   
        filepath: ../../services/authentication/pb/authentication.proto                                                                                                                                     
        package: services.authentication.pb                                                                                                                                                                 
        service: Auth                                                                                                                                                                                       
      protoLoaderConfig:                                                                                                                                                                                    
        keepCase: true                                                                                                                                                                                      
        longs: String                                                                                                                                                                                       
        enums: String                                                                                                                                                                                       
        bytes: Buffer                                                                                                                                                                                       
        defaults: false                                                                                                                                                                                     
        arrays: false                                                                                                                                                                                       
        objects: false                                                                                                                                                                                      
        oneofs: true                                                                                                                                                                                        
      metadata:                                                                                                                                                                                             
        "pointlesskey": "stringvalue"                                                                                                                                                                       
                                                                                                                                                                                                              
  scenarios:                                                                                                                                                                                                  
    - name: test Auth running at http://0.0.0.0:8080                                                                                                                                                          
      engine: grpc                                                                                                                                                                                            
      flow:                                                                                                                                                                                                   
        - Register:                                                                                                                                                                                           
            email: "{{ email }}"

samisagit avatar Nov 18 '20 08:11 samisagit

I've got the same problem, looks like this can be fixed by changing const args = ops[rpcName] -> const args = this.helpers.template(ops[rpcName], context) in the step function @kenju

bmurphy421 avatar Jul 02 '21 21:07 bmurphy421

@bmurphy421 @samisagit

Thanks for your report & your contribution at #40!

v0.0.9 is now available. Could you confirm that variables template works as expected? Thank you.

kenju avatar Jul 09 '21 14:07 kenju