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
|
<?php
final class VyOSElasticModernHostTestEngine
extends VyOSElasticModernFulltextStorageEngine {
}
final class VyOSElasticModernHostTestCase
extends PhutilTestCase {
public function testEngineIsConcreteForDispatch() {
// Must NOT be abstract: PhutilClassMapQuery → PhutilSymbolLoader::loadObjects()
// calls setConcreteOnly(true) which unsets abstract classes. A concrete (plain)
// class is required for cluster.search[].type:elasticsearch-modern dispatch.
$class = new ReflectionClass('VyOSElasticModernFulltextStorageEngine');
$this->assertFalse($class->isAbstract());
}
public function testDisplayName() {
$engine = new VyOSElasticModernHostTestEngine();
$host = new VyOSElasticModernHost($engine);
$this->assertEqual(
'Elasticsearch (modern)',
(string)$host->getDisplayName());
}
public function testConfigDefaults() {
$engine = new VyOSElasticModernHostTestEngine();
$host = new VyOSElasticModernHost($engine);
$host->setConfig(array());
$this->assertEqual('http', $host->getProtocol());
$this->assertEqual('phabricator/', $host->getPath());
$this->assertEqual(7, $host->getVersion());
}
public function testConfigOverrides() {
$engine = new VyOSElasticModernHostTestEngine();
$host = new VyOSElasticModernHost($engine);
$host->setConfig(array(
'host' => 'es.example.com',
'port' => 9200,
'protocol' => 'https',
'path' => '/myphorge',
'version' => 8,
));
$this->assertEqual('es.example.com', $host->getHost());
$this->assertEqual(9200, $host->getPort());
$this->assertEqual('https', $host->getProtocol());
$this->assertEqual('/myphorge', $host->getPath());
$this->assertEqual(8, $host->getVersion());
}
public function testGetURI() {
$engine = new VyOSElasticModernHostTestEngine();
$host = new VyOSElasticModernHost($engine);
$host->setConfig(array(
'host' => 'es.example.com',
'port' => 9200,
'protocol' => 'http',
'path' => '/phabricator',
));
$uri = (string)$host->getURI('/_doc/abc');
$this->assertTrue(strpos($uri, 'es.example.com') !== false);
$this->assertTrue(strpos($uri, '/_doc/abc') !== false);
}
}
|