52
52
53
53
public class FileBasedUnicastHostsProviderTests extends ESTestCase {
54
54
55
- private boolean legacyLocation ;
56
55
private ThreadPool threadPool ;
57
56
private ExecutorService executorService ;
58
57
private MockTransportService transportService ;
59
- private Path configPath ;
60
58
61
59
@ Before
62
60
public void setUp () throws Exception {
@@ -108,24 +106,12 @@ public void testBuildDynamicNodes() throws Exception {
108
106
assertEquals (9300 , nodes .get (2 ).getPort ());
109
107
}
110
108
111
- public void testBuildDynamicNodesLegacyLocation () throws Exception {
112
- legacyLocation = true ;
113
- testBuildDynamicNodes ();
114
- assertDeprecatedLocationWarning ();
115
- }
116
-
117
109
public void testEmptyUnicastHostsFile () throws Exception {
118
110
final List <String > hostEntries = Collections .emptyList ();
119
111
final List <TransportAddress > addresses = setupAndRunHostProvider (hostEntries );
120
112
assertEquals (0 , addresses .size ());
121
113
}
122
114
123
- public void testEmptyUnicastHostsFileLegacyLocation () throws Exception {
124
- legacyLocation = true ;
125
- testEmptyUnicastHostsFile ();
126
- assertDeprecatedLocationWarning ();
127
- }
128
-
129
115
public void testUnicastHostsDoesNotExist () {
130
116
final Settings settings = Settings .builder ().put (Environment .PATH_HOME_SETTING .getKey (), createTempDir ()).build ();
131
117
final FileBasedUnicastHostsProvider provider = new FileBasedUnicastHostsProvider (settings , createTempDir ().toAbsolutePath ());
@@ -141,12 +127,6 @@ public void testInvalidHostEntries() throws Exception {
141
127
assertEquals (0 , addresses .size ());
142
128
}
143
129
144
- public void testInvalidHostEntriesLegacyLocation () throws Exception {
145
- legacyLocation = true ;
146
- testInvalidHostEntries ();
147
- assertDeprecatedLocationWarning ();
148
- }
149
-
150
130
public void testSomeInvalidHostEntries () throws Exception {
151
131
final List <String > hostEntries = Arrays .asList ("192.168.0.1:9300:9300" , "192.168.0.1:9301" );
152
132
final List <TransportAddress > addresses = setupAndRunHostProvider (hostEntries );
@@ -155,41 +135,21 @@ public void testSomeInvalidHostEntries() throws Exception {
155
135
assertEquals (9301 , addresses .get (0 ).getPort ());
156
136
}
157
137
158
- public void testSomeInvalidHostEntriesLegacyLocation () throws Exception {
159
- legacyLocation = true ;
160
- testSomeInvalidHostEntries ();
161
- assertDeprecatedLocationWarning ();
162
- }
163
-
164
138
// sets up the config dir, writes to the unicast hosts file in the config dir,
165
139
// and then runs the file-based unicast host provider to get the list of discovery nodes
166
140
private List <TransportAddress > setupAndRunHostProvider (final List <String > hostEntries ) throws IOException {
167
141
final Path homeDir = createTempDir ();
168
142
final Settings settings = Settings .builder ()
169
143
.put (Environment .PATH_HOME_SETTING .getKey (), homeDir )
170
144
.build ();
171
- if (randomBoolean ()) {
172
- configPath = homeDir .resolve ("config" );
173
- } else {
174
- configPath = createTempDir ();
175
- }
176
- final Path discoveryFilePath = legacyLocation ? configPath .resolve ("discovery-file" ) : configPath ;
177
- Files .createDirectories (discoveryFilePath );
178
- final Path unicastHostsPath = discoveryFilePath .resolve (UNICAST_HOSTS_FILE );
179
- try (BufferedWriter writer = Files .newBufferedWriter (unicastHostsPath )) {
145
+ final Path configPath = randomBoolean () ? homeDir .resolve ("config" ) : createTempDir ();
146
+ Files .createDirectories (configPath );
147
+ try (BufferedWriter writer = Files .newBufferedWriter (configPath .resolve (UNICAST_HOSTS_FILE ))) {
180
148
writer .write (String .join ("\n " , hostEntries ));
181
149
}
182
150
183
151
return new FileBasedUnicastHostsProvider (settings , configPath ).buildDynamicHosts ((hosts , limitPortCounts ) ->
184
152
UnicastZenPing .resolveHostsLists (executorService , logger , hosts , limitPortCounts , transportService ,
185
153
TimeValue .timeValueSeconds (10 )));
186
154
}
187
-
188
- private void assertDeprecatedLocationWarning () {
189
- assertWarnings ("Found dynamic hosts list at [" +
190
- configPath .resolve ("discovery-file" ).resolve (UNICAST_HOSTS_FILE ) +
191
- "] but this path is deprecated. This list should be at [" +
192
- configPath .resolve (UNICAST_HOSTS_FILE ) +
193
- "] instead. Support for the deprecated path will be removed in future." );
194
- }
195
155
}
0 commit comments