Files
namaste/stubs/testMigrations.php
gramps 373ebc8c93 Archive: Namaste PHP AMQP framework v1.0 (2017-2020)
952 days continuous production uptime, 40k+ tp/s single node.
Original corpo Bitbucket history not included — clean archive commit.
2026-04-05 09:49:30 -07:00

69 lines
2.5 KiB
PHP

<?php
/**
* testMigration() --- test stub
*
* used to test the migration process by submitting a request (instantiating the class submits the request) either
* as an object or as a broker event. If we submit the request as an object, we can use the debugger to trace the
* code flow. Once this is solid, turn on the broker processing so we can evaluate the broker's ability to handle
* the request.
*
* @author mike@givingassistant.org
* @version 1.0
*
* HISTORY:
* ========
* 02-21-18 mks _INF-139: original coding
*
*/
// load the namaste environment
require_once(dirname(__DIR__) . '/config/sneakerstrap.inc');
const OBJECT = 1;
const BROKER = 2;
// if processing is OBJECT, we can use the debugger
// if processing is BROKER, event is passed to migration broker
$processing = OBJECT;
// set up the data payloads
$meta = [
META_CLIENT => CLIENT_SYSTEM,
META_CLIENT_IP => STRING_SESSION_HOME,
META_EVENT_GUID => guid(), // simulate a broker event by generating the event guid
META_LIMIT => 1, // limit the deletes to deleting just the last record created
];
$brokerData = [
MIGRATION_SOURCE_SCHEMA => STRING_MYSQL,
MIGRATION_SOURCE_TABLE => 'product_registrations',
MIGRATION_DEST_SCHEMA => STRING_MYSQL, // either STRING_MYSQL or STRING_MONGO
// MIGRATION_DEST_TABLE => TEMPLATE_CLASS_PRODUCT_REG,
MIGRATION_DEST_TABLE => TEMPLATE_CLASS_PROD_REGS,
MIGRATION_FILTER_SOFT_DELETES => 0, // if 1: soft deleted records will not be imported
MIGRATION_FILTER_PARTIALS => 0, // if 1: a record will not be imported if a field fails validation
MIGRATION_TEST_MODE => 0 // if 1: no records will be migrated, test-report generated
];
// submit the request
if ($processing == OBJECT) {
// submit the request at the object level for debugging
$testObject = new gacMigrations($brokerData, $meta);
var_export( ($testObject->status) ? $testObject->migrationReport : $testObject->errorStack );
if (is_object($testObject)) $testObject->__destruct();
unset($testObject);
} else {
// submit the request to the broker
$bc = new gacBrokerClient(BROKER_QUEUE_M, basename(__FILE__) . COLON_NS . __LINE__);
$request = [
BROKER_REQUEST => BROKER_REQUEST_MIGRATION,
BROKER_DATA => $brokerData,
BROKER_META_DATA => $meta
];
$payload = gzcompress(json_encode($request));
$response = json_decode(gzuncompress($bc->call($payload)), true);
var_export($response);
if (is_object($bc)) $bc->__destruct();
unset($bc);
}