-func (s *TestSuite) TestFullBrokenDocker1(c *C) {
- tf, err := ioutil.TempFile("", "brokenNodeHook-")
- c.Assert(err, IsNil)
- defer os.Remove(tf.Name())
-
- tf.Write([]byte(`#!/bin/sh
-exec echo killme
-`))
- tf.Close()
- os.Chmod(tf.Name(), 0700)
-
- ech := tf.Name()
- brokenNodeHook = &ech
-
- api, _, _ := s.fullRunHelper(c, `{
- "command": ["echo", "hello world"],
- "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
- "cwd": ".",
- "environment": {},
- "mounts": {"/tmp": {"kind": "tmp"} },
- "output_path": "/tmp",
- "priority": 1,
- "runtime_constraints": {},
- "state": "Locked"
-}`, nil, 2, func(t *TestDockerClient) {
- t.logWriter.Write(dockerLog(1, "hello world\n"))
- t.logWriter.Close()
- })
-
- c.Check(api.CalledWith("container.state", "Queued"), NotNil)
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*unable to run containers.*")
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*Running broken node hook.*")
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*killme.*")
-
-}
-
-func (s *TestSuite) TestFullBrokenDocker2(c *C) {
- ech := ""
- brokenNodeHook = &ech
-
- api, _, _ := s.fullRunHelper(c, `{
- "command": ["echo", "hello world"],
- "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
- "cwd": ".",
- "environment": {},
- "mounts": {"/tmp": {"kind": "tmp"} },
- "output_path": "/tmp",
- "priority": 1,
- "runtime_constraints": {},
- "state": "Locked"
-}`, nil, 2, func(t *TestDockerClient) {
- t.logWriter.Write(dockerLog(1, "hello world\n"))
- t.logWriter.Close()
- })
-
- c.Check(api.CalledWith("container.state", "Queued"), NotNil)
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*unable to run containers.*")
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*Writing /var/lock/crunch-run-broken to mark node as broken.*")
-}
-
-func (s *TestSuite) TestFullBrokenDocker3(c *C) {
- ech := ""
- brokenNodeHook = &ech
-
- api, _, _ := s.fullRunHelper(c, `{
- "command": ["echo", "hello world"],
- "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
- "cwd": ".",
- "environment": {},
- "mounts": {"/tmp": {"kind": "tmp"} },
- "output_path": "/tmp",
- "priority": 1,
- "runtime_constraints": {},
- "state": "Locked"
-}`, nil, 3, func(t *TestDockerClient) {
- t.logWriter.Write(dockerLog(1, "hello world\n"))
- t.logWriter.Close()
- })
-
- c.Check(api.CalledWith("container.state", "Cancelled"), NotNil)
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*unable to run containers.*")
-}
-
-func (s *TestSuite) TestBadCommand1(c *C) {
- ech := ""
- brokenNodeHook = &ech
-
- api, _, _ := s.fullRunHelper(c, `{
- "command": ["echo", "hello world"],
- "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
- "cwd": ".",
- "environment": {},
- "mounts": {"/tmp": {"kind": "tmp"} },
- "output_path": "/tmp",
- "priority": 1,
- "runtime_constraints": {},
- "state": "Locked"
-}`, nil, 4, func(t *TestDockerClient) {
- t.logWriter.Write(dockerLog(1, "hello world\n"))
- t.logWriter.Close()
- })
-
- c.Check(api.CalledWith("container.state", "Cancelled"), NotNil)
- c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*Possible causes:.*is missing.*")
-}
-
-func (s *TestSuite) TestBadCommand2(c *C) {
- ech := ""
- brokenNodeHook = &ech
-
- api, _, _ := s.fullRunHelper(c, `{