Bug 731587

Summary: Metric templates import not robust enough
Product: [Other] RHQ Project Reporter: Lukas Krejci <lkrejci>
Component: CLIAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.2CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-07 19:17:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 707232    

Description Lukas Krejci 2011-08-17 22:27:46 UTC
The import of metric templates should be robust against metric templates not present in the target RHQ installation as well as against duplicit metric template definitions in the export file, both of which should be treated as validation errors.

Steps to reproduce:
1) create an configuration export file
2) gunzip the file and change some metric template - introduce a typo in one of its attributes.
3) gzip the file again and import it to the RHQ server

Actual results:
The import silently ignores the not-matching metric templates

Expected results:
The import should fail with an error message.

Comment 1 Lukas Krejci 2011-08-17 22:48:45 UTC
commit d7449e1aeefbea1354204e51d142fabca29d7889
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Thu Aug 18 00:29:00 2011 +0200

    BZ 731587 - added a new metric template validator that checks that the imported metric templates match records in the database and are not duplicated in the export file.

Comment 2 Mike Foley 2011-08-22 18:51:33 UTC
retested as follows:
1) exported a server configuration:

var ex = SynchronizationManager.exportAllSubsystems();
saveBytesToFile(ex.exportFile, 'export.xml.gz');

2) edit'ed the export.xml file as follows:

i introduced a typo (per step 2 of the steps to reproduce) ...

original:  <entry key="RT_DATA_PURGE">2678400000</entry>
with typo: <entry keyx="RT_DATA_PURGE">abc</entry>

3) imported the configuration, as follows:

var definitions = SynchronizationManager.importConfigurationDefinitionOfAllSynchronizers;

var data = getFileBytes('export.xml.gz');
SynchronizationManager.importAllSubsystems(data, null);

4) correctly received an exception (documented below).  the exception and validation error is the correct response ... this is a negative test that had been failing silently ... now produces meaningful error message.

Wrapped javax.ejb.EJBException: [Warning] org.rhq.enterprise.server.sync.ValidationException
Reports of individual validators:

ConsistencyValidatorFailureReport[validator='org.rhq.enterprise.server.sync.validators.SystemSettingsValidator', message='org.rhq.enterprise.server.sync.ValidationException: Failed to validate entity [SystemSettings[CAM_BASE_URL = 'http://10.0.1.189:7080/', CAM_LDAP_BIND_DN = '', CAM_DATA_PURGE_6H = '2678400000', ACTIVE_DRIFT_PLUGIN = 'drift-jpa', SERVER_VERSION = '4.1.0-SNAPSHOT', CAM_GUIDE_ENABLED = '1', EVENT_PURGE = '1209600000', CAM_HELP_USER = 'web', CAM_DATA_MAINTENANCE = '3600000', AGENT_MAX_QUIET_TIME_ALLOWED = '900000', ALERT_PURGE = '2678400000', CAM_SYSLOG_ACTIONS_ENABLED = '0', CAM_BASELINE_FREQUENCY = '259200000', CAM_LDAP_LOGIN_PROPERTY = 'cn', null = 'abc', ENABLE_AGENT_AUTO_UPDATE = 'true', CAM_LDAP_NAMING_PROVIDER_URL = 'ldap://localhost/', DRIFT_FILE_PURGE = '2678400000', DB_SCHEMA_VERSION = '2.114', CAM_LDAP_NAMING_FACTORY_INITIAL = 'com.sun.jndi.ldap.LdapCtxFactory', CAM_LDAP_BIND_PW = '', AVAILABILITY_PURGE = '31536000000', TRAIT_PURGE = '31536000000', CAM_LDAP_PROTOCOL = '', CAM_LDAP_FILTER = '', CAM_LDAP_BASE_DN = 'o=JBoss,c=US', CAM_JAAS_PROVIDER = 'JDBC', CAM_BASELINE_DATASET = '604800000', CAM_DATA_PURGE_1H = '1209600000', CAM_RT_COLLECT_IP_ADDRS = '1', CAM_HELP_PASSWORD = 'user', DATA_REINDEX_NIGHTLY = 'true', CAM_DATA_PURGE_1D = '31536000000', RESOURCE_GENERIC_PROPERTIES_UPGRADE = '0']]
	at org.rhq.enterprise.server.sync.SynchronizationManagerBean.validateEntities(SynchronizationManagerBean.java:334)
	at org.rhq.enterprise.server.sync.SynchronizationManagerBean.validateExport(SynchronizationManagerBean.java:261)
	at org.rhq.enterprise.server.sync.SynchronizationManagerBean.importAllSubsystems(SynchronizationManagerBean.java:161)

Comment 3 Mike Foley 2012-02-07 19:17:45 UTC
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE