2525
2626class  TestBuildInfoParser  {
2727
28-     private  static  final  String  NAME_KEY  = "name " ;
29-     private  static  final  String  LOCATIONS_KEY  = "locations " ;
28+     private  static  final  String  PLUGIN_TEST_BUILD_INFO_RESOURCES  = "META-INF/plugin-test-build-info.json " ;
29+     private  static  final  String  SERVER_TEST_BUILD_INFO_RESOURCE  = "META-INF/server-test-build-info.json " ;
3030
3131    private  static  final  ObjectParser <Builder , Void > PARSER  = new  ObjectParser <>("test_build_info" , Builder ::new );
3232    private  static  final  ObjectParser <Location , Void > LOCATION_PARSER  = new  ObjectParser <>("location" , Location ::new );
@@ -72,12 +72,10 @@ static TestBuildInfo fromXContent(final XContentParser parser) throws IOExceptio
7272        return  PARSER .parse (parser , null ).build ();
7373    }
7474
75-     // TODO: possibly move it to whoever is calling/using this 
76-     // TODO: server test build info 
7775    static  List <TestBuildInfo > parseAllPluginTestBuildInfo () throws  IOException  {
7876        var  xContent  = XContentFactory .xContent (XContentType .JSON );
7977        List <TestBuildInfo > pluginsTestBuildInfos  = new  ArrayList <>();
80-         var  resources  = TestBuildInfoParser .class .getClassLoader ().getResources ("/META-INF/es-plugins/" );
78+         var  resources  = TestBuildInfoParser .class .getClassLoader ().getResources (PLUGIN_TEST_BUILD_INFO_RESOURCES );
8179        URL  resource ;
8280        while  ((resource  = resources .nextElement ()) != null ) {
8381            try  (var  stream  = getStream (resource ); var  parser  = xContent .createParser (XContentParserConfiguration .EMPTY , stream )) {
@@ -87,6 +85,18 @@ static List<TestBuildInfo> parseAllPluginTestBuildInfo() throws IOException {
8785        return  pluginsTestBuildInfos ;
8886    }
8987
88+     static  TestBuildInfo  parseServerTestBuildInfo () throws  IOException  {
89+         var  xContent  = XContentFactory .xContent (XContentType .JSON );
90+         var  resource  = TestBuildInfoParser .class .getClassLoader ().getResource (SERVER_TEST_BUILD_INFO_RESOURCE );
91+         // No test-build-info for server: this might be a non-gradle build. Proceed without TestBuildInfo 
92+         if  (resource  == null ) {
93+             return  null ;
94+         }
95+         try  (var  stream  = getStream (resource ); var  parser  = xContent .createParser (XContentParserConfiguration .EMPTY , stream )) {
96+             return  fromXContent (parser );
97+         }
98+     }
99+ 
90100    @ SuppressForbidden (reason  = "URLs from class loader" )
91101    private  static  InputStream  getStream (URL  resource ) throws  IOException  {
92102        return  resource .openStream ();
0 commit comments