def test_no_duplicate_IPs(self, input_files, drydock_state, deckhand_ingester): input_file = input_files.join("validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator( state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.no_duplicate_IPs_check(site_design) msg = message_list[0].to_dict() assert msg.get('message') == 'No Duplicate IP Addresses.' assert msg.get('error') is False
def test_storage_partitioning(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = StoragePartitioning() message_list = validator.execute(site_design, orchestrator=orch) msg = message_list[0].to_dict() assert len(message_list) == 1 assert msg.get('error') is False
def test_no_duplicate_IPs_no_addressing(self, input_files, drydock_state, deckhand_ingester): input_file = input_files.join("no_duplicate_IPs_no_addressing.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = NoDuplicateIpsCheck() message_list = validator.execute(site_design, orchestrator=orch) msg = message_list[0].to_dict() assert 'No BaremetalNodes Found.' in msg.get('message') assert msg.get('error') is False
def test_mtu(self, mocker, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("mtu_rational.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.mtu_rational(site_design) msg = message_list[0].to_dict() assert msg.get('message') == 'Mtu' assert msg.get('error') is False assert len(message_list) == 1
def test_validate_no_nodes(self, deckhand_ingester, drydock_state, input_files, mock_get_build_data): """Test that a design with no baremetal nodes validates.""" input_file = input_files.join("deckhand_fullsite_no_nodes.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) val = Validator(orch) response = val.validate_design(site_design) assert response.status == hd_fields.ValidationResult.Success
def test_no_baremetal_node(self, input_files, drydock_state, deckhand_ingester): input_file = input_files.join("no_baremetal_node.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = IpLocalityCheck() message_list = validator.execute(site_design, orchestrator=orch) msg = message_list[0].to_dict() assert 'No baremetal_nodes found' in msg.get('message') assert msg.get('error') is False
def test_rational_network_bond(self, mocker, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator( state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = RationalNetworkBond() message_list = validator.execute(site_design, orchestrator=orch) msg = message_list[0].to_dict() assert msg.get('error') is False assert len(message_list) == 1 assert len(msg.get('documents')) == 0
def test_absent_bootaction(self, deckhand_ingester, drydock_state, setup, input_files, mock_get_build_data): input_file = input_files.join("absent_bootaction.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) ba_msg = [ msg for msg in status.message_list if ("DD4001" in msg.name and msg.level == hd_fields.MessageLevels.WARN) ] assert len(ba_msg) > 0
def test_invalid_no_duplicate_IPs(self, input_files, drydock_state, deckhand_ingester): input_file = input_files.join("invalid_validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator( state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.no_duplicate_IPs_check(site_design) regex = re.compile( 'Error! Duplicate IP Address Found: .+ is in use by both .+ and .+.' ) for msg in message_list: msg = msg.to_dict() assert msg.get('error') is True assert regex.match(msg.get('message')) is not None
def test_validate_design(self, deckhand_ingester, drydock_state, input_files): """Test the basic validation engine.""" input_file = input_files.join("deckhand_fullsite.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) val = Validator() response = val.validate_design(site_design) for msg in response.message_list: assert msg.error is False assert response.error_count == 0 assert response.status == hd_fields.ValidationResult.Success
def test_invalid_rational_network_bond(self, mocker, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_rational_network_bond.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.rational_network_bond(site_design) regex = re.compile('Network Link Bonding Error: Down delay is less than mon rate on BaremetalNode .+') regex_1 = re.compile('Network Link Bonding Error: Up delay is less than mon rate on BaremetalNode .+') for msg in message_list: msg = msg.to_dict() assert msg.get('error') is True assert regex.match(msg.get('message')) is not None or regex_1.match(msg.get('message')) is not None assert len(message_list) == 2
def test_invalid_no_duplicate_IPs(self, input_files, drydock_state, deckhand_ingester): input_file = input_files.join("invalid_validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = NoDuplicateIpsCheck() message_list = validator.execute(site_design) regex = re.compile('Duplicate IP Address Found: [0-9.]+') for msg in message_list: msg = msg.to_dict() LOG.debug(msg) assert len(msg.get('documents')) > 0 assert msg.get('error') is True assert regex.search(msg.get('message')) is not None
def test_invalid_vg_mountpoints(self, deckhand_ingester, drydock_state, input_files, mock_get_build_data): input_file = input_files.join("invalid_mountpoint.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = StorageMountpoints() message_list = validator.execute(site_design, orchestrator=orch) regex = re.compile('Mountpoint .+ already exists') for msg in message_list: msg = msg.to_dict() LOG.debug(msg) assert regex.search(msg.get('message')) is not None assert msg.get('error') is True
def test_valid_platform(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester, enabled_drivers=config.config_mgr.conf.plugins) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = HugepagesValidity() message_list = validator.execute(site_design, orchestrator=orch) for r in message_list: LOG.debug(r.to_dict()) msg = message_list[0].to_dict() assert msg.get('error') is False assert len(message_list) == 1
def test_valid_bootaction(self, deckhand_ingester, drydock_state, setup, input_files, mock_get_build_data): input_file = input_files.join("validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) assert status.status == hd_fields.ValidationResult.Success LOG.debug("%s" % status.to_dict()) validator = BootactionDefined() message_list = validator.execute(site_design, orchestrator=orch) msg = message_list[0].to_dict() assert msg.get('error') is False assert msg.get('level') == hd_fields.MessageLevels.INFO assert len(message_list) == 1
def test_invalid_hugepages(self, deckhand_ingester, drydock_state, input_files): """Test that a design with incorrect hugepages configuration.""" input_file = input_files.join("invalid_hugepages.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester, enabled_drivers=config.config_mgr.conf.plugins) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = HugepagesValidity() message_list = validator.execute(site_design) assert len(message_list) > 0 for msg in message_list: msg = msg.to_dict() LOG.debug(msg) assert len(msg.get('documents', [])) > 0 assert msg.get('error') is True
def test_invalid_storage_sizing_large(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_storage_sizing_large.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.storage_sizing(site_design) regex = re.compile( 'Storage Sizing Error: Storage .+ size is greater than 99 on Baremetal Node .+' ) assert len(message_list) == 4 for msg in message_list: msg = msg.to_dict() assert regex.match(msg.get('message')) is not None assert msg.get('error') is True
def test_invalid_hostname(self, mocker, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator( state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = HostnameValidity() message_list = validator.execute(site_design, orchestrator=orch) for msg in message_list: msg = msg.to_dict() LOG.debug(msg) assert msg.get('error') assert len(msg.get('documents')) > 0 assert "bad__name" in msg.get('message') assert len(message_list) == 1
def test_invalid_boot_storage_small(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_boot_storage_small.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.boot_storage_rational(site_design) regex = re.compile( 'Boot Storage Error: .+ volume must be > .+GB on BaremetalNode .+') for msg in message_list: msg = msg.to_dict() assert regex.match(msg.get('message')) is not None assert msg.get('error') assert len(message_list) == 4
def test_invalid_unique_network(self, mocker, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_unique_network.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.unique_network_check(site_design) regex = re.compile( 'Unique Network Error: Allowed network .+ duplicated on NetworkLink .+ and NetworkLink .+' ) for msg in message_list: msg = msg.to_dict() assert msg.get('error') assert regex.match(msg.get('message')) is not None assert len(message_list) == 1
def test_invalid_boot_storage_root_not_set(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = BootStorageRational() message_list = validator.execute(site_design) regex = re.compile('Root volume has to be set and must be > 20GB') for msg in message_list: msg = msg.to_dict() LOG.debug(msg) assert len(msg.get('documents')) > 0 assert regex.search(msg.get('message')) is not None assert msg.get('error') assert len(message_list) == 2
def test_invalid_rational_network_trunking(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_rational_network_trunking.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.network_trunking_rational(site_design) regex = re.compile('Rational Network Trunking Error: Trunking mode is disabled, a trunking' 'default_network must be defined; on NetworkLink .+') regex_1 = re.compile('Rational Network Trunking Error: If there is more than 1 allowed network,' 'trunking mode must be enabled; on NetworkLink .+') for msg in message_list: msg = msg.to_dict() assert msg.get('error') assert regex.match(msg.get('message')) is not None or regex_1.match(msg.get('message')) is not None assert len(message_list) == 2
def test_invalid_storage_partitioning(self, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_storage_partitioning.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) message_list = Validator.storage_partitioning(site_design) regex = re.compile( 'Storage Partitioning Error: A volume group must be assigned to a storage device or ' 'partition; volume group .+ on BaremetalNode .+') for msg in message_list: msg = msg.to_dict() assert msg.get('error') assert regex.match(msg.get('message')) is not None assert len(message_list) == 2
def test_invalid_hostname(self, mocker, deckhand_ingester, drydock_state, input_files): input_file = input_files.join("invalid_validation.yaml") design_ref = "file://%s" % str(input_file) orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester) status, site_design = Orchestrator.get_effective_site(orch, design_ref) validator = HostnameValidity() message_list = validator.execute(site_design, orchestrator=orch) long_label = "sitenameisverylongsoitshouldbeinvalidperrfcifikeepaddingoctetsafewmore" for msg in message_list: msg = msg.to_dict() LOG.debug(msg) assert msg.get('error') assert len(msg.get('documents')) > 0 assert "bad__name" in msg.get('message') or long_label in msg.get( 'message') assert len(message_list) > 1