drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-5126) Provide simplified, unified "cluster fixture" for tests
Date Sat, 07 Jan 2017 01:16:01 GMT

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

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_r95047142
  
    --- 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+)\\(" );
    +    for ( int i = n-1; i >= 0;  i-- ) {
    +      String plan = plans.get( i );
    +      Matcher m = p.matcher( plan );
    +      if ( ! m.find() ) { continue; }
    +      if ( m.group(1).equals( "Scan" ) ) {
    +        return plan; }
    +    }
    +    return null;
    +  }
    +
    +  public List<FieldDef> getColumns( String plan ) {
    +    Pattern p = Pattern.compile( "RecordType\\((.*)\\):" );
    +    Matcher m = p.matcher(plan);
    +    if ( ! m.find() ) { return null; }
    +    String frag = m.group(1);
    +    String parts[] = frag.split( ", " );
    +    List<FieldDef> fields = new ArrayList<>( );
    +    for ( String part : parts ) {
    +      String halves[] = part.split( " " );
    +      fields.add( new FieldDef( halves[1], halves[0] ) );
    +    }
    +    return fields;
    +  }
    +
    +  public Map<Integer,String> getOperators( ) {
    +    Map<Integer,String> ops = new HashMap<>();
    +    int n = getPlans( ).size();
    +    Pattern p = Pattern.compile( "\\d+-(\\d+)\\s+(\\w+)" );
    --- End diff --
    
    Verified all the regex with a sample plan from a query profile. Looks good!


> 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)

Mime
View raw message