blob: 67d09a039c977bfa7ebfffdab523fb3dbe3fe78d [file] [log] [blame]
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +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
Fei Long Wangd39431f2015-05-14 11:30:48 +120016from tempest.common.utils import data_utils
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040017from tempest import test
18
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040019
20class DataSourceTest(dp_base.BaseDataProcessingTest):
21 @classmethod
Andrea Frittoli581c3932014-09-15 13:14:53 +010022 def resource_setup(cls):
23 super(DataSourceTest, cls).resource_setup()
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040024 cls.swift_data_source_with_creds = {
25 'url': 'swift://sahara-container.sahara/input-source',
26 'description': 'Test data source',
27 'credentials': {
Yaroslav Lobankovfa5a36e2014-07-01 15:24:55 +040028 'user': cls.os.credentials.username,
29 'password': cls.os.credentials.password
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040030 },
31 'type': 'swift'
32 }
33 cls.swift_data_source = cls.swift_data_source_with_creds.copy()
34 del cls.swift_data_source['credentials']
35
36 cls.local_hdfs_data_source = {
37 'url': 'input-source',
38 'description': 'Test data source',
39 'type': 'hdfs'
40 }
41
42 cls.external_hdfs_data_source = {
43 'url': 'hdfs://172.18.168.2:8020/usr/hadoop/input-source',
44 'description': 'Test data source',
45 'type': 'hdfs'
46 }
47
48 def _create_data_source(self, source_body, source_name=None):
49 """Creates Data Source with optional name specified.
50
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040051 It creates a link to input-source file (it may not exist), ensures
52 source name and response body. Returns id and name of created source.
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040053 """
54 if not source_name:
55 # generate random name if it's not specified
56 source_name = data_utils.rand_name('sahara-data-source')
57
58 # create data source
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040059 resp_body = self.create_data_source(source_name, **source_body)
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040060
61 # ensure that source created successfully
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040062 self.assertEqual(source_name, resp_body['name'])
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040063 if source_body['type'] == 'swift':
64 source_body = self.swift_data_source
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040065 self.assertDictContainsSubset(source_body, resp_body)
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040066
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040067 return resp_body['id'], source_name
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040068
69 def _list_data_sources(self, source_info):
70 # check for data source in list
Yaroslav Lobankov1662b0e2015-08-10 16:48:07 +030071 sources = self.client.list_data_sources()['data_sources']
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040072 sources_info = [(source['id'], source['name']) for source in sources]
73 self.assertIn(source_info, sources_info)
74
75 def _get_data_source(self, source_id, source_name, source_body):
76 # check data source fetch by id
Yaroslav Lobankov1662b0e2015-08-10 16:48:07 +030077 source = self.client.get_data_source(source_id)['data_source']
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040078 self.assertEqual(source_name, source['name'])
79 self.assertDictContainsSubset(source_body, source)
80
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040081 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080082 @test.idempotent_id('9e0e836d-c372-4fca-91b7-b66c3e9646c8')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040083 def test_swift_data_source_create(self):
84 self._create_data_source(self.swift_data_source_with_creds)
85
86 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080087 @test.idempotent_id('3cb87a4a-0534-4b97-9edc-8bbc822b68a0')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040088 def test_swift_data_source_list(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040089 source_info = (
90 self._create_data_source(self.swift_data_source_with_creds))
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040091 self._list_data_sources(source_info)
92
93 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080094 @test.idempotent_id('fc07409b-6477-4cb3-9168-e633c46b227f')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040095 def test_swift_data_source_get(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +040096 source_id, source_name = (
97 self._create_data_source(self.swift_data_source_with_creds))
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +040098 self._get_data_source(source_id, source_name, self.swift_data_source)
99
100 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800101 @test.idempotent_id('df53669c-0cd1-4cf7-b408-4cf215d8beb8')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400102 def test_swift_data_source_delete(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +0400103 source_id, _ = (
104 self._create_data_source(self.swift_data_source_with_creds))
105
106 # delete the data source by id
107 self.client.delete_data_source(source_id)
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400108
109 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800110 @test.idempotent_id('88505d52-db01-4229-8f1d-a1137da5fe2d')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400111 def test_local_hdfs_data_source_create(self):
112 self._create_data_source(self.local_hdfs_data_source)
113
114 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800115 @test.idempotent_id('81d7d42a-d7f6-4d9b-b38c-0801a4dfe3c2')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400116 def test_local_hdfs_data_source_list(self):
117 source_info = self._create_data_source(self.local_hdfs_data_source)
118 self._list_data_sources(source_info)
119
120 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800121 @test.idempotent_id('ec0144c6-db1e-4169-bb06-7abae14a8443')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400122 def test_local_hdfs_data_source_get(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +0400123 source_id, source_name = (
124 self._create_data_source(self.local_hdfs_data_source))
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400125 self._get_data_source(
126 source_id, source_name, self.local_hdfs_data_source)
127
128 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800129 @test.idempotent_id('e398308b-4230-4f86-ba10-9b0b60a59c8d')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400130 def test_local_hdfs_data_source_delete(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +0400131 source_id, _ = self._create_data_source(self.local_hdfs_data_source)
132
133 # delete the data source by id
134 self.client.delete_data_source(source_id)
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400135
136 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800137 @test.idempotent_id('bfd91128-e642-4d95-a973-3e536962180c')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400138 def test_external_hdfs_data_source_create(self):
139 self._create_data_source(self.external_hdfs_data_source)
140
141 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800142 @test.idempotent_id('92e2be72-f7ab-499d-ae01-fb9943c90d8e')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400143 def test_external_hdfs_data_source_list(self):
144 source_info = self._create_data_source(self.external_hdfs_data_source)
145 self._list_data_sources(source_info)
146
147 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800148 @test.idempotent_id('a31edb1b-6bc6-4f42-871f-70cd243184ac')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400149 def test_external_hdfs_data_source_get(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +0400150 source_id, source_name = (
151 self._create_data_source(self.external_hdfs_data_source))
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400152 self._get_data_source(
153 source_id, source_name, self.external_hdfs_data_source)
154
155 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -0800156 @test.idempotent_id('295924cd-a085-4b45-aea8-0707cdb2da7e')
Yaroslav Lobankovee92a9d2014-05-12 17:15:17 +0400157 def test_external_hdfs_data_source_delete(self):
Yaroslav Lobankov2f8525e2014-07-21 16:40:23 +0400158 source_id, _ = self._create_data_source(self.external_hdfs_data_source)
159
160 # delete the data source by id
161 self.client.delete_data_source(source_id)