[ 
https://issues.apache.org/jira/browse/DRILL-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15806394#comment-15806394
 ] 

ASF GitHub Bot commented on DRILL-5126:
---------------------------------------

Github user sohami commented on a diff in the pull request:

    https://github.com/apache/drill/pull/710#discussion_r95044899
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/test/ProfileParser.java ---
    @@ -0,0 +1,217 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + 
******************************************************************************/
    +package org.apache.drill.test;
    +
    +import java.io.File;
    +import java.io.FileReader;
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.regex.Matcher;
    +import java.util.regex.Pattern;
    +
    +import javax.json.Json;
    +import javax.json.JsonArray;
    +import javax.json.JsonNumber;
    +import javax.json.JsonObject;
    +import javax.json.JsonReader;
    +import javax.json.JsonValue;
    +
    +/**
    + * Parses a query profile and provides access to various bits of the 
profile
    + * for diagnostic purposes during tests.
    + */
    +
    +public class ProfileParser {
    +
    +  JsonObject profile;
    +  List<String> plans;
    +
    +  public ProfileParser( File file ) throws IOException {
    +    try (FileReader fileReader = new FileReader(file);
    +         JsonReader reader = Json.createReader(fileReader)) {
    +      profile = (JsonObject) reader.read();
    +    }
    +  }
    +
    +  public String getQuery( ) {
    +    return profile.get("query").toString();
    +  }
    +
    +  public String getPlan() {
    +    return profile.get("plan").toString();
    +  }
    +
    +  public List<String> getPlans() {
    +    if ( plans != null ) {
    +      return plans; }
    +    String plan = getPlan( );
    +    Pattern p = Pattern.compile( "(\\d\\d-\\d+[^\\\\]*)\\\\n", 
Pattern.MULTILINE );
    +    Matcher m = p.matcher(plan);
    +    plans = new ArrayList<>( );
    +    while ( m.find() ) {
    +      plans.add(m.group(1));
    +    }
    +    return plans;
    +  }
    +
    +  public String getScan( ) {
    +    int n = getPlans( ).size();
    +    Pattern p = Pattern.compile( "\\d+-\\d+\\s+(\\w+)\\(" );
    --- End diff --
    
    So we are just trying to find if this plan has Scan keyword after fragment 
number. Can't we simply use plan.contains("Scan") ? I guess the scan keyword 
will only be in plans which are actually Scan's.?
    
    Also there can be multiple Scans in the plan right ? In which case we 
should return list of plans here.


> Provide simplified, unified "cluster fixture" for tests
> -------------------------------------------------------
>
>                 Key: DRILL-5126
>                 URL: https://issues.apache.org/jira/browse/DRILL-5126
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Tools, Build & Test
>    Affects Versions: 1.9.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>
> Drill provides a robust selection of test frameworks that have evolved to 
> satisfy the needs of a variety of test cases. For newbies, however, the 
> result is a bewildering array of ways to do basically the same thing: set up 
> an embedded Drill cluster, run queries and check results.
> Further, some key test settings are distributed: some are in the pom.xml 
> file, some in config files stored as resources, some in hard-coded settings 
> in base test classes.
> Also, some test base classes helpfully set up a test cluster, but then 
> individual tests need a different config, so they immediately tear down the 
> default cluster and create a new one.
> This ticket proposes a new test framework, available for new tests, that 
> combines the best of the existing test frameworks into a single, easy-to-use 
> package.
> * Builder for the cluster
> * Accept config-time options
> * Accept run-time session and system options
> * Specify number of Drillbits
> * Simplified API for the most common options
> * AutoCloseable for use in try-with-resources statements
> * Integration with existing test builder classes
> And so on.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to