1919
2020package org .elasticsearch .transport ;
2121
22+ import org .elasticsearch .Version ;
2223import org .elasticsearch .common .network .NetworkAddress ;
2324import org .elasticsearch .common .transport .BoundTransportAddress ;
2425import org .elasticsearch .common .transport .TransportAddress ;
3435
3536public class TransportInfoTests extends ESTestCase {
3637
37- private TransportInfo createTransportInfo (InetAddress address , int port , boolean cnameInPublishAddress ) {
38+ private TransportInfo createTransportInfo (InetAddress address , int port , boolean cnameInPublishAddressProperty ) {
3839 BoundTransportAddress boundAddress = new BoundTransportAddress (
3940 new TransportAddress []{new TransportAddress (address , port )},
4041 new TransportAddress (address , port )
4142 );
4243 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 );
4449 }
4550
4651 public void testCorrectlyDisplayPublishedCname () throws Exception {
4752 InetAddress address = InetAddress .getByName ("localhost" );
4853 int port = 9200 ;
4954 assertPublishAddress (
50- createTransportInfo (address , port ,true ),
55+ createTransportInfo (address , port , false ),
5156 "localhost/" + NetworkAddress .format (address ) + ':' + port
5257 );
5358 }
5459
55- public void testHideCnameIfDeprecatedFormat () throws Exception {
60+ public void testDeprecatedWarningIfPropertySpecified () throws Exception {
5661 InetAddress address = InetAddress .getByName ("localhost" );
5762 int port = 9200 ;
5863 assertPublishAddress (
59- createTransportInfo (address , port ,false ),
60- NetworkAddress .format (address ) + ':' + port
64+ createTransportInfo (address , port , true ),
65+ "localhost/" + NetworkAddress .format (address ) + ':' + port
6166 );
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." ,
6569
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." );
6972 }
7073
7174 public void testCorrectDisplayPublishedIp () throws Exception {
7275 InetAddress address = InetAddress .getByName (NetworkAddress .format (InetAddress .getByName ("localhost" )));
7376 int port = 9200 ;
7477 assertPublishAddress (
75- createTransportInfo (address , port ,true ),
78+ createTransportInfo (address , port , false ),
7679 NetworkAddress .format (address ) + ':' + port
7780 );
7881 }
@@ -81,7 +84,7 @@ public void testCorrectDisplayPublishedIpv6() throws Exception {
8184 InetAddress address = InetAddress .getByName (NetworkAddress .format (InetAddress .getByName ("0:0:0:0:0:0:0:1" )));
8285 int port = 9200 ;
8386 assertPublishAddress (
84- createTransportInfo (address , port ,true ),
87+ createTransportInfo (address , port , false ),
8588 new TransportAddress (address , port ).toString ()
8689 );
8790 }
0 commit comments