| // 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. |
| |
| suite("test_action") { |
| test { |
| sql "abcdefg" |
| // check exception message contains |
| exception "extraneous input 'abcdefg'" |
| } |
| |
| test { |
| sql """ |
| select * |
| from ( |
| select 1 id |
| union all |
| select 2 |
| ) a |
| order by id""" |
| |
| // multi check condition |
| |
| // check return 2 rows |
| rowNum 2 |
| // execute time must <= 5000 millisecond |
| time 5000 |
| // check result, must be 2 rows and 1 column, the first row is 1, second is 2 |
| result( |
| [[1], [2]] |
| ) |
| } |
| |
| test { |
| sql "a b c d e f g" |
| |
| // other check will not work because already declared a check callback |
| exception "aaaaaaaaa" |
| |
| // callback |
| check { result, exception, startTime, endTime -> |
| // assertXxx() will invoke junit5's Assertions.assertXxx() dynamically |
| assertTrue(exception != null) |
| } |
| } |
| |
| test { |
| sql """ |
| select 2 |
| union all |
| select 1 |
| union all |
| select null |
| union all |
| select 15 |
| union all |
| select 3 |
| """ |
| |
| check { result, ex, startTime, endTime -> |
| // same as order_sql(sqlStr) |
| result = sortRows(result) |
| |
| assertEquals(null, result[0][0]) |
| assertEquals(1, result[1][0]) |
| assertEquals(15, result[2][0]) |
| assertEquals(2, result[3][0]) |
| assertEquals(3, result[4][0]) |
| } |
| } |
| |
| // execute sql and order query result, then compare to iterator |
| def selectValues = [1, 2, 3, 4] |
| test { |
| order true |
| sql selectUnionAll(selectValues) |
| resultIterator(selectValues.iterator()) |
| } |
| |
| // compare to data/demo/test_action.csv |
| test { |
| order true |
| sql selectUnionAll(selectValues) |
| |
| // you can set to http://xxx or https://xxx |
| // and compare to http response body |
| resultFile "test_action.csv" |
| } |
| } |