~andreserl/maas/python3_qa_lab_tests

« back to all changes in this revision

Viewing changes to maas-rsd.py

  • Committer: Brendan Donegan
  • Date: 2017-02-23 11:41:31 UTC
  • mto: This revision was merged to the branch mainline in revision 477.
  • Revision ID: brendan.donegan@canonical.com-20170223114131-3jf4xck70mtvkwjp
test manually composing machines

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
tests_order = [
19
19
    'test_add_rsd_pod',
20
 
    'test_composed_machines_commissioned',
 
20
    'test_precomposed_machines_commissioned',
21
21
    'test_manually_compose_machine_no_constraints',
 
22
    'test_manually_compose_machine_with_constraints',
 
23
    'test_manually_composed_machines_commissioned',
22
24
    'test_allocate_rsd_machines',
23
25
    'test_deploy_rsd_machines',
24
26
    'test_delete_composed_machine',
59
61
            "power_pass={}".format(RSD_CONFIG['pass']),
60
62
        ])
61
63
        rsd_pod = loads(output)
 
64
        pod_cfg = RSD_CONFIG['pod']
62
65
        self.assertThat(rsd_pod, ContainsDict(
63
66
            {
64
 
                "architectures": Equals(8 * ['amd64/generic']),
 
67
                "architectures": Equals(pod_cfg['architectures']),
65
68
                "type": Equals(RSD_POD_TYPE),
66
69
                "total": MatchesDict(
67
70
                    {
68
 
                        "cores": Equals(352),
69
 
                        "local_storage": Equals(959999999999),
70
 
                        "memory": Equals(249984),
71
 
                        "local_disks": Equals(7),
 
71
                        "cores": Equals(pod_cfg['total']['cores']),
 
72
                        "local_storage": Equals(
 
73
                            pod_cfg['total']['local_storage']
 
74
                        ),
 
75
                        "memory": Equals(pod_cfg['total']['memory']),
 
76
                        "local_disks": Equals(pod_cfg['total']['local_disks']),
72
77
                    }
73
78
                ),
74
79
                "available": MatchesDict(
75
80
                    {
76
 
                        "cores": Equals(256),
77
 
                        "local_storage": Equals(480000000003),
78
 
                        "memory": Equals(184448),
79
 
                        "local_disks": Equals(5),
 
81
                        "cores": Equals(pod_cfg['available']['cores']),
 
82
                        "local_storage": Equals(
 
83
                            pod_cfg['available']['local_storage']
 
84
                        ),
 
85
                        "memory": Equals(pod_cfg['available']['memory']),
 
86
                        "local_disks": Equals(
 
87
                            pod_cfg['available']['local_disks']
 
88
                        ),
80
89
                    }
81
90
                ),
82
91
                "used": MatchesDict(
83
92
                    {
84
 
                        "cores": Equals(96),
85
 
                        "local_storage": Equals(479999999996),
86
 
                        "memory": Equals(65536),
87
 
                        "local_disks": Equals(2),
 
93
                        "cores": Equals(pod_cfg['used']['cores']),
 
94
                        "local_storage": Equals(
 
95
                            pod_cfg['used']['local_storage']
 
96
                        ),
 
97
                        "memory": Equals(pod_cfg['used']['memory']),
 
98
                        "local_disks": Equals(pod_cfg['used']['local_disks']),
88
99
                    }
89
100
                ),
90
 
                "capabilities": Equals(["composable", "fixed_local_storage"]),
 
101
                "capabilities": Equals(pod_cfg['capabilities']),
91
102
            }
92
103
        ))
93
104
 
94
105
    @timeout(20*60)
95
 
    def test_composed_machines_commissioned(self):
 
106
    def test_precomposed_machines_commissioned(self):
96
107
        rsd_machines = self._wait_machines(NODE_STATUS.READY)
97
108
        hw = [
98
109
            {
109
120
        return rsd_pods[0]
110
121
 
111
122
    def test_manually_compose_machine_no_constraints(self):
112
 
        import pdb; pdb.set_trace()
113
123
        # Create a tag to tag composed machines with
114
124
        output, _ = self._run_maas_cli(["tags", "create", "name=composed"])
115
125
        tag = loads(output)
124
134
        output, _ = self._run_maas_cli([
125
135
            "tag",
126
136
            "update-nodes",
127
 
            "add=" + machine['system_id'],
128
 
        ])
 
137
            "composed",
 
138
            "add=" + machine['system_id'],
 
139
        ])
 
140
 
 
141
    def test_manually_compose_machine_with_constraints(self):
 
142
        rsd_pod = self._get_rsd_pod()
 
143
        output, _ = self._run_maas_cli([
 
144
            "pod",
 
145
            "compose",
 
146
            "%s" % rsd_pod['id'],
 
147
            "memory=31248"
 
148
            "cores=40",
 
149
        ])
 
150
        machine = loads(output)
 
151
        output, _ = self._run_maas_cli([
 
152
            "tag",
 
153
            "update-nodes",
 
154
            "composed",
 
155
            "add=" + machine['system_id'],
 
156
        ])
 
157
 
 
158
    @timeout(20*60)
 
159
    def test_manually_composed_machines_commissioned(self):
 
160
        rsd_machines = self._wait_machines(
 
161
            NODE_STATUS.READY,
 
162
            num_expected=len(RSD_CONFIG['composed_machines']) + 2,
 
163
        )
129
164
 
130
165
    @timeout(20*60)
131
166
    def test_allocate_rsd_machines(self):
132
 
        rsd_machines = self._wait_machines(NODE_STATUS.READY)
 
167
        rsd_machines = self._wait_machines(
 
168
            NODE_STATUS.READY,
 
169
            num_expected=len(RSD_CONFIG['composed_machines']) + 2,
 
170
        )
133
171
        for machine in rsd_machines:
134
172
            self._run_maas_cli([
135
173
                "machines", "allocate", "system_id={}".format(
136
174
                    machine['system_id']
137
175
                )
138
176
            ])
139
 
        self._wait_machines(NODE_STATUS.ALLOCATED)
 
177
        rsd_machines = self._wait_machines(
 
178
            NODE_STATUS.ALLOCATED,
 
179
            num_expected=len(RSD_CONFIG['composed_machines']) + 2,
 
180
        )
140
181
 
141
182
    @timeout(20*60)
142
183
    def test_deploy_rsd_machines(self):
143
 
        allocated_machines = self._wait_machines(NODE_STATUS.ALLOCATED)
 
184
        rsd_machines = self._wait_machines(
 
185
            NODE_STATUS.ALLOCATED,
 
186
            num_expected=len(RSD_CONFIG['composed_machines']) + 2,
 
187
        )
144
188
        for machine in allocated_machines:
145
189
            self._run_maas_cli(
146
190
                ["machine", "deploy", machine['system_id']]
147
191
            )
148
 
        self._wait_machines(NODE_STATUS.DEPLOYED)
 
192
        rsd_machines = self._wait_machines(
 
193
            NODE_STATUS.DEPLOYED,
 
194
            num_expected=len(RSD_CONFIG['composed_machines']) + 2,
 
195
        )
149
196
 
150
197
    def test_delete_composed_machine(self):
 
198
        import pdb; pdb.set_trace()
151
199
        output, _ = self._run_maas_cli(["tag", "machines", "composed"])
152
200
        machines = loads(output)
153
201
        for machine in machines: