@@ -83,12 +83,27 @@ public boolean isRunningFabricTLS() {
8383 private final boolean runningFabricTLS ;
8484 private static final HashMap <String , SampleOrg > sampleOrgs = new HashMap <>();
8585
86+ private static final String ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION
87+ = System .getenv ("ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION" ) == null ? "1.3.0" : System .getenv ("ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION" );
88+
8689 static {
8790 //set to fake out discovery during testing to local docker see Endpoint.java's createEndpoint method.
8891 System .setProperty ("org.hyperledger.fabric.sdk.test.endpoint_remap_discovery_host_name" , "localhost" ); // for testing only remaps all endpoint names.
8992 }
9093
94+ int [] fabricVersion = new int [3 ];
95+
9196 private TestConfig () {
97+
98+ final String [] fvs = ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION .split ("\\ ." );
99+ if (fvs .length != 3 ) {
100+ throw new AssertionError ("Expected environment variable 'ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION' to be three numbers sperated by dots (1.0.0) but got: " + ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION );
101+
102+ }
103+ fabricVersion [0 ] = Integer .parseInt (fvs [0 ].trim ());
104+ fabricVersion [1 ] = Integer .parseInt (fvs [1 ].trim ());
105+ fabricVersion [2 ] = Integer .parseInt (fvs [2 ].trim ());
106+
92107 File loadFile ;
93108 FileInputStream configProps ;
94109
@@ -169,11 +184,14 @@ private TestConfig() {
169184 sampleOrg .addOrdererLocation (nl [0 ], grpcTLSify (nl [1 ]));
170185 }
171186
172- String eventHubNames = sdkProperties .getProperty (INTEGRATIONTESTS_ORG + orgName + ".eventhub_locations" );
173- ps = eventHubNames .split ("[ \t ]*,[ \t ]*" );
174- for (String peer : ps ) {
175- String [] nl = peer .split ("[ \t ]*@[ \t ]*" );
176- sampleOrg .addEventHubLocation (nl [0 ], grpcTLSify (nl [1 ]));
187+ if (isFabricVersionBefore ("1.3" )) { // Eventhubs supported.
188+
189+ String eventHubNames = sdkProperties .getProperty (INTEGRATIONTESTS_ORG + orgName + ".eventhub_locations" );
190+ ps = eventHubNames .split ("[ \t ]*,[ \t ]*" );
191+ for (String peer : ps ) {
192+ String [] nl = peer .split ("[ \t ]*@[ \t ]*" );
193+ sampleOrg .addEventHubLocation (nl [0 ], grpcTLSify (nl [1 ]));
194+ }
177195 }
178196
179197 sampleOrg .setCALocation (httpTLSify (sdkProperties .getProperty ((INTEGRATIONTESTS_ORG + org .getKey () + ".ca_location" ))));
@@ -200,6 +218,42 @@ private TestConfig() {
200218
201219 }
202220
221+ public boolean isFabricVersionAtOrAfter (String version ) {
222+
223+ final int [] vers = parseVersion (version );
224+ for (int i = 0 ; i < 3 ; ++i ) {
225+ if (vers [i ] > fabricVersion [i ]) {
226+ return false ;
227+ }
228+ }
229+ return true ;
230+ }
231+
232+ public boolean isFabricVersionBefore (String version ) {
233+
234+ return !isFabricVersionAtOrAfter (version );
235+ }
236+
237+ private static int [] parseVersion (String version ) {
238+ if (null == version || version .isEmpty ()) {
239+ throw new AssertionError ("Version is bad :" + version );
240+ }
241+ String [] split = version .split ("[ \\ t]*\\ .[ \\ t]*" );
242+ if (split .length < 1 || split .length > 3 ) {
243+ throw new AssertionError ("Version is bad :" + version );
244+ }
245+ int [] ret = new int [3 ];
246+ int i = 0 ;
247+ for (; i < split .length ; ++i ) {
248+ ret [i ] = Integer .parseInt (split [i ]);
249+ }
250+ for (; i < 3 ; ++i ) {
251+ ret [i ] = 0 ;
252+ }
253+ return ret ;
254+
255+ }
256+
203257 private String grpcTLSify (String location ) {
204258 location = location .trim ();
205259 Exception e = Utils .checkGrpcUrl (location );
@@ -385,7 +439,7 @@ public File getTestNetworkConfigFileYAML() {
385439 String pname = "src/test/fixture/sdkintegration/network_configs/" ;
386440 File ret = new File (pname , fname );
387441
388- if (!"localhost" .equals (LOCALHOST )) {
442+ if (!"localhost" .equals (LOCALHOST ) || isFabricVersionAtOrAfter ( "1.3" ) ) {
389443 // change on the fly ...
390444 File temp = null ;
391445
@@ -406,6 +460,11 @@ public File getTestNetworkConfigFileYAML() {
406460 sourceText = sourceText .replaceAll ("grpcs://localhost" , "grpcs://" + LOCALHOST );
407461 sourceText = sourceText .replaceAll ("grpc://localhost" , "grpc://" + LOCALHOST );
408462
463+ if (isFabricVersionAtOrAfter ("1.3" )) {
464+ //eventUrl: grpc://localhost:8053
465+ sourceText = sourceText .replaceAll ("(?m)^[ \\ t]*eventUrl:" , "# eventUrl:" );
466+ }
467+
409468 Files .write (Paths .get (temp .getAbsolutePath ()), sourceText .getBytes (StandardCharsets .UTF_8 ),
410469 StandardOpenOption .CREATE_NEW , StandardOpenOption .TRUNCATE_EXISTING , StandardOpenOption .WRITE );
411470
0 commit comments