19
19
20
20
package org .elasticsearch .transport ;
21
21
22
+ import org .elasticsearch .Version ;
22
23
import org .elasticsearch .common .network .NetworkAddress ;
23
24
import org .elasticsearch .common .transport .BoundTransportAddress ;
24
25
import org .elasticsearch .common .transport .TransportAddress ;
34
35
35
36
public class TransportInfoTests extends ESTestCase {
36
37
37
- private TransportInfo createTransportInfo (InetAddress address , int port , boolean cnameInPublishAddress ) {
38
+ private TransportInfo createTransportInfo (InetAddress address , int port , boolean cnameInPublishAddressProperty ) {
38
39
BoundTransportAddress boundAddress = new BoundTransportAddress (
39
40
new TransportAddress []{new TransportAddress (address , port )},
40
41
new TransportAddress (address , port )
41
42
);
42
43
Map <String , BoundTransportAddress > profiles = Collections .singletonMap ("test_profile" , boundAddress );
43
- return new TransportInfo (boundAddress , profiles , cnameInPublishAddress );
44
+ return new TransportInfo (boundAddress , profiles , cnameInPublishAddressProperty );
45
+ }
46
+
47
+ public void testDoNotForgetToRemoveProperty () {
48
+ assertTrue ("Remove es.transport.cname_in_publish_address property from TransportInfo in 9.0.0" , Version .CURRENT .major < 9 );
44
49
}
45
50
46
51
public void testCorrectlyDisplayPublishedCname () throws Exception {
47
52
InetAddress address = InetAddress .getByName ("localhost" );
48
53
int port = 9200 ;
49
54
assertPublishAddress (
50
- createTransportInfo (address , port ,true ),
55
+ createTransportInfo (address , port , false ),
51
56
"localhost/" + NetworkAddress .format (address ) + ':' + port
52
57
);
53
58
}
54
59
55
- public void testHideCnameIfDeprecatedFormat () throws Exception {
60
+ public void testDeprecatedWarningIfPropertySpecified () throws Exception {
56
61
InetAddress address = InetAddress .getByName ("localhost" );
57
62
int port = 9200 ;
58
63
assertPublishAddress (
59
- createTransportInfo (address , port ,false ),
60
- NetworkAddress .format (address ) + ':' + port
64
+ createTransportInfo (address , port , true ),
65
+ "localhost/" + NetworkAddress .format (address ) + ':' + port
61
66
);
62
- assertWarnings ("transport.publish_address was printed as [ip:port] instead of [hostname/ip:port]. " +
63
- "This format is deprecated and will change to [hostname/ip:port] in a future version. " +
64
- "Use -Des.transport.cname_in_publish_address=true to enforce non-deprecated formatting." ,
67
+ assertWarnings ("es.transport.cname_in_publish_address system property is deprecated and no longer affects " +
68
+ "transport.publish_address formatting. Remove this property to get rid of this deprecation warning." ,
65
69
66
- "transport.test_profile.publish_address was printed as [ip:port] instead of [hostname/ip:port]. " +
67
- "This format is deprecated and will change to [hostname/ip:port] in a future version. " +
68
- "Use -Des.transport.cname_in_publish_address=true to enforce non-deprecated formatting." );
70
+ "es.transport.cname_in_publish_address system property is deprecated and no longer affects " +
71
+ "transport.test_profile.publish_address formatting. Remove this property to get rid of this deprecation warning." );
69
72
}
70
73
71
74
public void testCorrectDisplayPublishedIp () throws Exception {
72
75
InetAddress address = InetAddress .getByName (NetworkAddress .format (InetAddress .getByName ("localhost" )));
73
76
int port = 9200 ;
74
77
assertPublishAddress (
75
- createTransportInfo (address , port ,true ),
78
+ createTransportInfo (address , port , false ),
76
79
NetworkAddress .format (address ) + ':' + port
77
80
);
78
81
}
@@ -81,7 +84,7 @@ public void testCorrectDisplayPublishedIpv6() throws Exception {
81
84
InetAddress address = InetAddress .getByName (NetworkAddress .format (InetAddress .getByName ("0:0:0:0:0:0:0:1" )));
82
85
int port = 9200 ;
83
86
assertPublishAddress (
84
- createTransportInfo (address , port ,true ),
87
+ createTransportInfo (address , port , false ),
85
88
new TransportAddress (address , port ).toString ()
86
89
);
87
90
}
0 commit comments