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

validation: implement PosixHooksCalledInOrder test #577

Merged
merged 1 commit into from
Feb 11, 2018

Conversation

zhouhao3
Copy link

@zhouhao3 zhouhao3 commented Feb 8, 2018

Signed-off-by: Zhou Hao [email protected]

@liangchenye
Copy link
Member

  1. I prefer to rename it to hooksorder.go .
  2. We need to verify 'poststart/poststop' as well.
   echo prestart1 > output_prestart
   echo prestart2 > output_prestart
   verify prestart hook order
   echo poststart1 > output_poststart
   echo poststart2 > output_poststart
   verify poststart hook order
   echo poststop1 > output_poststop
   echo poststop2 > output_poststop
   verify poststop hook order

@zhouhao3
Copy link
Author

zhouhao3 commented Feb 9, 2018

When poststart and poststop execute errors, only warnings are output without error, so if the last err is nil, and the result isn't we expect. it is hard to determine whether it is an execution error or not in order. So I only used prestart for testing.

@liangchenye
Copy link
Member

I think in the order tests, we have the assumption: every hook ('echo') will be executed collect, we just test the 'order'.

@zhouhao3
Copy link
Author

zhouhao3 commented Feb 9, 2018

updated, and I think hook.go would be better.

"sh", "-c", fmt.Sprintf("echo 'pre-start1 called' >> %s", output),
},
}
g.AddPreStartHook(prestart1)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for a prestart1 temporary variable, you can just use:

err := g.AddPreStartHook(rspec.Hook{
  …
})
if err != nil {
  return err
}

That also checks this call's returned error, which you're currently ignoring.

g := util.GetDefaultGenerator()
output = filepath.Join(r.BundleDir, g.Spec().Root.Path, "output")
prestart1 := rspec.Hook{
Path: filepath.Join(r.BundleDir, g.Spec().Root.Path, "/bin/sh"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You use this Join a lot in this test. Maybe store it in a temporary variable:

shPath := filepath.Join(r.BundleDir, g.Spec().Root.Path, "/bin/sh")
…
  Path: shPath,

Copy link
Author

Choose a reason for hiding this comment

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

updated, thanks.

@liangchenye
Copy link
Member

liangchenye commented Feb 11, 2018

LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit 963c1c0 into opencontainers:master Feb 11, 2018
@zhouhao3 zhouhao3 deleted the hook-list-order branch February 12, 2018 02:46
@zhouhao3 zhouhao3 mentioned this pull request Feb 12, 2018
44 tasks
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