-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_streaming_poc.php
More file actions
124 lines (105 loc) · 4.08 KB
/
test_streaming_poc.php
File metadata and controls
124 lines (105 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env php
<?php
/**
* POC Test for streaming database implementation
* This verifies that the classes are loadable and basic structure is correct
*/
require_once __DIR__ . '/cli/vendor/autoload.php';
use Localpoc\StreamingDatabaseClient;
use Localpoc\Http;
echo "Testing streaming database POC...\n\n";
// Test 1: Verify StreamingDatabaseClient class exists
if (!class_exists('Localpoc\StreamingDatabaseClient')) {
echo "❌ StreamingDatabaseClient class not found\n";
exit(1);
}
echo "✅ StreamingDatabaseClient class exists\n";
// Test 2: Verify required methods exist
$requiredMethods = ['initStream', 'fetchChunk', 'streamToFile'];
$missingMethods = [];
foreach ($requiredMethods as $method) {
if (!method_exists('Localpoc\StreamingDatabaseClient', $method)) {
$missingMethods[] = $method;
}
}
if (empty($missingMethods)) {
echo "✅ All required methods exist in StreamingDatabaseClient\n";
} else {
echo "❌ Missing methods in StreamingDatabaseClient: " . implode(', ', $missingMethods) . "\n";
exit(1);
}
// Test 3: Verify DownloadOrchestrator uses streaming
$orchestratorPath = __DIR__ . '/cli/src/Localpoc/DownloadOrchestrator.php';
$orchestratorCode = file_get_contents($orchestratorPath);
if (strpos($orchestratorCode, 'StreamingDatabaseClient') !== false) {
echo "✅ DownloadOrchestrator imports StreamingDatabaseClient\n";
} else {
echo "❌ DownloadOrchestrator does not import StreamingDatabaseClient\n";
exit(1);
}
if (strpos($orchestratorCode, '$useStreaming = true') !== false) {
echo "✅ DownloadOrchestrator has streaming flag enabled\n";
} else {
echo "❌ DownloadOrchestrator does not have streaming flag\n";
exit(1);
}
if (strpos($orchestratorCode, 'streamToFile') !== false || strpos($orchestratorCode, 'fetchChunk') !== false) {
echo "✅ DownloadOrchestrator calls streamToFile or fetchChunk method\n";
} else {
echo "❌ DownloadOrchestrator does not call streamToFile or fetchChunk\n";
exit(1);
}
// Test 4: Verify plugin files exist
$pluginFiles = [
'/plugin/includes/class-database-stream-manager.php' => 'Database Stream Manager',
];
foreach ($pluginFiles as $file => $name) {
$fullPath = __DIR__ . $file;
if (file_exists($fullPath)) {
echo "✅ Plugin file exists: $name\n";
// Check if class is defined
$content = file_get_contents($fullPath);
if (strpos($content, 'class LocalPOC_Database_Stream_Manager') !== false) {
echo " ✅ Class LocalPOC_Database_Stream_Manager is defined\n";
} else {
echo " ❌ Class LocalPOC_Database_Stream_Manager not found\n";
exit(1);
}
} else {
echo "❌ Plugin file missing: $name at $fullPath\n";
exit(1);
}
}
// Test 5: Check AJAX handlers
$ajaxPath = __DIR__ . '/plugin/includes/class-ajax-handlers.php';
$ajaxCode = file_get_contents($ajaxPath);
$streamingEndpoints = ['db_stream_init', 'db_stream_chunk'];
foreach ($streamingEndpoints as $endpoint) {
if (strpos($ajaxCode, "function $endpoint") !== false) {
echo "✅ AJAX handler exists: $endpoint\n";
} else {
echo "❌ AJAX handler missing: $endpoint\n";
exit(1);
}
}
// Test 6: Check plugin registration
$pluginPath = __DIR__ . '/plugin/includes/class-plugin.php';
$pluginCode = file_get_contents($pluginPath);
if (strpos($pluginCode, 'localpoc_db_stream_init') !== false &&
strpos($pluginCode, 'localpoc_db_stream_chunk') !== false) {
echo "✅ Streaming endpoints registered in plugin\n";
} else {
echo "❌ Streaming endpoints not registered in plugin\n";
exit(1);
}
echo "\n";
echo "========================================\n";
echo "✅ All POC tests passed successfully!\n";
echo "========================================\n";
echo "\n";
echo "The streaming database POC is ready for testing.\n";
echo "Next steps:\n";
echo "1. Deploy the plugin to a test WordPress site\n";
echo "2. Run: lm download --url='<site>' --key='<key>' --output='./test'\n";
echo "3. Monitor the output for streaming messages\n";
echo "4. Verify db.sql is created with correct content\n";