#375 basic role: stdout and stderr in a single file
Merged 5 years ago by astepano. Opened 5 years ago by bgoncalv.
bgoncalv/standard-test-roles fix-role  into  master

@@ -142,7 +142,7 @@ 

          "  result: $result"      \

          "  logs:"  \

          >> "$results"

-     for log in "$logfile_stdout" "$logfile_stderr"; do

+     for log in "$logfile"; do

          if [ -f "$log" ]; then

              local prefixed_log="$STR_ARTIFACTS_DIR/${status}-$(basename $log)"

              mv -f "$log" "$prefixed_log"
@@ -165,11 +165,9 @@ 

  export PATH="$PATH:$STR_WORKDIR"

  mkdir -p "$STR_ARTIFACTS_DIR"

  # add str_ prefix to test logs

- logfile_stdout="$STR_ARTIFACTS_DIR/$(echo "str_$STR_TEST_NAME" | sed -e 's/\//-/g').log"

- logfile_stderr="$STR_ARTIFACTS_DIR/$(echo "str_$STR_TEST_NAME" | sed -e 's/\//-/g')-err.log"

- logfile_stdout="$(realpath "$logfile_stdout")"

- logfile_stderr="$(realpath "$logfile_stderr")"

- exec 3>&1 4>&2 1> >(tee -a "$logfile_stdout" >&3) 2> >(tee -a "$logfile_stderr" >&4)

+ logfile="$STR_ARTIFACTS_DIR/$(echo "str_$STR_TEST_NAME" | sed -e 's/\//-/g').log"

+ logfile="$(realpath "$logfile")"

+ exec > >(tee -a "$logfile") 2>&1

  cd "$STR_WORKDIR"

  # Purpose to spawn new bash is to ignore -efu setting for current shell

  # Test command: run-basic-test -w wodir -c 'false; echo 123; echo 333 >&2; touch "123 123"; exit 43' -t my_test -a logs -v

file modified
+19
@@ -126,3 +126,22 @@ 

      delegate_to: localhost

    - import_tasks: shared-tasks/artifacts_test_env.yml

    - import_tasks: shared-tasks/artifacts_test_runner.yml

+ 

+ # Make sure the role outputs stderr and stdout correctly

+ - hosts: localhost

+   tags:

+   - atomic

+   - classic

+   - container

+   roles:

+   - role: standard-test-basic

+     tests:

+     - test-basic-stdout-stderr

+   tasks:

+   - name: "Check if {{artifacts}}/PASS-str_test-basic-stdout-stderr.log was created properly"

+     shell: >

+       diff {{artifacts}}/PASS-str_test-basic-stdout-stderr.log

+       {{playbook_dir}}/test-basic-stdout-stderr/expected_output.txt

+     delegate_to: localhost

+   - import_tasks: shared-tasks/artifacts_test_env.yml

+   - import_tasks: shared-tasks/artifacts_test_runner.yml

@@ -0,0 +1,7 @@ 

+ error1

+ pass1

+ error2

+ pass2

+ pass3

+ error3

+ Run test 'test-basic-stdout-stderr': done. Test's exit code: 0

@@ -0,0 +1,7 @@ 

+ #!/usr/bin/sh

+ >&2 echo "error1"

+ echo pass1

+ >&2 echo "error2"

+ echo pass2

+ echo pass3

+ >&2 echo "error3"

rebased onto 6bc12487d9bc37a09b7a64f82332f06ebe57326a

5 years ago

with this approach all output will be hidden in the logs.
No matter have many you add -vvv to ansible there will be no output.
Also, when you call runner manually output to terminal will be empty.

rebased onto c1b921555e9f3cb56ce9793b72e3294eee4efd49

5 years ago

with this approach all output will be hidden in the logs.
No matter have many you add -vvv to ansible there will be no output.
Also, when you call runner manually output to terminal will be empty.

I don't know how to solve this issue and have stdout an stderr outpus in order? Is this a feature that we must have? When ansible output the test execution we already have it saved in the logs...

rebased onto f98bf9a

5 years ago

with this approach all output will be hidden in the logs.
No matter have many you add -vvv to ansible there will be no output.
Also, when you call runner manually output to terminal will be empty.

I don't know how to solve this issue and have stdout an stderr outpus in order? Is this a feature that we must have? When ansible output the test execution we already have it saved in the logs...

I think I got it :)

pretty please pagure-ci rebuild

Commit f0afdf2 fixes this pull-request

Pull-Request has been merged by astepano

5 years ago

Pull-Request has been merged by astepano

5 years ago