MediaWiki
REL1_31
DnsSrvDiscovererTest.php
Go to the documentation of this file.
1
<?php
2
6
class
DnsSrvDiscovererTest
extends
PHPUnit\Framework\TestCase {
7
8
use MediaWikiCoversValidator;
9
13
public
function
testPickServer
(
$params
, $expected ) {
14
$discoverer =
new
DnsSrvDiscoverer
(
'etcd-tcp.example.net'
);
15
$record = $discoverer->pickServer(
$params
);
16
17
$this->assertEquals( $expected, $record );
18
}
19
20
public
static
function
provideRecords
() {
21
return
[
22
[
23
[
// record list
24
[
25
'target'
=>
'conf03.example.net'
,
26
'port'
=>
'SRV'
,
27
'pri'
=> 0,
28
'weight'
=> 1,
29
],
30
[
31
'target'
=>
'conf02.example.net'
,
32
'port'
=>
'SRV'
,
33
'pri'
=> 1,
34
'weight'
=> 1,
35
],
36
[
37
'target'
=>
'conf01.example.net'
,
38
'port'
=>
'SRV'
,
39
'pri'
=> 2,
40
'weight'
=> 1,
41
],
42
],
// selected record
43
[
44
'target'
=>
'conf03.example.net'
,
45
'port'
=>
'SRV'
,
46
'pri'
=> 0,
47
'weight'
=> 1,
48
]
49
],
50
[
51
[
// record list
52
[
53
'target'
=>
'conf03or2.example.net'
,
54
'port'
=>
'SRV'
,
55
'pri'
=> 0,
56
'weight'
=> 1,
57
],
58
[
59
'target'
=>
'conf03or2.example.net'
,
60
'port'
=>
'SRV'
,
61
'pri'
=> 0,
62
'weight'
=> 1,
63
],
64
[
65
'target'
=>
'conf01.example.net'
,
66
'port'
=>
'SRV'
,
67
'pri'
=> 2,
68
'weight'
=> 1,
69
],
70
[
71
'target'
=>
'conf04.example.net'
,
72
'port'
=>
'SRV'
,
73
'pri'
=> 2,
74
'weight'
=> 1,
75
],
76
[
77
'target'
=>
'conf05.example.net'
,
78
'port'
=>
'SRV'
,
79
'pri'
=> 3,
80
'weight'
=> 1,
81
],
82
],
// selected record
83
[
84
'target'
=>
'conf03or2.example.net'
,
85
'port'
=>
'SRV'
,
86
'pri'
=> 0,
87
'weight'
=> 1,
88
]
89
],
90
];
91
}
92
93
public
function
testRemoveServer
() {
94
$dsd =
new
DnsSrvDiscoverer
(
'localhost'
);
95
96
$servers = [
97
[
98
'target'
=>
'conf01.example.net'
,
99
'port'
=> 35,
100
'pri'
=> 2,
101
'weight'
=> 1,
102
],
103
[
104
'target'
=>
'conf04.example.net'
,
105
'port'
=> 74,
106
'pri'
=> 2,
107
'weight'
=> 1,
108
],
109
[
110
'target'
=>
'conf05.example.net'
,
111
'port'
=> 77,
112
'pri'
=> 3,
113
'weight'
=> 1,
114
],
115
];
116
$server = $servers[1];
117
118
$expected = [
119
[
120
'target'
=>
'conf01.example.net'
,
121
'port'
=> 35,
122
'pri'
=> 2,
123
'weight'
=> 1,
124
],
125
[
126
'target'
=>
'conf05.example.net'
,
127
'port'
=> 77,
128
'pri'
=> 3,
129
'weight'
=> 1,
130
],
131
];
132
133
$this->assertEquals(
134
$expected,
135
$dsd->removeServer( $server, $servers ),
136
"Correct server removed"
137
);
138
$this->assertEquals(
139
$expected,
140
$dsd->removeServer( $server, $servers ),
141
"Nothing to remove"
142
);
143
}
144
}
DnsSrvDiscovererTest
DnsSrvDiscoverer.
Definition
DnsSrvDiscovererTest.php:6
DnsSrvDiscovererTest\testPickServer
testPickServer( $params, $expected)
provideRecords
Definition
DnsSrvDiscovererTest.php:13
DnsSrvDiscovererTest\testRemoveServer
testRemoveServer()
Definition
DnsSrvDiscovererTest.php:93
DnsSrvDiscovererTest\provideRecords
static provideRecords()
Definition
DnsSrvDiscovererTest.php:20
DnsSrvDiscoverer
Definition
DnsSrvDiscoverer.php:26
$params
$params
Definition
styleTest.css.php:40
tests
phpunit
includes
libs
DnsSrvDiscovererTest.php
Generated on Mon Nov 25 2024 15:36:24 for MediaWiki by
1.10.0