Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Transition from tap Diagnostic(...) to YAML(...) #533

Merged
merged 5 commits into from
Jan 11, 2018

Conversation

wking
Copy link
Contributor

@wking wking commented Dec 3, 2017

See ad47e7d (#439) about how node-tap handles YAML blocks vs. diagnostics.

@Mashimiao
Copy link

Please use gofmt -s -w validation/create.go to fix CI failure

@wking
Copy link
Contributor Author

wking commented Dec 4, 2017 via email

@Mashimiao
Copy link

The result doesn't looks the same as result in README.md

# make RUNTIME=runc localvalidation
RUNTIME=runc tap validation/root_readonly_true.t validation/process_rlimits.t validation/linux_rootfs_propagation_unbindable.t validation/linux_readonly_paths.t validation/linux_masked_paths.t validation/mounts.t validation/process.t validation/root_readonly_false.t validation/linux_sysctl.t validation/linux_devices.t validation/linux_id_mappings.t validation/process_capabilities.t validation/process_oom_score_adj.t validation/create.t validation/hostname.t validation/linux_rootfs_propagation_shared.t validation/default.t
total ................................................... 0/0

ok

Forgot to modify Makefile?

@wking
Copy link
Contributor Author

wking commented Dec 4, 2017 via email

@Mashimiao
Copy link

So strange, The following is my environment:

# which tap
/usr/bin/tap
# rpm -qf /usr/bin/tap
nodejs-tap-0.4.4-9.fc24.noarch
# file /usr/bin/tap
/usr/bin/tap: symbolic link to ../lib/node_modules/tap/bin/tap.js
# uname -r
4.13.13-200.fc26.x86_64

@Mashimiao
Copy link

And

# ./validation/create.t 
TAP version 13
ok 1 - create MUST generate an error if the ID is not provided
  ---
  {
    "error": "exit status 1",
    "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md#create",
    "stderr": "/usr/local/sbin/runc: \"create\" requires exactly 1 argument(s)\n"
  }
  ...
ok 2 - create MUST create a new container
  ---
  {
    "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md#create"
  }
  ...
ok 3 - 

I think that's not what we expect

@wking
Copy link
Contributor Author

wking commented Dec 4, 2017 via email

@wking
Copy link
Contributor Author

wking commented Dec 4, 2017 via email

@wking
Copy link
Contributor Author

wking commented Dec 4, 2017

Ah, possible cause for your 0/0 is that you didn't run:

$ make runtimetest validation-executables

first. I've added a guard for that to the Makefile with a55d23407a3809.

@Mashimiao
Copy link

No, I did run $ make runtimetest validation-executables.

@wking
Copy link
Contributor Author

wking commented Dec 6, 2017

Can you strace -f ... tap validation/mounts.t to see if tap is actually executing mounts.t?

@wking
Copy link
Contributor Author

wking commented Dec 13, 2017

This is a followup to #439. Can we add it to the 0.4.0 milestone and land it before #308? I'd rather switch #308 over to the .YAML(…) method too.

@Mashimiao Mashimiao added this to the v0.4.0 milestone Dec 14, 2017
@zhouhao3
Copy link

@Mashimiao @mrunalp @liangchenye What do you think of this pr?

@@ -39,15 +39,18 @@ $ npm install tap

```console
$ make runtimetest validation-executables
$ sudo make RUNTIME=runc localvalidation

Choose a reason for hiding this comment

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

Do we need to add the following?

for EXECUTABLE in runtimetest validation/linux_rootfs_propagation_shared.t validation/create.t validation/linux_gid_mappings.t validation/linux_rootfs_propagation_unbindable.t validation/linux_readonly_paths.t validation/linux_masked_paths.t validation/mounts.t validation/process.t validation/root_readonly_false.t validation/linux_sysctl.t validation/default.t validation/linux_devices.t validation/process_capabilities.t validation/process_oom_score_adj.t validation/process_rlimits.t validation/root_readonly_true.t validation/hostname.t validation/linux_uid_mappings.t; \ do \ test -x "${EXECUTABLE}"; \ done || (echo "missing test executable; run 'make runtimetest validation-executables'" >&2 && exit 1)

The other looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to add the following?

for EXECUTABLE
…

I've pushed 07a380923f547a to remove that noise from the localvalidation output.

@zhouhao3
Copy link

zhouhao3 commented Dec 27, 2017

LGTM

Approved with PullApprove

@zhouhao3
Copy link

zhouhao3 commented Jan 2, 2018

ping @liangchenye @Mashimiao

@zhouhao3
Copy link

zhouhao3 commented Jan 8, 2018

This is an important pr that progressed to the 0.4 version, WDYT @liangchenye .

@liangchenye
Copy link
Member

It looks good to me and sorry @wking I merged 547 just now, so we have a conflict to solve.

Since the runtime-CLI interface is added now. #321
we need to change the 'create' function a lot. But we can do that in our 0.5 milestone.

To pick up t.YAML(...) for more visible error messages.  See ad47e7d
(Makefile: Change from prove to node-tap, 2017-11-30, opencontainers#439) about how
node-tap handles YAML blocks vs. diagnostics.

Generated with:

  $ go get -u github.com/mndrix/tap-go
  $ godep update github.com/mndrix/tap-go
  $ emacs Godeps/Godeps.json  # remove gopkg.in/yaml.v2 entry
  $ rm -rf vendor/gopkg.in/yaml.v2
  $ git add vendor/github.com/mndrix

We don't need gopkg.in/yaml.v2 because we're using tap-go's JSON
output.

Signed-off-by: W. Trevor King <wking@tremily.us>
See ad47e7d (Makefile: Change from prove to node-tap, 2017-11-30,
opencontainers#439) about how node-tap handles YAML blocks vs. diagnostics.

The README's localvalidation line is back after I accidentally removed
it in ad47e7d.

Signed-off-by: W. Trevor King <wking@tremily.us>
So we get:

  ok 3 - 'state' MUST return the state of a container

instead of:

  ok 3 -

Signed-off-by: W. Trevor King <wking@tremily.us>
So validation/create.t gives:

  ok 4 - create MUST generate an error if the ID provided is not unique
    ---
    {
      "error": "exit status 1",
      "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md#create",
      "stderr": "container with id exists: 4a142dd0-e5bc-48b3-9abd-49c1a8f7c498\n"
    }
    ...

instead of:

  ok 4 - create MUST generate an error if the ID provided is not unique
    ---
    {
      "error": "open /tmp/ocitest842577116/stdout-178f8311-9cc7-42c5-b91e-abbe29eaf582: file exists",
      "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md#create"
    }
    ...

The old code hit the internal error, while the new code is checking
for a runtime error.

Signed-off-by: W. Trevor King <wking@tremily.us>
Instead of reporting

  total ................................................. 0/0

and passing (which node-tap seems to do when given missing files as
arguments), report:

  missing test executable; run 'make runtimetest validation-executables'

and error out.  Having a separate step to build the executables is
useful for:

* Not building them as root, which reduces the change of security
  issues by using as little privilege as possible.
* Not rebuilding them on each test, since we haven't told Make about
  the full dependency tree for the test executables.

The separate build step was introduced in e11b77f (validation: Use
prove(1) as a TAP harness, 2017-11-25, opencontainers#439), but I didn't do a good
job of motivating it in that commit message.

Signed-off-by: W. Trevor King <wking@tremily.us>
@wking
Copy link
Contributor Author

wking commented Jan 10, 2018

Rebased onto master with 23f547ae85081a.

@zhouhao3
Copy link

zhouhao3 commented Jan 11, 2018

LGTM

Approved with PullApprove

@liangchenye
Copy link
Member

liangchenye commented Jan 11, 2018

LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit e6a60ee into opencontainers:master Jan 11, 2018
@wking wking deleted the tap-yaml branch January 11, 2018 05:21
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.

4 participants