Files
hunfabric/tests/modules/compute_vm/test_plan.py
Ludovico Magnocavallo be3c461cf9 MIG and ILB modules (#61)
* preliminary net-ilb module, untested

* outputs

* fix basic mistakes, add initial test

* test variable defaults on all resources

* README stub

* net-ilb module fixes and example

* compute-vm module fixes

* fix test

* remove mig from compute vm module

* split out mig from compute-vm (untested)

* split out mig from compute-vm (untested)

* fix mig versions

* small fixes and examples for mig module

* Update README.md

* Update README.md

* switch mig to using a single  variable for both region and zone
2020-04-30 17:08:18 +02:00

56 lines
1.8 KiB
Python

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pytest
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'fixture')
def test_single_instance(plan_runner):
plan, resources = plan_runner(FIXTURES_DIR)
assert len(resources) == 1
assert resources[0]['type'] == 'google_compute_instance'
def test_multiple_instances(plan_runner):
plan, resources = plan_runner(FIXTURES_DIR, instance_count=2)
assert len(resources) == 2
assert set(r['type'] for r in resources) == set(['google_compute_instance'])
def test_service_account(plan_runner):
plan, resources = plan_runner(FIXTURES_DIR, instance_count=2,
service_account_create='true')
assert len(resources) == 3
assert 'google_service_account' in [r['type'] for r in resources]
def test_template(plan_runner):
plan, resources = plan_runner(FIXTURES_DIR, use_instance_template='true')
assert len(resources) == 1
assert resources[0]['type'] == 'google_compute_instance_template'
assert resources[0]['values']['name_prefix'] == 'test-'
def test_group(plan_runner):
plan, resources = plan_runner(FIXTURES_DIR, instance_count=2,
group='{named_ports={}}')
assert len(resources) == 3
assert set(r['type'] for r in resources) == set([
'google_compute_instance_group', 'google_compute_instance'
])