12 // Gocheck boilerplate
13 func Test(t *testing.T) {
17 var _ = Suite(&ServerRequiredSuite{})
19 // Tests that require the Keep server running
20 type ServerRequiredSuite struct{}
22 func pythonDir() string {
24 return fmt.Sprintf("%s/../../python/tests", cwd)
27 func (s *ServerRequiredSuite) SetUpSuite(c *C) {
29 if err := exec.Command("python", "run_test_server.py", "start").Run(); err != nil {
30 panic("'python run_test_server.py start' returned error")
32 if err := exec.Command("python", "run_test_server.py", "start_keep").Run(); err != nil {
33 panic("'python run_test_server.py start_keep' returned error")
37 func (s *ServerRequiredSuite) TestMakeArvadosClient(c *C) {
38 os.Setenv("ARVADOS_API_HOST", "localhost:3000")
39 os.Setenv("ARVADOS_API_TOKEN", "4axaw8zxe0qm22wa6urpp5nskcne8z88cvbupv653y1njyi05h")
40 os.Setenv("ARVADOS_API_HOST_INSECURE", "")
42 kc, err := MakeArvadosClient()
43 c.Check(kc.ApiServer, Equals, "localhost:3000")
44 c.Check(kc.ApiToken, Equals, "4axaw8zxe0qm22wa6urpp5nskcne8z88cvbupv653y1njyi05h")
45 c.Check(kc.ApiInsecure, Equals, false)
47 os.Setenv("ARVADOS_API_HOST_INSECURE", "true")
49 kc, err = MakeArvadosClient()
50 c.Check(kc.ApiServer, Equals, "localhost:3000")
51 c.Check(kc.ApiToken, Equals, "4axaw8zxe0qm22wa6urpp5nskcne8z88cvbupv653y1njyi05h")
52 c.Check(kc.ApiInsecure, Equals, true)
53 c.Check(kc.Client.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify, Equals, true)
55 c.Assert(err, Equals, nil)
58 func (s *ServerRequiredSuite) TestCreatePipelineTemplate(c *C) {
59 os.Setenv("ARVADOS_API_HOST", "localhost:3000")
60 os.Setenv("ARVADOS_API_TOKEN", "4axaw8zxe0qm22wa6urpp5nskcne8z88cvbupv653y1njyi05h")
61 os.Setenv("ARVADOS_API_HOST_INSECURE", "true")
63 arv, err := MakeArvadosClient()
66 err = arv.Create("pipeline_templates",
67 Dict{"pipeline_template": Dict{
70 "c1": map[string]string{"script": "script1"},
71 "c2": map[string]string{"script": "script2"}}}},
73 c.Assert(err, Equals, nil)
74 c.Assert(getback["name"], Equals, "tmp")
75 c.Assert(getback["components"].(map[string]interface{})["c2"].(map[string]interface{})["script"], Equals, "script2")
77 uuid := getback["uuid"].(string)
79 err = arv.Update("pipeline_templates", uuid,
81 "pipeline_template": Dict{"name": "tmp2"}},
83 c.Assert(err, Equals, nil)
84 c.Assert(getback["name"], Equals, "tmp2")
86 c.Assert(getback["uuid"].(string), Equals, uuid)
88 err = arv.Delete("pipeline_templates", uuid, nil, &getback)
89 c.Assert(err, Equals, nil)
90 c.Assert(getback["name"], Equals, "tmp2")
93 func (s *ServerRequiredSuite) TestErrorResponse(c *C) {
94 os.Setenv("ARVADOS_API_HOST", "localhost:3000")
95 os.Setenv("ARVADOS_API_TOKEN", "4axaw8zxe0qm22wa6urpp5nskcne8z88cvbupv653y1njyi05h")
96 os.Setenv("ARVADOS_API_HOST_INSECURE", "true")
98 arv, _ := MakeArvadosClient()
100 getback := make(Dict)
103 err := arv.Create("logs",
104 Dict{"log": Dict{"bogus_attr": "foo"}},
106 c.Assert(err, ErrorMatches, ".*unknown attribute: bogus_attr.*")
107 c.Assert(err, FitsTypeOf, ArvadosApiError{})
108 c.Assert(err.(ArvadosApiError).HttpStatusCode, Equals, 422)
112 err := arv.Create("bogus",
113 Dict{"bogus": Dict{}},
115 c.Assert(err, ErrorMatches, "Path not found")
116 c.Assert(err, FitsTypeOf, ArvadosApiError{})
117 c.Assert(err.(ArvadosApiError).HttpStatusCode, Equals, 404)