Search in sources :

Example 11 with BulletError

use of com.yahoo.bullet.common.BulletError in project bullet-core by yahoo.

the class GroupAllTest method testAttributeOperationBadFormat.

@Test
public void testAttributeOperationBadFormat() {
    Aggregation aggregation = makeAggregation(singletonMap(GroupOperation.OPERATIONS, asList("foo")));
    GroupAll groupAll = new GroupAll(aggregation);
    Optional<List<BulletError>> optionalErrors = groupAll.initialize();
    Assert.assertTrue(optionalErrors.isPresent());
    List<BulletError> errors = optionalErrors.get();
    Assert.assertEquals(errors.size(), 1);
    Assert.assertEquals(errors.get(0), GroupOperation.REQUIRES_FIELD_OR_OPERATION_ERROR);
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) List(java.util.List) Arrays.asList(java.util.Arrays.asList) BulletError(com.yahoo.bullet.common.BulletError) Test(org.testng.annotations.Test)

Example 12 with BulletError

use of com.yahoo.bullet.common.BulletError in project bullet-storm by yahoo.

the class JoinBoltTest method testUnknownAggregation.

@Test
public void testUnknownAggregation() {
    // Lowercase "top" is not valid and will not be parsed since there is no enum for it
    // In this case aggregation type should be set to null and an error should be emitted
    Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{\"aggregation\": {\"type\": \"garbage\"}}", EMPTY);
    bolt.execute(query);
    Assert.assertEquals(collector.getEmittedCount(), 1);
    BulletError expectedError = Aggregation.TYPE_NOT_SUPPORTED_ERROR;
    Meta expectedMetadata = Meta.of(expectedError);
    List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
    List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
    Assert.assertTrue(isSameResult(actual, expected));
}
Also used : Meta(com.yahoo.bullet.result.Meta) JsonObject(com.google.gson.JsonObject) BulletError(com.yahoo.bullet.common.BulletError) Tuple(org.apache.storm.tuple.Tuple) Test(org.testng.annotations.Test) GroupByTest(com.yahoo.bullet.aggregations.GroupByTest) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 13 with BulletError

use of com.yahoo.bullet.common.BulletError in project bullet-storm by yahoo.

the class JoinBoltTest method testErrorEmittedProperly.

@Test
public void testErrorEmittedProperly() {
    Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "garbage", EMPTY);
    bolt.execute(query);
    Assert.assertEquals(collector.getEmittedCount(), 1);
    String error = ParsingError.GENERIC_JSON_ERROR + ":\ngarbage\n" + "IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $";
    BulletError expectedError = ParsingError.makeError(error, ParsingError.GENERIC_JSON_RESOLUTION);
    Meta expectedMetadata = Meta.of(expectedError);
    List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
    List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
    Assert.assertTrue(isSameResult(actual, expected));
}
Also used : Meta(com.yahoo.bullet.result.Meta) JsonObject(com.google.gson.JsonObject) BulletError(com.yahoo.bullet.common.BulletError) Tuple(org.apache.storm.tuple.Tuple) Test(org.testng.annotations.Test) GroupByTest(com.yahoo.bullet.aggregations.GroupByTest) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 14 with BulletError

use of com.yahoo.bullet.common.BulletError in project bullet-storm by yahoo.

the class JoinBoltTest method testUnhandledExceptionErrorEmitted.

@Test
public void testUnhandledExceptionErrorEmitted() {
    // An empty query should throw an null-pointer exception which should be caught in JoinBolt
    // and an error should be emitted
    Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "", EMPTY);
    bolt.execute(query);
    sendRawRecordTuplesTo(bolt, "42");
    Assert.assertEquals(collector.getEmittedCount(), 1);
    String error = ParsingError.GENERIC_JSON_ERROR + ":\n\nNullPointerException: ";
    BulletError expectedError = ParsingError.makeError(error, ParsingError.GENERIC_JSON_RESOLUTION);
    Meta expectedMetadata = Meta.of(expectedError);
    List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
    List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
    Assert.assertTrue(isSameResult(actual, expected));
}
Also used : Meta(com.yahoo.bullet.result.Meta) JsonObject(com.google.gson.JsonObject) BulletError(com.yahoo.bullet.common.BulletError) Tuple(org.apache.storm.tuple.Tuple) Test(org.testng.annotations.Test) GroupByTest(com.yahoo.bullet.aggregations.GroupByTest) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Aggregations

BulletError (com.yahoo.bullet.common.BulletError)14 Test (org.testng.annotations.Test)14 List (java.util.List)9 Arrays.asList (java.util.Arrays.asList)8 Aggregation (com.yahoo.bullet.parsing.Aggregation)7 BulletConfig (com.yahoo.bullet.common.BulletConfig)6 Meta (com.yahoo.bullet.result.Meta)5 JsonObject (com.google.gson.JsonObject)4 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)4 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)4 GroupByTest (com.yahoo.bullet.aggregations.GroupByTest)4 TopKTest (com.yahoo.bullet.aggregations.TopKTest)4 Tuple (org.apache.storm.tuple.Tuple)4 ArrayList (java.util.ArrayList)2 AggregationUtils.makeGroupOperation (com.yahoo.bullet.parsing.AggregationUtils.makeGroupOperation)1 Query (com.yahoo.bullet.parsing.Query)1 QueryUtils.makeAggregationQuery (com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery)1 QueryUtils.makeProjectionFilterQuery (com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery)1 QueryUtils.makeRawFullQuery (com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery)1 Clip (com.yahoo.bullet.result.Clip)1