Skip to content

test/system: Don't check the output of 'toolbox run' - #438

Merged
debarshiray merged 1 commit into
containers:masterfrom
martymichal:update-tests
Jul 22, 2020
Merged

debarshiray merged 1 commit into
containers:masterfrom
martymichal:update-tests

Conversation

@martymichal

Copy link
Copy Markdown
Member

Now that the rewritten version is the default, the tests need to be adjusted.

Also, we did not enable tests on Fedora 32 -> enabling with this.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal
martymichal force-pushed the update-tests branch 3 times, most recently from 8bbd560 to 904fe63 Compare May 14, 2020 08:26
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal

Copy link
Copy Markdown
Member Author

Looks like I'll need to adjust the parts where the tests check what was written in stdout/stderr. The spinner breaks those test cases.

@debarshiray

Copy link
Copy Markdown
Member

Looks like I'll need to adjust the parts where the tests check what was written
in stdout/stderr. The spinner breaks those test cases.

Oh, really? Is it because the spinner just looks different now? I think that the spinner is written to the standard output in both the POSIX shell and Go versions.

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the tests. Some quick comments:

Comment thread playbooks/shellcheck.yaml Resolved
Comment thread test/system/102-create.bats Resolved
@martymichal

Copy link
Copy Markdown
Member Author

Looks like I'll need to adjust the parts where the tests check what was written
in stdout/stderr. The spinner breaks those test cases.

Oh, really? Is it because the spinner just looks different now? I think that the spinner is written to the standard output in both the POSIX shell and Go versions.

I think the problem is in the output variable. I think it holds both stdout and stderr. I'll check the documentation.

@softwarefactory-delete-me

Copy link
Copy Markdown

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal

Copy link
Copy Markdown
Member Author

@debarshiray This should be ready to be merged. The tests are not passing but they are working which is the main point of this PR. I'm just wondering about the additional dependency introduced in 11133ac. What do you think??

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal

Copy link
Copy Markdown
Member Author

Tests should be ok now. #410 still needs to be sorted out but that is a different issue (I suspect this is something introduced by Podman but I'm not sure. We'll see if V2 makes a difference regarding this matter). Rawhide tests are failing but that is due to an old version of Podman being available. Newer versions should have all the necessarry fixes.

@martymichal
martymichal requested a review from debarshiray June 26, 2020 09:33
@martymichal

Copy link
Copy Markdown
Member Author

recheck

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal martymichal added this to the Stable 1.0 milestone Jul 7, 2020
@debarshiray

Copy link
Copy Markdown
Member

Looking at the API documentation of golang.org/x/crypto/ssh/terminal
and github.com/mattn/go-isatty, it seems likely that the former will have a
bigger footprint in terms of the final binary size. Preventing the
binary size from growing is a worthwhile goal.

After actually trying out both packages and building the resulting binaries, golang.org/x/crypto/ssh/terminal gave the smaller size. 7778323 bytes versus 7782284.

It's not what I expected because github.com/mattn/go-isatty seemed like a much smaller package in comparison. It's essentially just:

import "golang.org/x/sys/unix"

// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
        _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
        return err == nil
}

But I cannot argue with actual data. :) Unless I am missing something.

@debarshiray

Copy link
Copy Markdown
Member

I discussed the spinner changes with @HarryMichal on Telegram, and he confirmed that there's no reason not to use the golang.org/x/crypto/ssh/terminal package. So, I took the liberty to tweak his commit accordingly, and merged it via #496

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, looks like I missed something:

Comment thread src/cmd/create.go Resolved
Comment thread src/cmd/rm.go Resolved
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal

Copy link
Copy Markdown
Member Author

/recheck

@martymichal

Copy link
Copy Markdown
Member Author

recheck

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 21, 2020
In the Go implementation, when the 'rm' and 'rmi' commands fail to
remove a container or image, they don't use a non-zero exit code.
There's currently no nice fix for this. So, the tests have been
adjusted as a temporary measure.

containers#438
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 21, 2020
New release out, we need to run the tests there.

containers#438

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the branch, @HarryMichal !

I have merged most of the commits in this branch. I used two separate pull requests for them, so that I could see the CI get progressively more green and be sure that each commit is doing exactly as it claims to.

Comment thread playbooks/fedora-31/setup-env.yaml Resolved
Comment thread test/system/301-rm.bats Resolved
Comment thread test/system/201-run.bats Resolved
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 21, 2020
Not all tests are the same and the ones we're currently running are
system tests. Also the mention of 'podman-stable' is not that important
because we're using the version in the 'stable' stream of Fedora
releases.

containers#438
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 21, 2020
For some reason running 'toolbox run echo Hello World' in the tests in
the environment of Zuul is causing problems. Bats saves the output of
ran command to $output that can be then checked if it contains the right
output. This variable sometimes holds in this case the right output
("Hello World") but more often it is blank, causing the tests to fail.

I don't know the culprit, so for now I'm commenting out the checks to
make the CI pass again.

containers#438
@debarshiray

Copy link
Copy Markdown
Member

I merged the renaming of the files and test names.

The only thing left is to figure out if we should notify Zuul about the toolbox run test failures.

@martymichal martymichal changed the title Update tests test/system: Don't check the output of 'toolbox run' Jul 22, 2020
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

For some reason running 'toolbox run echo Hello World' in the tests in
the environment of Zuul is causing problems. Bats saves the output of
ran command to $output that can be then checked if it contains the right
output. This variable sometimes holds in this case the right output
("Hello World") but more often it is blank, causing the tests to fail.

I don't know the culprit, so for now I'm commenting out the checks to
make the CI pass again.

containers#410
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@debarshiray
debarshiray merged commit 68c585f into containers:master Jul 22, 2020
@debarshiray

debarshiray commented Jul 22, 2020 •

Copy link
Copy Markdown
Member

The only thing left is to figure out if we should notify Zuul about the toolbox run test failures.

Let's continue discussing that on #410

@juanje

juanje commented Jul 22, 2020

Copy link
Copy Markdown
Contributor

Hi, I was rewriting the bats tests (for practicing purposes) and I found this issue with the toolbox run.

Here the test (using bats-assert):

@test "Echo 'Hello World' inside of the default container" {
  create_default_container
  run toolbox run echo "Hello World"

  assert_success
  assert_output "Hello World"
}

And the fail:

 ✗ Echo 'Hello World' inside of the default container
   (from function `assert_output' in file test/system/libs/bats-assert/src/assert.bash, line 239,
    in test file test/system/1201-run.bats, line 28)
     `assert_output "Hello World"' failed
   
   -- output differs --
   expected : Hello World
   actual   : Hello World
   --

As you can see, the outputs seem to be the same, but after some checking, I found that the toolbox run echo added a CRLF at the end of the line.

After much testing I tried this:

$ toolbox run echo foo > toolbox_output.txt
$ echo foo >  output.txt
$ file *output.txt
output.txt:         ASCII text
toolbox_output.txt: ASCII text, with CRLF line terminators

I couldn't make it work at the test comparison, but if I add the flag -n to the command echo the test work:

$ toolbox run echo -n foo > toolbox_output.txt
$ file toolbox_output.txt
toolbox_output.txt: ASCII text, with no line terminators

Well, I could make the comparison works with the assert's flag --partial, but it looks to me as a hack for the test to pass rather than a solution:

assert_output --partial "Hello World"

The same with the echo -n trick. The problem remains because if I try other commands it doesn't work. For example:

$ toolbox run ls > toolbox_output.txt
$ file toolbox_output.txt
toolbox_output.txt: ASCII text, with CRLF line terminators

I guess it's something about the toolbox output. I hope this give you some useful info to debug the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants