Skip to content

Traces log for command to include exec content and full stdout/stderr #816

@gberche-orange

Description

@gberche-orange

Describe the feature:

With complex commands, the exec field conveniently enables to use multiline strings. However, the content of the exec field is not yet printed in with trace level. It would also be useful to have the full stdout and stderr be printed.

Given following goss.yaml

command:
    display-gcloud-sql-instances-with-labels:
      exec: |
        echo "current list of sql instances in the gcp project:"
        for i in $(gcloud sql instances list --format="value(name)"); do printf "\n\n$i :\n"; gcloud sql instances describe $i | yq '[.createTime, .settings.userLabels]'  ; done
      exit-status: 0
    no-sql-instance-remaining-for-current-namespace:
      exec: |
        gcloud sql instances list --filter="labels.xrc_namespace:$NAMESPACE"
      exit-status: 0
      stdout:
        - "Listed 0 items"

the command goss -L TRACE validate does not output the executed commands and their current stdout/stderr

image

cloudsdk@gcp-gcloud-cli-5c74f98554-26t58:~$ /home/cloudsdk/bin/goss -L TRACE -g /home/cloudsdk/goss.yaml validate 
2023/07/07 09:03:51 [DEBUG] Setting log level to TRACE
2023/07/07 09:03:56 [WARN] FAIL: Command => no-sql-instance-remaining-for-current-namespace (exit-status [0] [1]) [5.63]
F2023/07/07 09:03:56 [WARN] FAIL: Command => no-sql-instance-remaining-for-current-namespace (stdout [Listed 0 items] []) [0.00]
F2023/07/07 09:04:01 [WARN] FAIL: Command => display-gcloud-sql-instances-with-labels (exit-status [] []) [10.00]
F

Failures/Skipped:

Command: no-sql-instance-remaining-for-current-namespace: exit-status:
Expected
    <int>: 1
to equal
    <int>: 0
Command: no-sql-instance-remaining-for-current-namespace: stdout: patterns not found: [Listed 0 items]

display-gcloud-sql-instances-with-labels: exit-status: Error: Command execution timed out (10s)

Total Duration: 10.001s
Count: 3, Failed: 3, Skipped: 0
2023/07/07 09:04:01 [WARN] FAIL SUMMARY: Total Duration: 10.001s Count: 3, Failed: 3, Skipped: 0 

Describe the solution you'd like

Describe alternatives you've considered

the json format to include an additional field with the command exec original output. Currently it only displays the matcher output and matcher expected output

goss -L TRACE -g /home/cloudsdk/goss.yaml validate --format json -o verbose | yq -P
[...]
  - duration: 25336                                                                                                                                                                                        
    err: null                                                                                                                                                                                              
    expected:                                                                                                                                                                                              
      - value                                                                                        
    found: null                                                                                                                                                                                            
    human: ""                                                                                                                                                                                              
    meta: null                                                                                                                                                                                             
    property: stdout
    resource-id: gcloud sql instances list                                                                                                                                                                 
    resource-type: Command                                                                           
    result: 1                                                                                                                                                                                              
    skipped: false                                                                                   
    successful: false                                                                                                                                                                                      
    summary-line: 'Command: gcloud sql instances list: stdout: patterns not found: [value]'                                                                                                                
    test-type: 2                                                                                                                                                                                           
    title: ""                                                                                                                                                                                              

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions