Skip to content

Commit

Permalink
Tests with new minimal sample dataset
Browse files Browse the repository at this point in the history
Add RoleServiceTest2 to testsuite.

Simplistic creation of minimal user objects for testing
failed due to incoming requirement for UserIdentifiers.
  • Loading branch information
Ian Neilson committed Jun 13, 2022
1 parent 47e261f commit 2a753f1
Show file tree
Hide file tree
Showing 28 changed files with 1,265 additions and 150 deletions.
22 changes: 15 additions & 7 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,23 @@ $ cd lib/Doctrine
$ php deploy/DeployRequiredDataRunner.php requiredData
```

### Deploy Sample Data<a id="deploy-sample-data"></a>
### OPTIONAL: Deploy Sample Data<a id="deploy-sample-data"></a>

Optional - you can deploy some sample data to seed your DB with sample users,
sites and services.
You can choose to deploy some sample data to seed your DB with sample users,
sites and services. Two sample data sets are available. Choose one of -

```bash
$ cd lib/Doctrine
$ php deploy/DeploySampleDataRunner.php sampleData
```
1. Minimal - just enough to get going with no real-world associations.

```bash
$ cd lib/Doctrine
$ php deploy/DeploySampleDataRunner.php simpleSampleData
```
1. "Real World" - a small subset derived from real data.

```bash
$ cd lib/Doctrine
$ php deploy/DeploySampleDataRunner.php sampleData
```

### ORACLE ONLY: Deploy an existing DB .dmp file to populate your DB<a id="deploy-existing-dump"></a>

Expand Down
34 changes: 1 addition & 33 deletions lib/Doctrine/deploy/AddGroupRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,6 @@
require_once __DIR__."/../bootstrap.php";
require_once __DIR__."/AddUtils.php";

/**
* AddNGIs.php: Loads a list of NGIs from an XML file and inserts them into
* the doctrine prototype.
* XML format is the output from get_roc_list PI query, e.g:
<EGEE_USER USER_ID=" " PRIMARY_KEY="63777G0">
<FORENAME>Patricia</FORENAME>
<SURNAME>Gomes</SURNAME>
<TITLE>Miss</TITLE>
<DESCRIPTION></DESCRIPTION>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=113158&amp;grid_id=0</GOCDB_PORTAL_URL>
<EMAIL>[email protected]</EMAIL>
<TEL>+55(21)21417419</TEL>
<WORKING_HOURS_START></WORKING_HOURS_START>
<WORKING_HOURS_END></WORKING_HOURS_END>
<CERTDN>/C=BR/O=ICPEDU/O=UFF BrGrid CA/O=CBPF/OU=LAFEX/CN=Patricia Gomes</CERTDN>
<APPROVED></APPROVED>
<ACTIVE></ACTIVE>
<HOMESITE></HOMESITE>
<USER_ROLE>
<USER_ROLE>Regional First Line Support</USER_ROLE>
<ON_ENTITY>ROC_LA</ON_ENTITY>
<ENTITY_TYPE>group</ENTITY_TYPE>
</USER_ROLE>
<USER_ROLE>
<USER_ROLE>Site Operations Deputy Manager</USER_ROLE>
<ON_ENTITY>CBPF</ON_ENTITY>
<ENTITY_TYPE>site</ENTITY_TYPE>
</USER_ROLE>
</EGEE_USER>
*/
$usersRolesFileName = __DIR__ . "/" . $GLOBALS['dataDir'] . "/UsersAndRoles.xml";
$usersRoles = simplexml_load_file($usersRolesFileName);

Expand Down Expand Up @@ -125,4 +93,4 @@
}
}

$entityManager->flush();
$entityManager->flush();
51 changes: 51 additions & 0 deletions lib/Doctrine/deploy/AddServiceGroups.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

require_once __DIR__."/../bootstrap.php";
require_once __DIR__."/AddUtils.php";

/* Loads a list of service types from an XML file and inserts them into
* the doctrine prototype.
* XML format is the PROM GOCDB PI output for get_service_type
*/
$stFileName = __DIR__ . "/" . $GLOBALS['dataDir'] . "/ServiceGroups.xml";
$sts = simplexml_load_file($stFileName);

foreach($sts as $st) {
$instance = new ServiceGroup();
$name = "";
$desc = "";
$monitored = false;
$email = "default@an_email.net";
$scope = "Local";

foreach ($st as $key => $value) {
switch ($key) {
case "NAME":
$name = (string) $value;
break;
case "DESCRIPTION":
$desc = (string) $value;
break;
case "MONITORED":
if ( (string) $value == "Y") {$monitored = true;}
break;
case "CONTACT_EMAIL":
$email = (string) $value;
break;
case "SCOPE":
$scope = (string) $value;
break;
default:
throw new LogicException("Unknown ServiceGroup key in input XML: ". $key);
}
}
$instance->setName($name);
$instance->setDescription($desc);
$instance->setMonitored($monitored);
$instance->setEmail($email);
$instance->addScope(getScope($entityManager, $scope));

$entityManager->persist($instance);
}

$entityManager->flush();
2 changes: 1 addition & 1 deletion lib/Doctrine/deploy/AddSiteRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@
}
}
}
$entityManager->flush();
$entityManager->flush();
18 changes: 2 additions & 16 deletions lib/Doctrine/deploy/AddSites.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,7 @@
}
$doctrineSite->setCertificationStatus($certStatus);

// get the scope
$dql = "SELECT s FROM Scope s WHERE s.name = ?1";
$scopes = $entityManager->createQuery($dql)
->setParameter(1, (string) $xmlSite->SCOPE)
->getResult();
/* Error checking: ensure each Site's "SCOPE" refers to exactly
* one SCOPE */
if(count($scopes) !== 1) {
throw new Exception(count($scopes) . " SCOPEs found with name: " .
$xmlSite->SCOPE);
}
foreach($scopes as $scope) {
$scope = $scope;
}
$doctrineSite->addScope($scope);
$doctrineSite->addScope(getScope($entityManager, (string) $xmlSite->SCOPE));

// get / set the country
$dql = "SELECT c FROM Country c WHERE c.name = ?1";
Expand Down Expand Up @@ -241,4 +227,4 @@
$entityManager->flush();
} catch (Exception $e) {
echo $e->getMessage();
}
}
15 changes: 0 additions & 15 deletions lib/Doctrine/deploy/AddTiers.php

This file was deleted.

22 changes: 0 additions & 22 deletions lib/Doctrine/deploy/AddTimezones.php

This file was deleted.

22 changes: 21 additions & 1 deletion lib/Doctrine/deploy/AddUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,24 @@ function isBad($site) {
} else {
return true;
}
}
}
/**
* Return a scope object given a scope name
* @param EntityManager $entityManager
* @param string $scope
* @return \Scope
*/
function getScope($entityManager, $scope) {
// get the scope
$dql = "SELECT s FROM Scope s WHERE s.name = ?1";
$scopes = $entityManager->createQuery($dql)
->setParameter(1, $scope)
->getResult();
/* Error checking: ensure each Site's "SCOPE" refers to exactly
* one SCOPE */
if(count($scopes) !== 1) {
throw new Exception(count($scopes) . " SCOPEs found with name: " . $scope);
}

return $scopes[0];
}
8 changes: 1 addition & 7 deletions lib/Doctrine/deploy/DeployRequiredDataRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@
require __DIR__."/AddCountries.php";
echo "Added Countries OK\n";

//require __DIR__."/AddTimezones.php";
//echo "Added Timezones OK\n";

require __DIR__."/AddTiers.php";
echo "Added Tiers OK\n";

require __DIR__."/AddRoleTypes.php";
echo "Added Roles OK\n";

require __DIR__."/AddCertificationStatuses.php";
echo "Added Certification Statuses OK\n";

require __DIR__."/AddServiceTypes.php";
echo "Added Service Types OK\n";
echo "Added Service Types OK\n";
7 changes: 5 additions & 2 deletions lib/Doctrine/deploy/DeploySampleDataRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
die("Please specify your data directory (sampleData) \n");
}

print_r("Deploying Sample Data\n");
print_r("Deploying Sample Data from ".$GLOBALS['dataDir']."\n");

require __DIR__."/AddProjects.php";
echo "Added Projects OK\n";
Expand All @@ -49,4 +49,7 @@
echo "Added NGI level Roles OK\n";

require __DIR__."/AddEgiRoles.php";
echo "Added EGI level Roles OK\n";
echo "Added EGI level Roles OK\n";

require __DIR__."/AddServiceGroups.php";
echo "Added Service Groups OK\n";
11 changes: 11 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/CertStatusChanges.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<result>
<UNIX_TIME>1262304001</UNIX_TIME>
<SITE>SITE_1</SITE>
<OLD_STATUS>Uncertified</OLD_STATUS>
<NEW_STATUS>Certified</NEW_STATUS>
<CHANGED_BY>/CN=SOME CN</CHANGED_BY>
<COMMENT>Record of a change of status</COMMENT>
</result>
</results>
8 changes: 8 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/CertStatusDate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<site>
<name>SITE_1</name>
<cert_status>Certified</cert_status>
<cert_date>01-JAN-10 00.00.01 AM</cert_date>
</site>
</results>
9 changes: 9 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/NGIs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<NGI>
<NAME>NGI-1</NAME>
<DESCRIPTION>A sample NGI</DESCRIPTION>
<EMAIL>[email protected]</EMAIL>
<SECURITY_EMAIL>[email protected]</SECURITY_EMAIL>
</NGI>
</results>
10 changes: 10 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/Scopes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Required tag seed data for scoping Sites and SEs -->
<results>
<tag grid_id="0">
<name key="primary">Local</name>
</tag>
<tag grid_id="0">
<name key="primary">EGI</name>
</tag>
</results>
26 changes: 26 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/ServiceEndpoints.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<SERVICE_ENDPOINT PRIMARY_KEY="44657G0">
<SITENAME>SITE-1</SITENAME>
<HOSTNAME>service-1.site-1.org</HOSTNAME>
<SERVICE_TYPE>CE</SERVICE_TYPE>
<IN_PRODUCTION>Y</IN_PRODUCTION>
<NODE_MONITORED>Y</NODE_MONITORED>
<SCOPE>Local</SCOPE>
<HOSTDN>/DC=org/DC=site-1/CN=service-1.site-1.org</HOSTDN>
<HOST_IP>127.0.0.01</HOST_IP>
<HOST_OS>SL5</HOST_OS>
<HOST_ARCH>64 bit</HOST_ARCH>
<DESCRIPTION>A service on Site 1</DESCRIPTION>

<URL></URL>
<!--
<PRIMARY_KEY>44657G0</PRIMARY_KEY>
<GOCDB_PORTAL_URL>https://testing.host.com/portal/index.php?Page_Type=View_Object&amp;object_id=26149&amp;grid_id=0</GOCDB_PORTAL_URL>
<BETA>N</BETA>
<CORE></CORE>
<COUNTRY_NAME>Switzerland</COUNTRY_NAME>
<COUNTRY_CODE>CH</COUNTRY_CODE>
<ROC_NAME>NGI_CH</ROC_NAME> -->
</SERVICE_ENDPOINT>
</results>
19 changes: 19 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/ServiceGroups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<SERVICE_GROUP>
<NAME>Group1_Services</NAME>
<DESCRIPTION>A test service group</DESCRIPTION>
<MONITORED>Y</MONITORED>
<CONTACT_EMAIL>[email protected]</CONTACT_EMAIL>
<SCOPE>Local</SCOPE>
<!--
<SERVICE_ENDPOINT>
<HOSTNAME>service-1.site-1.org</HOSTNAME>
<SERVICE_TYPE>CE</SERVICE_TYPE>
<HOST_IP>127.0.0.01</HOST_IP>
<IN_PRODUCTION>Y</IN_PRODUCTION>
<NODE_MONITORED>Y</NODE_MONITORED>
</SERVICE_ENDPOINT>
-->
</SERVICE_GROUP>
</results>
28 changes: 28 additions & 0 deletions lib/Doctrine/deploy/simpleSampleData/Sites.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<SITE>
<PRIMARY_KEY>SITE-PK-1</PRIMARY_KEY>
<SHORT_NAME>SITE-1</SHORT_NAME>
<OFFICIAL_NAME>SITE NUMBER 1</OFFICIAL_NAME>
<SITE_DESCRIPTION>Test site description for Site 1.</SITE_DESCRIPTION>
<HOME_URL>http://www.site-1.org/</HOME_URL>
<CONTACT_EMAIL>[email protected]</CONTACT_EMAIL>
<CSIRT_EMAIL>[email protected]</CSIRT_EMAIL>
<CONTACT_TEL>+12 34 5678 01</CONTACT_TEL>
<COUNTRY_CODE>DK</COUNTRY_CODE>
<COUNTRY>Denmark</COUNTRY>
<ROC>NGI-1</ROC>
<PRODUCTION_INFRASTRUCTURE>Test</PRODUCTION_INFRASTRUCTURE>
<CERTIFICATION_STATUS>Certified</CERTIFICATION_STATUS>
<TIMEZONE>Europe/Zurich</TIMEZONE>
<IP_RANGE>127.0.0.1/127.0.0.99</IP_RANGE>
<CSIRTTEL>+12 34 5678 02</CSIRTTEL>
<EMERGENCYTEL>+12 34 5678 03</EMERGENCYTEL>
<SCOPE>EGI</SCOPE>
<DOMAIN>
<DOMAIN_NAME>site-1.org</DOMAIN_NAME>
</DOMAIN>
<LONGITUDE>-06.47</LONGITUDE>
<LATITUDE>62.00</LATITUDE>
</SITE>
</results>
Loading

0 comments on commit 2a753f1

Please sign in to comment.