Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure resourcetypes table is correctly populated. #1108

Merged
merged 1 commit into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/OpenXdmod/DataWarehouseInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function ingestAllShredded($startDate = null, $endDate = null)
}

$this->logger->debug('Ingesting shredded data to staging tables');
Utilities::runEtlPipeline(array('staging-ingest-common', 'staging-ingest-jobs', 'ingest-resource-types'), $this->logger);
Utilities::runEtlPipeline(array('staging-ingest-common', 'staging-ingest-jobs'), $this->logger);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions configuration/etl/etl.d/staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@
}
}
},
{
"name": "ResourceTypesStagingUnknown",
"description": "Populates the resource types table w/ the Unknown resource",
"namespace": "ETL\\Maintenance",
"class": "ExecuteSql",
"options_class": "MaintenanceOptions",
"sql_file_list": [
"cloud_openstack/unknown_resource_type.sql"
]
},
{
"name": "resource-config",
"description": "Ingest resource configuration file",
Expand Down
63 changes: 63 additions & 0 deletions configuration/etl/etl.d/xdmod-migration-8_1_2-8_5_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,69 @@
}
}
},
{
"name": "ResourceTypesStagingUnknown",
"description": "Populates the resource types table w/ the Unknown resource",
"namespace": "ETL\\Maintenance",
"class": "ExecuteSql",
"options_class": "MaintenanceOptions",
"sql_file_list": [
"cloud_openstack/unknown_resource_type.sql"
],
"endpoints": {
"destination": {
"type": "mysql",
"name": "Shredder/Staging Database",
"config": "database",
"schema": "mod_shredder",
"definition_file": "common/staging/resource-type-realms.json"
}
}
},
{
"name": "ResourceTypesHpcdb",
"description": "Ingest resource types",
"definition_file": "common/hpcdb/resource-types.json",
"namespace": "ETL\\Ingestor",
"class": "DatabaseIngestor",
"options_class": "IngestorOptions",
"endpoints": {
"source": {
"type": "mysql",
"name": "Staging tables",
"config": "database",
"schema": "mod_shredder"
},
"destination": {
"type": "mysql",
"name": "HPCDB Database",
"config": "database",
"schema": "mod_hpcdb"
}
}
},
{
"name": "ResourceTypesDatawarehouse",
"definition_file": "jobs/xdw/resource-type.json",
"namespace": "ETL\\Ingestor",
"description": "resource type records",
"class": "DatabaseIngestor",
"options_class": "IngestorOptions",
"endpoints": {
"source": {
"type": "mysql",
"name": "HPCDB",
"config": "datawarehouse",
"schema": "mod_hpcdb"
},
"destination": {
"type": "mysql",
"name": "Datawarehouse",
"config": "datawarehouse",
"schema": "modw"
}
}
},
{
"class": "DatabaseIngestor",
"name": "IngestInitialRealms",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
INSERT INTO ${DESTINATION_SCHEMA}.`staging_resource_type` (resource_type_id, resource_type_description, resource_type_abbrev)
VALUES (-1, 'Unknown Resource Type', 'UNK');
SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO';
INSERT IGNORE INTO ${DESTINATION_SCHEMA}.`staging_resource_type` (resource_type_id, resource_type_description, resource_type_abbrev)
VALUES ('0', 'Unknown Resource Type', 'UNK');
8 changes: 8 additions & 0 deletions tests/ci/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ do
fi
done

# Check that the unknown resource is in the database with key 0
unkrescount=$(echo 'SELECT COUNT(*) from resourcetype WHERE id = 0 and abbrev = '"'"'UNK'"'" | mysql -N modw)
if [ $unkrescount -ne 1 ];
then
echo "Missing / inconsistent 'UNK' row in modw.resourcetype"
exitcode=1
fi

exit $exitcode