blob: a7beb0e40c4e5976ae08c4053b98264856f57fe0 [file] [log] [blame]
Yaroslav Lobankov1b3c8242014-07-04 17:43:16 +04001# Copyright (c) 2014 Mirantis Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.api.data_processing import base as dp_base
16from tempest.common.utils import data_utils
17from tempest import test
18
19
20class JobTest(dp_base.BaseDataProcessingTest):
21 """Link to the API documentation is http://docs.openstack.org/developer/
22 sahara/restapi/rest_api_v1.1_EDP.html#jobs
23 """
24 @classmethod
Andrea Frittoli581c3932014-09-15 13:14:53 +010025 def resource_setup(cls):
26 super(JobTest, cls).resource_setup()
Yaroslav Lobankov1b3c8242014-07-04 17:43:16 +040027 # create job binary
28 job_binary = {
29 'name': data_utils.rand_name('sahara-job-binary'),
30 'url': 'swift://sahara-container.sahara/example.jar',
31 'description': 'Test job binary',
32 'extra': {
33 'user': cls.os.credentials.username,
34 'password': cls.os.credentials.password
35 }
36 }
37 resp_body = cls.create_job_binary(**job_binary)
38 job_binary_id = resp_body['id']
39
40 cls.job = {
41 'job_type': 'Pig',
42 'mains': [job_binary_id]
43 }
44
45 def _create_job(self, job_name=None):
46 """Creates Job with optional name specified.
47
48 It creates job and ensures job name. Returns id and name of created
49 job.
50 """
51 if not job_name:
52 # generate random name if it's not specified
53 job_name = data_utils.rand_name('sahara-job')
54
55 # create job
56 resp_body = self.create_job(job_name, **self.job)
57
58 # ensure that job created successfully
59 self.assertEqual(job_name, resp_body['name'])
60
61 return resp_body['id'], job_name
62
63 @test.attr(type='smoke')
64 def test_job_create(self):
65 self._create_job()
66
67 @test.attr(type='smoke')
68 def test_job_list(self):
69 job_info = self._create_job()
70
71 # check for job in list
David Kranz77f57202015-02-09 14:10:04 -050072 jobs = self.client.list_jobs()
Yaroslav Lobankov1b3c8242014-07-04 17:43:16 +040073 jobs_info = [(job['id'], job['name']) for job in jobs]
74 self.assertIn(job_info, jobs_info)
75
76 @test.attr(type='smoke')
77 def test_job_get(self):
78 job_id, job_name = self._create_job()
79
80 # check job fetch by id
David Kranz77f57202015-02-09 14:10:04 -050081 job = self.client.get_job(job_id)
Yaroslav Lobankov1b3c8242014-07-04 17:43:16 +040082 self.assertEqual(job_name, job['name'])
83
84 @test.attr(type='smoke')
85 def test_job_delete(self):
86 job_id, _ = self._create_job()
87
88 # delete the job by id
89 self.client.delete_job(job_id)