-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_sample_files
executable file
·74 lines (67 loc) · 2.1 KB
/
make_sample_files
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
#!/usr/bin/env php
<?php
// set up the Librarian DB for testing.
// Create a bunch of observations and files.
// Do this using RPCs rather than direct DB access
require_once("hera_util.inc");
require_once("test_setup.inc");
require_once("hl_rpc_client.php");
//require_once("mc_rpc_client.php");
function test_setup() {
global $test_stores;
$pols = array('xx', 'yy', 'xy', 'yx');
$nstores = count($test_stores);
// make the store directories
//
foreach ($test_stores as $store) {
@mkdir($store->path_prefix);
}
// make 10 observations
//
for ($i=1; $i<=10; $i++) {
$julian_date = time() - rand(0, 100*86400);
$polarization = $pols[rand(0, 3)];
$length = .1*rand(0, 864000);
// $ret = mc_create_observation($julian_date, $polarization, $length);
// if (!$ret->success) {
// echo "mc_create_observation() error: $ret->message\n";
// continue;
// }
// $obs_id = $ret->id;
$obs_id = $i;
$ret = create_observation(
TEST_SITE_NAME, $obs_id, $julian_date, $polarization, $length
);
if (!$ret->success) {
echo "create_observation() error: $ret->message\n";
}
// for each observation, create a few files.
// Put them on store 0.
//
for ($j=0; $j<4; $j++) {
$f = "file_".$obs_id."_$j";
$store = $test_stores[0];
if (1) {
$path = $store->path_prefix.'/'.$f;
$string = "aslkjsdf $i $j\n";
file_put_contents($path, $string);
$size = -1;
$md5 = null;
} else {
$size = rand(1, 100)*1.e9;
$md5 = random_string();
}
$ret = create_file(
TEST_SITE_NAME, $store->name, $f, '', $obs_id, $size, $md5
);
if ($ret->success) {
echo "created file $f\n";
} else {
echo "create_file() error: $ret->message\n";
continue;
}
}
}
}
test_setup();
?>