~ubuntu-branches/ubuntu/vivid/sahara/vivid-proposed

« back to all changes in this revision

Viewing changes to sahara/tests/unit/plugins/vanilla/hadoop2/test_configs.py

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2014-09-24 16:34:46 UTC
  • Revision ID: package-import@ubuntu.com-20140924163446-8gu3zscu5e3n9lr2
Tags: upstream-2014.2~b3
ImportĀ upstreamĀ versionĀ 2014.2~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2014 Mirantis Inc.
 
2
#
 
3
# Licensed under the Apache License, Version 2.0 (the "License");
 
4
# you may not use this file except in compliance with the License.
 
5
# You may obtain 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,
 
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
12
# implied.
 
13
# See the License for the specific language governing permissions and
 
14
# limitations under the License.
 
15
 
 
16
from sahara.plugins.vanilla.hadoop2 import config as c
 
17
from sahara.tests.unit import base
 
18
 
 
19
 
 
20
class VanillaTwoConfigTestCase(base.SaharaTestCase):
 
21
    def test_get_hadoop_dirs(self):
 
22
        ng = FakeNG(storage_paths=['/vol1', '/vol2'])
 
23
        dirs = c._get_hadoop_dirs(ng)
 
24
        expected = {
 
25
            'hadoop_name_dirs': ['/vol1/hdfs/namenode',
 
26
                                 '/vol2/hdfs/namenode'],
 
27
            'hadoop_data_dirs': ['/vol1/hdfs/datanode',
 
28
                                 '/vol2/hdfs/datanode'],
 
29
            'hadoop_log_dir': '/vol1/hadoop/logs',
 
30
            'hadoop_secure_dn_log_dir': '/vol1/hadoop/logs/secure',
 
31
            'yarn_log_dir': '/vol1/yarn/logs'
 
32
        }
 
33
        self.assertEqual(dirs, expected)
 
34
 
 
35
    def test_merge_configs(self):
 
36
        a = {
 
37
            'HDFS': {
 
38
                'param1': 'value1',
 
39
                'param2': 'value2'
 
40
            }
 
41
        }
 
42
        b = {
 
43
            'HDFS': {
 
44
                'param1': 'value3',
 
45
                'param3': 'value4'
 
46
            },
 
47
            'YARN': {
 
48
                'param5': 'value5'
 
49
            }
 
50
        }
 
51
 
 
52
        res = c._merge_configs(a, b)
 
53
        expected = {
 
54
            'HDFS': {
 
55
                'param1': 'value3',
 
56
                'param2': 'value2',
 
57
                'param3': 'value4'
 
58
            },
 
59
            'YARN': {
 
60
                'param5': 'value5'
 
61
            }
 
62
        }
 
63
        self.assertEqual(res, expected)
 
64
 
 
65
 
 
66
class FakeNG():
 
67
    def __init__(self, storage_paths=None):
 
68
        self.paths = storage_paths
 
69
 
 
70
    def storage_paths(self):
 
71
        return self.paths