rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / libs / DnsSrvDiscovererTest.php
blobcfc2d91b0d830dd716aa4f2135ecb66e0d1322cb
1 <?php
3 class DnsSrvDiscovererTest extends PHPUnit_Framework_TestCase {
4 /**
5 * @covers DnsSrvDiscoverer
6 * @dataProvider provideRecords
7 */
8 public function testPickServer( $params, $expected ) {
9 $discoverer = new DnsSrvDiscoverer( 'etcd-tcp.example.net' );
10 $record = $discoverer->pickServer( $params );
12 $this->assertEquals( $expected, $record );
15 public static function provideRecords() {
16 return [
18 [ // record list
20 'target' => 'conf03.example.net',
21 'port' => 'SRV',
22 'pri' => 0,
23 'weight' => 1,
26 'target' => 'conf02.example.net',
27 'port' => 'SRV',
28 'pri' => 1,
29 'weight' => 1,
32 'target' => 'conf01.example.net',
33 'port' => 'SRV',
34 'pri' => 2,
35 'weight' => 1,
37 ], // selected record
39 'target' => 'conf03.example.net',
40 'port' => 'SRV',
41 'pri' => 0,
42 'weight' => 1,
46 [ // record list
48 'target' => 'conf03or2.example.net',
49 'port' => 'SRV',
50 'pri' => 0,
51 'weight' => 1,
54 'target' => 'conf03or2.example.net',
55 'port' => 'SRV',
56 'pri' => 0,
57 'weight' => 1,
60 'target' => 'conf01.example.net',
61 'port' => 'SRV',
62 'pri' => 2,
63 'weight' => 1,
66 'target' => 'conf04.example.net',
67 'port' => 'SRV',
68 'pri' => 2,
69 'weight' => 1,
72 'target' => 'conf05.example.net',
73 'port' => 'SRV',
74 'pri' => 3,
75 'weight' => 1,
77 ], // selected record
79 'target' => 'conf03or2.example.net',
80 'port' => 'SRV',
81 'pri' => 0,
82 'weight' => 1,
88 public function testRemoveServer() {
89 $dsd = new DnsSrvDiscoverer( 'localhost' );
91 $servers = [
93 'target' => 'conf01.example.net',
94 'port' => 35,
95 'pri' => 2,
96 'weight' => 1,
99 'target' => 'conf04.example.net',
100 'port' => 74,
101 'pri' => 2,
102 'weight' => 1,
105 'target' => 'conf05.example.net',
106 'port' => 77,
107 'pri' => 3,
108 'weight' => 1,
111 $server = $servers[1];
113 $expected = [
115 'target' => 'conf01.example.net',
116 'port' => 35,
117 'pri' => 2,
118 'weight' => 1,
121 'target' => 'conf05.example.net',
122 'port' => 77,
123 'pri' => 3,
124 'weight' => 1,
128 $this->assertEquals(
129 $expected,
130 $dsd->removeServer( $server, $servers ),
131 "Correct server removed"
133 $this->assertEquals(
134 $expected,
135 $dsd->removeServer( $server, $servers ),
136 "Nothing to remove"