> getRequirementsSets();
26 | }
27 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/hadoop/hdfs/HdfsDataSourceWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.hadoop.hdfs;
16 |
17 | import io.trino.tempto.fulfillment.table.hive.HiveDataSource;
18 |
19 | public interface HdfsDataSourceWriter
20 | {
21 | void ensureDataOnHdfs(String dataPath, HiveDataSource dataSource);
22 | }
23 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/testmarkers/WithName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.testmarkers;
16 |
17 | import org.testng.ITest;
18 |
19 | /**
20 | * Marker interface for test classes which explicitly define dest name.
21 | */
22 | public interface WithName
23 | extends ITest
24 | {
25 | @Override
26 | String getTestName();
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/Requirement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto;
16 |
17 | /**
18 | * Specifies a test requirement.
19 | *
20 | * Requirement instances must provide proper implementation of hashCode and equals methods.
21 | * This is required so we can merge repeating requirements from different tests.
22 | */
23 | public interface Requirement
24 | {
25 | }
26 |
--------------------------------------------------------------------------------
/tempto-ldap/src/main/java/io/trino/tempto/internal/fulfillment/ldap/LdapObjectEntryManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.ldap;
16 |
17 | import io.trino.tempto.fulfillment.ldap.LdapObjectDefinition;
18 |
19 | import java.util.List;
20 |
21 | interface LdapObjectEntryManager
22 | {
23 | void addLdapDefinitions(List ldapObjectDefinitions);
24 | }
25 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/java/io/trino/tempto/examples/AnotherExclusionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.examples;
15 |
16 | import org.testng.annotations.Test;
17 |
18 | import static org.testng.FileAssert.fail;
19 |
20 | public class AnotherExclusionTest
21 | {
22 | @Test
23 | public void badTest()
24 | {
25 | fail("This should have been excluded by class name");
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/testmarkers/WithTestGroups.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.testmarkers;
16 |
17 | import org.testng.ITest;
18 |
19 | import java.util.Set;
20 |
21 | /**
22 | * Marker interface for test classes which explicitly define list of groups test belong to.
23 | */
24 | public interface WithTestGroups
25 | extends ITest
26 | {
27 | Set getTestGroups();
28 | }
29 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/tpch/show_stats_for_orders.sql:
--------------------------------------------------------------------------------
1 | -- database: trino; groups: stats, tpcds; tables: orders
2 | -- delimiter: |; ignoreOrder: true; types: VARCHAR|DOUBLE|DOUBLE|DOUBLE|DOUBLE|VARCHAR|VARCHAR
3 | --! name: show stats for orders
4 | SHOW STATS FOR orders
5 | --!
6 | o_orderkey|null|1500000.00000000000|0.00000000000|null|1|6000000|
7 | o_custkey|null|99996.00000000000|0.00000000000|null|1|149999|
8 | o_orderstatus|499950.00000000000|3.00000000000|0.00000000000|null|null|null|
9 | o_totalprice|null|1108856.00000000000|0.00000000000|null|17.15|11105.7|
10 | o_orderdate|null|2406.00000000000|0.00000000000|null|1992-01-01|1998-08-02|
11 | o_orderpriority|7500000.00000000000|5.00000000000|0.00000000000|null|null|null|
12 | o_clerk|7500000.00000000000|1000.00000000000|0.00000000000|null|null|null|
13 | o_shippriority|null|1.00000000000|0.00000000000|null|0|0|
14 | o_comment|39499950.00000000000|1482071.00000000000|0.00000000000|null|null|null|
15 | null|null|null|null|1500000.00000000000|null|null|
16 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/table/jdbc/Loader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.table.jdbc;
16 |
17 | import java.sql.SQLException;
18 | import java.util.List;
19 |
20 | interface Loader
21 | extends AutoCloseable
22 | {
23 | void load(List> batch)
24 | throws SQLException;
25 |
26 | void close()
27 | throws SQLException;
28 | }
29 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/context/ContextRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.context;
16 |
17 | /**
18 | * Interface for invocation of tests in dsl defined context.
19 | */
20 | public interface ContextRunnable
21 | {
22 | /**
23 | * Method invoked in given context T
24 | *
25 | * @param context context generated by {@link ContextProvider#setup}
26 | */
27 | void run(T context);
28 | }
29 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | wrapperVersion=3.3.2
18 | distributionType=only-script
19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
20 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed under the Apache License, Version 2.0 (the "License");
3 | # you may not use this file except in compliance with the License.
4 | # You may obtain a copy of the License at
5 | #
6 | # http://www.apache.org/licenses/LICENSE-2.0
7 | #
8 | # Unless required by applicable law or agreed to in writing, software
9 | # distributed under the License is distributed on an "AS IS" BASIS,
10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | # See the License for the specific language governing permissions and
12 | # limitations under the License.
13 | #
14 | log4j.rootLogger=INFO, TEST_FRAMEWORK_LOGGING_APPENDER, CONSOLE
15 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
16 | log4j.appender.CONSOLE.Target=System.out
17 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
18 | log4j.appender.CONSOLE.layout.conversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] [%X{test_id}] %m%n
19 | log4j.appender.CONSOLE.Threshold=INFO
20 | log4j.category.io.trino.tempto=DEBUG
21 |
22 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/ship_mode.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 20,
3 | "columns": {
4 | "sm_ship_mode_sk": {
5 | "distinctValuesCount": 20,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 20
9 | },
10 | "sm_ship_mode_id": {
11 | "distinctValuesCount": 20,
12 | "nullsCount": 0,
13 | "min": "AAAAAAAAABAAAAAA",
14 | "max": "AAAAAAAAPAAAAAAA"
15 | },
16 | "sm_type": {
17 | "distinctValuesCount": 6,
18 | "nullsCount": 0,
19 | "min": "EXPRESS",
20 | "max": "TWO DAY"
21 | },
22 | "sm_code": {
23 | "distinctValuesCount": 4,
24 | "nullsCount": 0,
25 | "min": "AIR",
26 | "max": "SURFACE"
27 | },
28 | "sm_carrier": {
29 | "distinctValuesCount": 20,
30 | "nullsCount": 0,
31 | "min": "AIRBORNE",
32 | "max": "ZOUROS"
33 | },
34 | "sm_contract": {
35 | "distinctValuesCount": 20,
36 | "nullsCount": 0,
37 | "min": "2mM8l",
38 | "max": "yVfotg7Tio3MVhBg6Bkn"
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/Requires.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto;
16 |
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | @Retention(RetentionPolicy.RUNTIME)
23 | @Target({ElementType.METHOD, ElementType.TYPE})
24 | public @interface Requires
25 | {
26 | Class extends RequirementsProvider>[] value();
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/initialization/SuiteModuleProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.initialization;
15 |
16 | import com.google.inject.Module;
17 | import io.trino.tempto.configuration.Configuration;
18 |
19 | /**
20 | * Classes implementing this interface provide {@link Module}s
21 | * at suite level.
22 | */
23 | @FunctionalInterface
24 | public interface SuiteModuleProvider
25 | {
26 | Module getModule(Configuration configuration);
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/hadoop/hdfs/HttpRequestsExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.hadoop.hdfs;
16 |
17 | import org.apache.http.client.methods.CloseableHttpResponse;
18 | import org.apache.http.client.methods.HttpUriRequest;
19 |
20 | import java.io.IOException;
21 |
22 | public interface HttpRequestsExecutor
23 | {
24 | CloseableHttpResponse execute(final HttpUriRequest request)
25 | throws IOException;
26 | }
27 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/internal/DummyTestRequirement.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal
16 |
17 | import io.trino.tempto.Requirement
18 |
19 | final class DummyTestRequirement
20 | implements Requirement
21 | {
22 | private final String name;
23 |
24 | DummyTestRequirement(String name)
25 | {
26 | this.name = name;
27 | }
28 |
29 | String toString()
30 | {
31 | return name;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/java/io/trino/tempto/another/examples/MultiplePackagesTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.another.examples;
15 |
16 | import org.testng.annotations.Test;
17 |
18 | import java.util.concurrent.atomic.AtomicBoolean;
19 |
20 | public class MultiplePackagesTest
21 | {
22 | public static AtomicBoolean called = new AtomicBoolean();
23 |
24 | @Test
25 | public void testInDifferentPackage()
26 | {
27 | called.set(true);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/java/io/trino/tempto/examples/ExclusionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.examples;
15 |
16 | import org.testng.annotations.Test;
17 |
18 | import static org.testng.FileAssert.fail;
19 |
20 | public class ExclusionTest
21 | {
22 | @Test
23 | public void passingTest()
24 | {
25 | }
26 |
27 | @Test
28 | public void failingTest()
29 | {
30 | fail("Method failingTest() should have been excluded from the execution");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/resources/TestResourcesState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.fulfillment.resources;
15 |
16 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContext;
17 |
18 | public class TestResourcesState
19 | extends ResourcesState
20 | {
21 | public static T closeAfterTest(T resource)
22 | {
23 | return testContext().getDependency(TestResourcesState.class).register(resource);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/process/CommandExecutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.process;
16 |
17 | public class CommandExecutionException
18 | extends RuntimeException
19 | {
20 | private final int exitStatus;
21 |
22 | public CommandExecutionException(String message, int exitStatus)
23 | {
24 | super(message);
25 | this.exitStatus = exitStatus;
26 | }
27 |
28 | public int getExitStatus()
29 | {
30 | return exitStatus;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/resources/SuiteResourcesState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.fulfillment.resources;
15 |
16 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContext;
17 |
18 | public class SuiteResourcesState
19 | extends ResourcesState
20 | {
21 | public static T closeAfterSuite(T resource)
22 | {
23 | return testContext().getDependency(SuiteResourcesState.class).register(resource);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/threads/IndexedRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.threads;
15 |
16 | /**
17 | * An interface of a runnable that has an index and can throw checked exceptions.
18 | */
19 | @FunctionalInterface
20 | public interface IndexedRunnable
21 | {
22 | /**
23 | * @param threadIndex an index of thread that executes this {@link IndexedRunnable}.
24 | * @throws Exception if something goes wrong
25 | */
26 | void run(int threadIndex)
27 | throws Exception;
28 | }
29 |
--------------------------------------------------------------------------------
/tempto-kafka/src/main/java/io/trino/tempto/fulfillment/table/kafka/KafkaTableInstance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.fulfillment.table.kafka;
15 |
16 | import io.trino.tempto.fulfillment.table.TableInstance;
17 | import io.trino.tempto.internal.fulfillment.table.TableName;
18 |
19 | public class KafkaTableInstance
20 | extends TableInstance
21 | {
22 | protected KafkaTableInstance(TableName name, KafkaTableDefinition tableDefinition)
23 | {
24 | super(name, tableDefinition);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/ProductTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto;
16 |
17 | import io.trino.tempto.internal.initialization.RequirementsExpanderInterceptor;
18 | import io.trino.tempto.internal.initialization.TestInitializationListener;
19 | import io.trino.tempto.internal.listeners.ProgressLoggingListener;
20 | import org.testng.annotations.Listeners;
21 |
22 | @Listeners({RequirementsExpanderInterceptor.class, TestInitializationListener.class, ProgressLoggingListener.class})
23 | public class ProductTest
24 | {
25 | }
26 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/convention/ConventionBasedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.convention;
16 |
17 | import io.trino.tempto.ProductTest;
18 | import io.trino.tempto.RequirementsProvider;
19 | import io.trino.tempto.testmarkers.WithName;
20 | import io.trino.tempto.testmarkers.WithTestGroups;
21 |
22 | public abstract class ConventionBasedTest
23 | extends ProductTest
24 | implements RequirementsProvider, WithName, WithTestGroups
25 | {
26 | public abstract void test();
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/initialization/TestMethodModuleProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.initialization;
15 |
16 | import com.google.inject.Module;
17 | import io.trino.tempto.configuration.Configuration;
18 | import org.testng.ITestResult;
19 |
20 | /**
21 | * Classes implementing this interface provide {@link Module}s
22 | * at test method level.
23 | */
24 | @FunctionalInterface
25 | public interface TestMethodModuleProvider
26 | {
27 | Module getModule(Configuration configuration, ITestResult testResult);
28 | }
29 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/assertions/ColumnValuesAssert.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.assertions;
16 |
17 | import org.assertj.core.api.AbstractListAssert;
18 | import org.assertj.core.api.ObjectAssert;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * Interface used for passing lambda expression assertions into
24 | * {@link QueryAssert#column}
25 | */
26 | public interface ColumnValuesAssert
27 | {
28 | void assertColumnValues(AbstractListAssert, ? extends List extends T>, T, ObjectAssert> columnAssert);
29 | }
30 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/context/State.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.context;
16 |
17 | import java.util.Optional;
18 |
19 | /**
20 | * Marker interface of state objects produced by fulfillers.
21 | */
22 | public interface State
23 | {
24 | /**
25 | * Return name for state. If non-empty optional is
26 | * returned State will be bound in TestContext with name annotation.
27 | *
28 | * @return Name
29 | */
30 | default Optional getName()
31 | {
32 | return Optional.empty();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/command/SuiteCommandFulfiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.fulfillment.command;
15 |
16 | import io.trino.tempto.fulfillment.RequirementFulfiller;
17 | import io.trino.tempto.fulfillment.command.SuiteCommandRequirement;
18 |
19 | @RequirementFulfiller.SuiteLevelFulfiller
20 | public class SuiteCommandFulfiller
21 | extends CommandFulfiller
22 | {
23 | public SuiteCommandFulfiller()
24 | {
25 | super(SuiteCommandRequirement.class);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/part_supplier.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 800000,
3 | "columns": {
4 | "ps_partkey": {
5 | "distinctValuesCount": 200000,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 200000
9 | },
10 | "ps_suppkey": {
11 | "distinctValuesCount": 10000,
12 | "nullsCount": 0,
13 | "min": 1,
14 | "max": 10000
15 | },
16 | "ps_availqty": {
17 | "distinctValuesCount": 9999,
18 | "nullsCount": 0,
19 | "min": 1,
20 | "max": 9999
21 | },
22 | "ps_supplycost": {
23 | "distinctValuesCount": 99865,
24 | "nullsCount": 0,
25 | "min": 1.0,
26 | "max": 1000.0
27 | },
28 | "ps_comment": {
29 | "distinctValuesCount": 799124,
30 | "nullsCount": 0,
31 | "min": " Tiresias according to the quiet courts sleep against the ironic, final requests. carefully unusual requests affix fluffily quickly ironic packages. regular ",
32 | "max": "zzle. unusual decoys detect slyly blithely express frays. furiously ironic packages about the bold accounts are close requests. slowly silent reque"
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/table/cassandra/CassandraTableInstance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.fulfillment.table.cassandra;
15 |
16 | import io.trino.tempto.fulfillment.table.TableInstance;
17 | import io.trino.tempto.internal.fulfillment.table.TableName;
18 |
19 | public class CassandraTableInstance
20 | extends TableInstance
21 | {
22 | protected CassandraTableInstance(TableName name, CassandraTableDefinition tableDefinition)
23 | {
24 | super(name, tableDefinition);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tempto-core/src/test/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed under the Apache License, Version 2.0 (the "License");
3 | # you may not use this file except in compliance with the License.
4 | # You may obtain a copy of the License at
5 | #
6 | # http://www.apache.org/licenses/LICENSE-2.0
7 | #
8 | # Unless required by applicable law or agreed to in writing, software
9 | # distributed under the License is distributed on an "AS IS" BASIS,
10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | # See the License for the specific language governing permissions and
12 | # limitations under the License.
13 | #
14 | # Set root logger to INFO and add a custom appender.
15 | log4j.rootLogger=TRACE, TEST_FRAMEWORK_LOGGING_APPENDER, CONSOLE
16 |
17 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
18 | log4j.appender.CONSOLE.Target=System.out
19 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
20 | log4j.appender.CONSOLE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L [%X{test_id}] - %m%n
21 | log4j.category.org.apache.http=INFO
22 | log4j.category.com.jayway.jsonpath=WARN
23 | log4j.category.org.apache.thrift=WARN
24 | log4j.category.org.apache.hive=WARN
25 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/command/TestCommandFulfiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.command;
16 |
17 | import io.trino.tempto.fulfillment.RequirementFulfiller;
18 | import io.trino.tempto.fulfillment.command.TestCommandRequirement;
19 |
20 | import com.google.inject.Inject;
21 |
22 | @RequirementFulfiller.TestLevelFulfiller
23 | public class TestCommandFulfiller
24 | extends CommandFulfiller
25 | {
26 | @Inject
27 | public TestCommandFulfiller()
28 | {
29 | super(TestCommandRequirement.class);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/table/hive/HiveTableInstance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.fulfillment.table.hive;
15 |
16 | import io.trino.tempto.fulfillment.table.TableInstance;
17 | import io.trino.tempto.fulfillment.table.hive.HiveTableDefinition;
18 | import io.trino.tempto.internal.fulfillment.table.TableName;
19 |
20 | public class HiveTableInstance
21 | extends TableInstance
22 | {
23 | public HiveTableInstance(TableName tableName, HiveTableDefinition tableDefinition)
24 | {
25 | super(tableName, tableDefinition);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/sql/view/View.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.sql.view;
16 |
17 | import static com.google.common.base.MoreObjects.toStringHelper;
18 |
19 | public class View
20 | {
21 | private final String name;
22 |
23 | public View(String name)
24 | {
25 | this.name = name;
26 | }
27 |
28 | public String getName()
29 | {
30 | return name;
31 | }
32 |
33 | @Override
34 | public String toString()
35 | {
36 | return toStringHelper(this)
37 | .add("name", name)
38 | .toString();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/context/ContextProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.context;
16 |
17 | /**
18 | * Provider class used for generation and cleanup of dsl defined contexts.
19 | *
20 | * @param context class
21 | */
22 | public interface ContextProvider
23 | {
24 | /**
25 | * Method generating new context.
26 | *
27 | * @return generated context
28 | */
29 | T setup();
30 |
31 | /**
32 | * Method invoked after finishing {@link ContextRunnable#run}
33 | *
34 | * @param context dls defined context
35 | */
36 | void cleanup(T context);
37 | }
38 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/MutableTablesState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table;
16 |
17 | import java.util.List;
18 |
19 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContext;
20 |
21 | public class MutableTablesState
22 | extends TablesState
23 | {
24 | public static MutableTablesState mutableTablesState()
25 | {
26 | return testContext().getDependency(MutableTablesState.class);
27 | }
28 |
29 | public MutableTablesState(List tables)
30 | {
31 | super(tables, "mutable table");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/table/jdbc/JdbcTableInstance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.fulfillment.table.jdbc;
15 |
16 | import io.trino.tempto.fulfillment.table.TableInstance;
17 | import io.trino.tempto.fulfillment.table.jdbc.RelationalTableDefinition;
18 | import io.trino.tempto.internal.fulfillment.table.TableName;
19 |
20 | public class JdbcTableInstance
21 | extends TableInstance
22 | {
23 | public JdbcTableInstance(TableName tableName, RelationalTableDefinition tableDefinition)
24 | {
25 | super(tableName, tableDefinition);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/java/io/trino/tempto/examples/TemptoExamplesPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.examples;
15 |
16 | import com.google.common.collect.ImmutableList;
17 | import io.trino.tempto.TemptoPlugin;
18 | import io.trino.tempto.fulfillment.table.TableManager;
19 | import io.trino.tempto.fulfillment.table.kafka.KafkaTableManager;
20 |
21 | import java.util.List;
22 |
23 | public class TemptoExamplesPlugin
24 | implements TemptoPlugin
25 | {
26 | @Override
27 | public List> getTableManagers()
28 | {
29 | return ImmutableList.of(KafkaTableManager.class);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/ImmutableTablesState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table;
16 |
17 | import java.util.List;
18 |
19 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContext;
20 |
21 | public class ImmutableTablesState
22 | extends TablesState
23 | {
24 | public static ImmutableTablesState immutableTablesState()
25 | {
26 | return testContext().getDependency(ImmutableTablesState.class);
27 | }
28 |
29 | public ImmutableTablesState(List tables)
30 | {
31 | super(tables, "immutable table");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/AfterMethodWithContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto;
16 |
17 | import org.testng.annotations.AfterMethod;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Annotates methods that should be invoked after each test method (like {@link AfterMethod}),
26 | * but before Tempto context has been destroyed.
27 | *
28 | * @see AfterMethod
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target({ElementType.METHOD})
32 | public @interface AfterMethodWithContext {}
33 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/BeforeMethodWithContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto;
16 |
17 | import org.testng.annotations.BeforeMethod;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Annotates methods that should be invoked before each test method (like {@link BeforeMethod}),
26 | * but after Tempto context has been injected.
27 | *
28 | * @see BeforeMethod
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target({ElementType.METHOD})
32 | public @interface BeforeMethodWithContext {}
33 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/jdbc/RelationalDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table.jdbc;
16 |
17 | import java.sql.PreparedStatement;
18 | import java.util.Iterator;
19 | import java.util.List;
20 |
21 | public interface RelationalDataSource
22 | {
23 | /**
24 | * Returns iterator over rows to be inserted to table.
25 | * Object types must match column types in table.
26 | * Object will be inserted using {@link PreparedStatement#setObject(int, Object)} method.
27 | *
28 | * @return iterator over rows to be inserted to table
29 | */
30 | Iterator> getDataRows();
31 | }
32 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/context/ContextDsl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.context;
16 |
17 | /**
18 | * Helper class used for execution of instances of {@link ContextRunnable} with context generated
19 | * by {@link ContextProvider#setup()}
20 | */
21 | public final class ContextDsl
22 | {
23 | public static void executeWith(ContextProvider provider, ContextRunnable runnable)
24 | {
25 | T context = provider.setup();
26 | try {
27 | runnable.run(context);
28 | }
29 | finally {
30 | provider.cleanup(context);
31 | }
32 | }
33 |
34 | private ContextDsl()
35 | {
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tempto-kafka/src/main/java/io/trino/tempto/fulfillment/table/kafka/ListKafkaDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table.kafka;
16 |
17 | import com.google.common.collect.ImmutableList;
18 |
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | public class ListKafkaDataSource
23 | implements KafkaDataSource
24 | {
25 | private final List messages;
26 |
27 | public ListKafkaDataSource(List messages)
28 | {
29 | this.messages = ImmutableList.copyOf(messages);
30 | }
31 |
32 | @Override
33 | public Iterator getMessages()
34 | {
35 | return messages.iterator();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/threads/ParallelExecutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.threads;
15 |
16 | import com.google.common.base.Joiner;
17 |
18 | import java.util.List;
19 |
20 | public class ParallelExecutionException
21 | extends RuntimeException
22 | {
23 | private final List throwables;
24 |
25 | public ParallelExecutionException(List throwables)
26 | {
27 | super("Throwables when running parallel runnables:\n" + Joiner.on("-------------------\n").join(throwables));
28 | this.throwables = throwables;
29 | }
30 |
31 | public List getThrowables()
32 | {
33 | return throwables;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/process/TestClassWithMain.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.process
15 |
16 | import static org.assertj.core.api.Assertions.assertThat
17 |
18 | class TestClassWithMain
19 | {
20 | public static final String EXPECTED_ARGUMENT = "foo";
21 | public static final String EXPECTED_LINE = "hello";
22 | public static final String PRODUCED_LINE = "world";
23 |
24 | static void main(String[] args)
25 | {
26 | assertThat(args.length).isEqualTo(1)
27 | assertThat(args[0]).isEqualTo(EXPECTED_ARGUMENT)
28 |
29 | Scanner scanner = new Scanner(System.in)
30 | assertThat(scanner.nextLine()).isEqualTo(EXPECTED_LINE)
31 | System.out.println(PRODUCED_LINE)
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/supplier.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 10000,
3 | "columns": {
4 | "s_suppkey": {
5 | "distinctValuesCount": 10000,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 10000
9 | },
10 | "s_name": {
11 | "distinctValuesCount": 10000,
12 | "nullsCount": 0,
13 | "min": "Supplier#000000001",
14 | "max": "Supplier#000010000"
15 | },
16 | "s_address": {
17 | "distinctValuesCount": 10000,
18 | "nullsCount": 0,
19 | "min": " 9aW1wwnBJJPnCx,nox0MA48Y0zpI1IeVfYZ",
20 | "max": "zzfDhdtZcvmVzA8rNFU,Yctj1zBN"
21 | },
22 | "s_nationkey": {
23 | "distinctValuesCount": 25,
24 | "nullsCount": 0,
25 | "min": 0,
26 | "max": 24
27 | },
28 | "s_phone": {
29 | "distinctValuesCount": 10000,
30 | "nullsCount": 0,
31 | "min": "10-102-116-6785",
32 | "max": "34-998-900-4911"
33 | },
34 | "s_acctbal": {
35 | "distinctValuesCount": 9955,
36 | "nullsCount": 0,
37 | "min": -998.22,
38 | "max": 9999.72
39 | },
40 | "s_comment": {
41 | "distinctValuesCount": 10000,
42 | "nullsCount": 0,
43 | "min": " about the blithely express foxes. bli",
44 | "max": "zzle furiously. bold accounts haggle furiously ironic excuses. fur"
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: ci
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 | strategy:
13 | fail-fast: false
14 | matrix:
15 | java: ['21', '22']
16 | steps:
17 | - uses: actions/checkout@v2
18 | - uses: actions/setup-java@v2
19 | with:
20 | distribution: 'temurin'
21 | java-version: ${{ matrix.java }}
22 | - name: compile and install
23 | run: ./mvnw install -B -V -DskipTests -Dair.check.skip-all
24 | - name: test
25 | run: ./mvnw install -B
26 | - name: tempto test (exclusion)
27 | run: ./tempto-examples/bin/run_on_docker.sh --thread-count 2 -x failing -e io.trino.tempto.examples.ExclusionTest.failingTest,io.trino.tempto.examples.AnotherExclusionTest
28 | - name: tempto test (config-read-only)
29 | run: CONFIG_FILE=tempto-configuration-read-only.yaml ./tempto-examples/bin/run_on_docker.sh --thread-count 2 -g in_memory
30 | - name: tempto test (config-no-db)
31 | run: CONFIG_FILE=tempto-configuration-no-db.yaml ./tempto-examples/bin/run_on_docker.sh --thread-count 2 -g ssh
32 | - name: tempto test (config-invalid-ssh-and-psql)
33 | run: CONFIG_FILE=tempto-configuration-invalid-ssh-and-psql.yaml ./tempto-examples/bin/run_on_docker.sh --thread-count 2 -g in_memory
34 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/table/TableNameGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.table;
16 |
17 | import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
18 |
19 | public class TableNameGenerator
20 | {
21 | private static final String MUTABLE_TABLE_NAME_PREFIX = "tempto_mut_";
22 |
23 | public String generateMutableTableNameInDatabase(String baseTableName)
24 | {
25 | String tableName = MUTABLE_TABLE_NAME_PREFIX + baseTableName + "_" + randomAlphanumeric(8);
26 | return tableName.toLowerCase();
27 | }
28 |
29 | public boolean isMutableTableName(String tableNameInDatabase)
30 | {
31 | return tableNameInDatabase.startsWith(MUTABLE_TABLE_NAME_PREFIX);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/fulfillment/table/TableHandleTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.fulfillment.table
15 |
16 | import spock.lang.Specification
17 | import spock.lang.Unroll
18 |
19 | import static TableHandle.tableHandle
20 |
21 | class TableHandleTest
22 | extends Specification
23 | {
24 | @Unroll
25 | def 'parse #tableHandleStr to #expectedTableHandle'()
26 | {
27 | expect:
28 | TableHandle.parse(tableHandleStr) == expectedTableHandle
29 |
30 | where:
31 | tableHandleStr | expectedTableHandle
32 | 'table' | tableHandle('table')
33 | 'schema.table' | tableHandle('table').inSchema('schema')
34 | 'db.schema.table' | tableHandle('table').inDatabase('db').inSchema('schema')
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/ImmutableTableRequirement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table;
16 |
17 | public class ImmutableTableRequirement
18 | extends TableRequirement
19 | {
20 | public ImmutableTableRequirement(TableDefinition tableDefinition)
21 | {
22 | this(tableDefinition, tableDefinition.getTableHandle());
23 | }
24 |
25 | public ImmutableTableRequirement(TableDefinition tableDefinition, TableHandle tableHandle)
26 | {
27 | super(tableDefinition, tableHandle);
28 | }
29 |
30 | @Override
31 | public ImmutableTableRequirement copyWithDatabase(String databaseName)
32 | {
33 | return new ImmutableTableRequirement(getTableDefinition(), getTableHandle().inDatabase(databaseName));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tempto-ldap/src/main/java/io/trino/tempto/internal/fulfillment/ldap/LdapObjectModuleProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.ldap;
16 |
17 | import com.google.inject.AbstractModule;
18 | import com.google.inject.Module;
19 | import io.trino.tempto.configuration.Configuration;
20 | import io.trino.tempto.initialization.SuiteModuleProvider;
21 |
22 | public class LdapObjectModuleProvider
23 | implements SuiteModuleProvider
24 | {
25 | public Module getModule(Configuration configuration)
26 | {
27 | return new AbstractModule()
28 | {
29 | @Override
30 | protected void configure()
31 | {
32 | bind(LdapObjectEntryManager.class).to(DefaultLdapObjectEntryManager.class);
33 | }
34 | };
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/convention/MutableTableDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.internal.convention;
15 |
16 | import io.trino.tempto.fulfillment.table.MutableTableRequirement.State;
17 | import io.trino.tempto.fulfillment.table.TableHandle;
18 |
19 | import static com.google.common.base.Preconditions.checkNotNull;
20 |
21 | public final class MutableTableDescriptor
22 | {
23 | public final String tableDefinitionName;
24 | public final State state;
25 | public final TableHandle tableHandle;
26 |
27 | MutableTableDescriptor(String tableDefinitionName, State state, TableHandle name)
28 | {
29 | this.tableDefinitionName = checkNotNull(tableDefinitionName);
30 | this.state = checkNotNull(state);
31 | this.tableHandle = checkNotNull(name);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/ssh/SshClientFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.ssh;
16 |
17 | import java.util.Optional;
18 |
19 | public interface SshClientFactory
20 | {
21 | String DEFAULT_USER = "root";
22 |
23 | default SshClient create(String host)
24 | {
25 | return create(host, 22, DEFAULT_USER, Optional.empty());
26 | }
27 |
28 | default SshClient create(String host, int port)
29 | {
30 | return create(host, port, DEFAULT_USER, Optional.empty());
31 | }
32 |
33 | default SshClient create(String host, int port, String user)
34 | {
35 | return create(host, port, user, Optional.empty());
36 | }
37 |
38 | SshClient create(String host, int port, String user, Optional password);
39 |
40 | void addIdentity(String pathToPem);
41 | }
42 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/TableDefinition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table;
16 |
17 | import java.util.Optional;
18 |
19 | import static java.util.Objects.requireNonNull;
20 |
21 | public abstract class TableDefinition
22 | {
23 | protected final TableHandle handle;
24 |
25 | public TableDefinition(TableHandle handle)
26 | {
27 | this.handle = requireNonNull(handle, "handle is null");
28 | }
29 |
30 | public String getName()
31 | {
32 | return handle.getName();
33 | }
34 |
35 | public Optional getSchema()
36 | {
37 | return handle.getSchema();
38 | }
39 |
40 | public Optional getDatabase()
41 | {
42 | return handle.getDatabase();
43 | }
44 |
45 | public TableHandle getTableHandle()
46 | {
47 | return handle;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/customer_demographics.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 1920800,
3 | "columns": {
4 | "cd_demo_sk": {
5 | "distinctValuesCount": 1920800,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 1920800
9 | },
10 | "cd_gender": {
11 | "distinctValuesCount": 2,
12 | "nullsCount": 0,
13 | "min": "F",
14 | "max": "M"
15 | },
16 | "cd_marital_status": {
17 | "distinctValuesCount": 5,
18 | "nullsCount": 0,
19 | "min": "D",
20 | "max": "W"
21 | },
22 | "cd_education_status": {
23 | "distinctValuesCount": 7,
24 | "nullsCount": 0,
25 | "min": "2 yr Degree",
26 | "max": "Unknown"
27 | },
28 | "cd_purchase_estimate": {
29 | "distinctValuesCount": 20,
30 | "nullsCount": 0,
31 | "min": 500,
32 | "max": 10000
33 | },
34 | "cd_credit_rating": {
35 | "distinctValuesCount": 4,
36 | "nullsCount": 0,
37 | "min": "Good",
38 | "max": "Unknown"
39 | },
40 | "cd_dep_count": {
41 | "distinctValuesCount": 7,
42 | "nullsCount": 0,
43 | "min": 0,
44 | "max": 6
45 | },
46 | "cd_dep_employed_count": {
47 | "distinctValuesCount": 7,
48 | "nullsCount": 0,
49 | "min": 0,
50 | "max": 6
51 | },
52 | "cd_dep_college_count": {
53 | "distinctValuesCount": 7,
54 | "nullsCount": 0,
55 | "min": 0,
56 | "max": 6
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/listeners/TestMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.listeners;
16 |
17 | import java.util.Set;
18 |
19 | import static com.google.common.base.MoreObjects.firstNonNull;
20 | import static com.google.common.base.Preconditions.checkNotNull;
21 | import static com.google.common.collect.ImmutableSet.copyOf;
22 |
23 | public class TestMetadata
24 | {
25 | public final Set testGroups;
26 | public final String testName;
27 | public final Object[] testParameters;
28 |
29 | public TestMetadata(Set testGroups, String testName, Object[] testParameters)
30 | {
31 | this.testGroups = copyOf(checkNotNull(testGroups, "testGroups can not be null"));
32 | this.testName = checkNotNull(testName, "testName can not be null");
33 | this.testParameters = firstNonNull(testParameters, new Object[]{});
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/tpch/show_stats_for_lineitem.sql:
--------------------------------------------------------------------------------
1 | -- database: trino; groups: stats, tpcds; tables: lineitem
2 | -- delimiter: |; ignoreOrder: true; types: VARCHAR|DOUBLE|DOUBLE|DOUBLE|DOUBLE|VARCHAR|VARCHAR
3 | --! name: show stats for lineitem
4 | SHOW STATS FOR lineitem
5 | --!
6 | l_orderkey|null|1500000.00000000000|0.00000000000|null|1|6000000|
7 | l_partkey|null|200000.00000000000|0.00000000000|null|1|200000|
8 | l_suppkey|null|10000.00000000000|0.00000000000|null|1|10000|
9 | l_linenumber|null|7.00000000000|0.00000000000|null|1|7|
10 | l_quantity|null|50.00000000000|0.00000000000|null|0.02|1.0|
11 | l_extendedprice|null|208097.00000000000|0.00000000000|null|18.02|2098.99|
12 | l_discount|null|1.00000000000|0.00000000000|null|0.0|0.0|
13 | l_tax|null|1.00000000000|0.00000000000|null|0.0|0.0|
14 | l_returnflag|2000205.00000000000|3.00000000000|0.00000000000|null|null|null|
15 | l_linestatus|2000205.00000000000|2.00000000000|0.00000000000|null|null|null|
16 | l_shipdate|null|2526.00000000000|0.00000000000|null|1992-01-02|1998-12-01|
17 | l_commitdate|null|2466.00000000000|0.00000000000|null|1992-01-31|1998-10-31|
18 | l_receiptdate|null|2554.00000000000|0.00000000000|null|1992-01-04|1998-12-31|
19 | l_shipinstruct|50009925.00000000000|4.00000000000|0.00000000000|null|null|null|
20 | l_shipmode|20003850.00000000000|7.00000000000|0.00000000000|null|null|null|
21 | l_comment|88018020.00000000000|4580667.00000000000|0.00000000000|null|null|null|
22 | null|null|null|null|6001215.00000000000|null|null|
23 |
--------------------------------------------------------------------------------
/tempto-kafka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | io.trino.tempto
7 | tempto-root
8 | 203-SNAPSHOT
9 |
10 |
11 | tempto-kafka
12 | jar
13 |
14 |
15 | ${project.parent.basedir}
16 |
17 | true
18 |
19 |
20 |
21 |
22 |
23 | com.google.guava
24 | guava
25 |
26 |
27 |
28 | com.google.inject
29 | guice
30 |
31 |
32 | io.trino.tempto
33 | tempto-core
34 |
35 |
36 |
37 | org.apache.kafka
38 | kafka-clients
39 | 2.4.1
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/util/Lazy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.util;
16 |
17 | import javax.annotation.concurrent.ThreadSafe;
18 |
19 | import java.util.Optional;
20 | import java.util.function.Supplier;
21 |
22 | import static java.util.Objects.requireNonNull;
23 |
24 | @ThreadSafe
25 | public class Lazy
26 | implements Supplier
27 | {
28 | private final Supplier provider;
29 | private T instance;
30 |
31 | public Lazy(Supplier provider)
32 | {
33 | this.provider = requireNonNull(provider, "provider is null");
34 | }
35 |
36 | @Override
37 | public synchronized T get()
38 | {
39 | if (instance == null) {
40 | instance = requireNonNull(provider.get());
41 | }
42 | return instance;
43 | }
44 |
45 | public synchronized Optional lazyGet()
46 | {
47 | return Optional.ofNullable(instance);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/orders.o_orderstatus.P.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 38543,
3 | "columns": {
4 | "o_orderkey": {
5 | "distinctValuesCount": 38543,
6 | "nullsCount": 0,
7 | "min": 65,
8 | "max": 5999875
9 | },
10 | "o_custkey": {
11 | "distinctValuesCount": 31310,
12 | "nullsCount": 0,
13 | "min": 2,
14 | "max": 149998
15 | },
16 | "o_orderstatus": {
17 | "distinctValuesCount": 1,
18 | "nullsCount": 0,
19 | "min": "P",
20 | "max": "P"
21 | },
22 | "o_totalprice": {
23 | "distinctValuesCount": 38515,
24 | "nullsCount": 0,
25 | "min": 2933.43,
26 | "max": 491549.57
27 | },
28 | "o_orderdate": {
29 | "distinctValuesCount": 120,
30 | "nullsCount": 0,
31 | "min": 9178,
32 | "max": 9297
33 | },
34 | "o_orderpriority": {
35 | "distinctValuesCount": 5,
36 | "nullsCount": 0,
37 | "min": "1-URGENT",
38 | "max": "5-LOW"
39 | },
40 | "o_clerk": {
41 | "distinctValuesCount": 1000,
42 | "nullsCount": 0,
43 | "min": "Clerk#000000001",
44 | "max": "Clerk#000001000"
45 | },
46 | "o_shippriority": {
47 | "distinctValuesCount": 1,
48 | "nullsCount": 0,
49 | "min": 0,
50 | "max": 0
51 | },
52 | "o_comment": {
53 | "distinctValuesCount": 38531,
54 | "nullsCount": 0,
55 | "min": " Tiresias haggle slyly bli",
56 | "max": "zzle furiously. bold packa"
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/customer.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 150000,
3 | "columns": {
4 | "c_custkey": {
5 | "distinctValuesCount": 150000,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 150000
9 | },
10 | "c_name": {
11 | "distinctValuesCount": 150000,
12 | "nullsCount": 0,
13 | "min": "Customer#000000001",
14 | "max": "Customer#000150000"
15 | },
16 | "c_address": {
17 | "distinctValuesCount": 150000,
18 | "nullsCount": 0,
19 | "min": " 2uZwVhQvwA",
20 | "max": "zzxGktzXTMKS1BxZlgQ9nqQ"
21 | },
22 | "c_nationkey": {
23 | "distinctValuesCount": 25,
24 | "nullsCount": 0,
25 | "min": 0,
26 | "max": 24
27 | },
28 | "c_phone": {
29 | "distinctValuesCount": 150000,
30 | "nullsCount": 0,
31 | "min": "10-100-106-1617",
32 | "max": "34-999-618-6881"
33 | },
34 | "c_acctbal": {
35 | "distinctValuesCount": 140187,
36 | "nullsCount": 0,
37 | "min": -999.99,
38 | "max": 9999.99
39 | },
40 | "c_mktsegment": {
41 | "distinctValuesCount": 5,
42 | "nullsCount": 0,
43 | "min": "AUTOMOBILE",
44 | "max": "MACHINERY"
45 | },
46 | "c_comment": {
47 | "distinctValuesCount": 149968,
48 | "nullsCount": 0,
49 | "min": " Tiresias according to the slyly blithe instructions detect quickly at the slyly express courts. express dinos wake ",
50 | "max": "zzle. blithely regular instructions cajol"
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/logging/LoggingMdcHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.logging;
16 |
17 | import io.trino.tempto.internal.listeners.TestMetadata;
18 | import io.trino.tempto.internal.listeners.TestMetadataReader;
19 | import org.testng.ITestResult;
20 |
21 | public class LoggingMdcHelper
22 | {
23 | private static final String MDC_TEST_ID_KEY = "test_id";
24 | private static final TestMetadataReader testMetadataReader = new TestMetadataReader();
25 |
26 | private LoggingMdcHelper() {}
27 |
28 | public static void setupLoggingMdcForTest(ITestResult testCase)
29 | {
30 | TestMetadata testMetadata = testMetadataReader.readTestMetadata(testCase);
31 | String testId = testMetadata.testName;
32 | org.slf4j.MDC.put("test_id", testId);
33 | }
34 |
35 | public static void cleanLoggingMdc()
36 | {
37 | org.slf4j.MDC.remove(MDC_TEST_ID_KEY);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/resources/TestResourceFulfiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.resources;
16 |
17 | import com.google.common.collect.ImmutableSet;
18 | import io.trino.tempto.Requirement;
19 | import io.trino.tempto.context.State;
20 | import io.trino.tempto.fulfillment.RequirementFulfiller;
21 | import io.trino.tempto.fulfillment.TestStatus;
22 |
23 | import java.util.Set;
24 |
25 | @RequirementFulfiller.TestLevelFulfiller
26 | public class TestResourceFulfiller
27 | implements RequirementFulfiller
28 | {
29 | private final TestResourcesState resourcesState = new TestResourcesState();
30 |
31 | @Override
32 | public Set fulfill(Set requirements)
33 | {
34 | return ImmutableSet.of(resourcesState);
35 | }
36 |
37 | @Override
38 | public void cleanup(TestStatus status)
39 | {
40 | resourcesState.close();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/command/TestCommandRequirement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.command;
16 |
17 | import java.util.List;
18 |
19 | import static java.util.Collections.singletonList;
20 |
21 | /**
22 | * Commands will be executed before the test.
23 | */
24 | public class TestCommandRequirement
25 | extends CommandRequirement
26 | {
27 | public static TestCommandRequirement testCommand(String command)
28 | {
29 | return new TestCommandRequirement(new Command(command));
30 | }
31 |
32 | public TestCommandRequirement(Command setupCommand)
33 | {
34 | this(singletonList(setupCommand));
35 | }
36 |
37 | public TestCommandRequirement(List setupCommands)
38 | {
39 | super(setupCommands);
40 | }
41 |
42 | @Override
43 | public String toString()
44 | {
45 | return "TestCommandRequirement{} " + super.toString();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/resources/SuiteResourceFulfiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.resources;
16 |
17 | import com.google.common.collect.ImmutableSet;
18 | import io.trino.tempto.Requirement;
19 | import io.trino.tempto.context.State;
20 | import io.trino.tempto.fulfillment.RequirementFulfiller;
21 | import io.trino.tempto.fulfillment.TestStatus;
22 |
23 | import java.util.Set;
24 |
25 | @RequirementFulfiller.SuiteLevelFulfiller
26 | public class SuiteResourceFulfiller
27 | implements RequirementFulfiller
28 | {
29 | private final SuiteResourcesState resourcesState = new SuiteResourcesState();
30 |
31 | @Override
32 | public Set fulfill(Set requirements)
33 | {
34 | return ImmutableSet.of(resourcesState);
35 | }
36 |
37 | @Override
38 | public void cleanup(TestStatus status)
39 | {
40 | resourcesState.close();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/orders.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 1500000,
3 | "columns": {
4 | "o_orderkey": {
5 | "distinctValuesCount": 1500000,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 6000000
9 | },
10 | "o_custkey": {
11 | "distinctValuesCount": 99996,
12 | "nullsCount": 0,
13 | "min": 1,
14 | "max": 149999
15 | },
16 | "o_orderstatus": {
17 | "distinctValuesCount": 3,
18 | "nullsCount": 0,
19 | "min": "F",
20 | "max": "P"
21 | },
22 | "o_totalprice": {
23 | "distinctValuesCount": 1464556,
24 | "nullsCount": 0,
25 | "min": 857.71,
26 | "max": 555285.16
27 | },
28 | "o_orderdate": {
29 | "distinctValuesCount": 2406,
30 | "nullsCount": 0,
31 | "min": 8035,
32 | "max": 10440
33 | },
34 | "o_orderpriority": {
35 | "distinctValuesCount": 5,
36 | "nullsCount": 0,
37 | "min": "1-URGENT",
38 | "max": "5-LOW"
39 | },
40 | "o_clerk": {
41 | "distinctValuesCount": 1000,
42 | "nullsCount": 0,
43 | "min": "Clerk#000000001",
44 | "max": "Clerk#000001000"
45 | },
46 | "o_shippriority": {
47 | "distinctValuesCount": 1,
48 | "nullsCount": 0,
49 | "min": 0,
50 | "max": 0
51 | },
52 | "o_comment": {
53 | "distinctValuesCount": 1482071,
54 | "nullsCount": 0,
55 | "min": " Tiresias about the blithely ironic a",
56 | "max": "zzle? furiously ironic instructions among the unusual t"
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/command/SuiteCommandRequirement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.command;
16 |
17 | import java.util.List;
18 |
19 | import static java.util.Collections.singletonList;
20 |
21 | /**
22 | * Commands which will be executed before the test suite.
23 | */
24 | public class SuiteCommandRequirement
25 | extends CommandRequirement
26 | {
27 | public static SuiteCommandRequirement suiteCommand(String command)
28 | {
29 | return new SuiteCommandRequirement(new Command(command));
30 | }
31 |
32 | public SuiteCommandRequirement(Command setupCommand)
33 | {
34 | this(singletonList(setupCommand));
35 | }
36 |
37 | public SuiteCommandRequirement(List setupCommands)
38 | {
39 | super(setupCommands);
40 | }
41 |
42 | @Override
43 | public String toString()
44 | {
45 | return "SuiteCommandRequirement{} " + super.toString();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/hive/HiveDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table.hive;
16 |
17 | import io.trino.tempto.fulfillment.table.hive.statistics.TableStatistics;
18 | import io.trino.tempto.hadoop.hdfs.HdfsClient.RepeatableContentProducer;
19 |
20 | import java.util.Collection;
21 | import java.util.Optional;
22 |
23 | /**
24 | * Responsible for providing data.
25 | */
26 | public interface HiveDataSource
27 | {
28 | /**
29 | * @return path suffix where data source data should be stored
30 | */
31 | String getPathSuffix();
32 |
33 | /**
34 | * @return collection with table files {@link RepeatableContentProducer}.
35 | * For each {@link RepeatableContentProducer} separate file will be created on HDFS
36 | */
37 | Collection data();
38 |
39 | default Optional getStatistics()
40 | {
41 | return Optional.empty();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/convention/recursion/RecursionPathTestFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.convention.recursion;
16 |
17 | import io.trino.tempto.internal.convention.ConventionBasedTest;
18 | import io.trino.tempto.internal.convention.ConventionBasedTestFactory;
19 |
20 | import java.nio.file.Files;
21 | import java.nio.file.Path;
22 | import java.util.List;
23 |
24 | public class RecursionPathTestFactory
25 | implements ConventionBasedTestFactory.PathTestFactory
26 | {
27 | @Override
28 | public boolean isSupportedPath(Path path)
29 | {
30 | return Files.isDirectory(path);
31 | }
32 |
33 | @Override
34 | public List createTestsForPath(Path path, String testNamePrefix, ConventionBasedTestFactory factory)
35 | {
36 | String newPrefix = testNamePrefix + "." + path.getFileName();
37 | return factory.createTestsForChildrenOfPath(path, newPrefix);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/initialization/RequirementsAwareTestNGMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.initialization;
16 |
17 | import io.trino.tempto.Requirement;
18 | import org.testng.ITestNGMethod;
19 |
20 | import java.util.Set;
21 |
22 | import static com.google.common.collect.Sets.newHashSet;
23 |
24 | public class RequirementsAwareTestNGMethod
25 | extends DelegateTestNGMethod
26 | {
27 | private final Set requirements;
28 |
29 | public RequirementsAwareTestNGMethod(ITestNGMethod delegate, Set requirements)
30 | {
31 | super(delegate);
32 | this.requirements = requirements;
33 | }
34 |
35 | public Set getRequirements()
36 | {
37 | return requirements;
38 | }
39 |
40 | @Override
41 | public ITestNGMethod clone()
42 | {
43 | return new RequirementsAwareTestNGMethod(super.delegate.clone(), newHashSet(requirements));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/time_dim.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 86400,
3 | "columns": {
4 | "t_time_sk": {
5 | "distinctValuesCount": 86400,
6 | "nullsCount": 0,
7 | "min": 0,
8 | "max": 86399
9 | },
10 | "t_time_id": {
11 | "distinctValuesCount": 86400,
12 | "nullsCount": 0,
13 | "min": "AAAAAAAAAAAABAAA",
14 | "max": "AAAAAAAAPPPPAAAA"
15 | },
16 | "t_time": {
17 | "distinctValuesCount": 86400,
18 | "nullsCount": 0,
19 | "min": 0,
20 | "max": 86399
21 | },
22 | "t_hour": {
23 | "distinctValuesCount": 24,
24 | "nullsCount": 0,
25 | "min": 0,
26 | "max": 23
27 | },
28 | "t_minute": {
29 | "distinctValuesCount": 60,
30 | "nullsCount": 0,
31 | "min": 0,
32 | "max": 59
33 | },
34 | "t_second": {
35 | "distinctValuesCount": 60,
36 | "nullsCount": 0,
37 | "min": 0,
38 | "max": 59
39 | },
40 | "t_am_pm": {
41 | "distinctValuesCount": 2,
42 | "nullsCount": 0,
43 | "min": "AM",
44 | "max": "PM"
45 | },
46 | "t_shift": {
47 | "distinctValuesCount": 3,
48 | "nullsCount": 0,
49 | "min": "first",
50 | "max": "third"
51 | },
52 | "t_sub_shift": {
53 | "distinctValuesCount": 4,
54 | "nullsCount": 0,
55 | "min": "afternoon",
56 | "max": "night"
57 | },
58 | "t_meal_time": {
59 | "distinctValuesCount": 4,
60 | "nullsCount": 0,
61 | "min": "",
62 | "max": "lunch"
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/orders.o_orderstatus.O.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 732044,
3 | "columns": {
4 | "o_orderkey": {
5 | "distinctValuesCount": 732044,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 6000000
9 | },
10 | "o_custkey": {
11 | "distinctValuesCount": 99621,
12 | "nullsCount": 0,
13 | "min": 1,
14 | "max": 149999
15 | },
16 | "o_orderstatus": {
17 | "distinctValuesCount": 1,
18 | "nullsCount": 0,
19 | "min": "O",
20 | "max": "O"
21 | },
22 | "o_totalprice": {
23 | "distinctValuesCount": 723368,
24 | "nullsCount": 0,
25 | "min": 857.71,
26 | "max": 530604.44
27 | },
28 | "o_orderdate": {
29 | "distinctValuesCount": 1262,
30 | "nullsCount": 0,
31 | "min": 9178,
32 | "max": 10440
33 | },
34 | "o_orderpriority": {
35 | "distinctValuesCount": 5,
36 | "nullsCount": 0,
37 | "min": "1-URGENT",
38 | "max": "5-LOW"
39 | },
40 | "o_clerk": {
41 | "distinctValuesCount": 1000,
42 | "nullsCount": 0,
43 | "min": "Clerk#000000001",
44 | "max": "Clerk#000001000"
45 | },
46 | "o_shippriority": {
47 | "distinctValuesCount": 1,
48 | "nullsCount": 0,
49 | "min": 0,
50 | "max": 0
51 | },
52 | "o_comment": {
53 | "distinctValuesCount": 727175,
54 | "nullsCount": 0,
55 | "min": " Tiresias about the blithely ironic a",
56 | "max": "zzle? furiously ironic instructions among the unusual t"
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/part.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 200000,
3 | "columns": {
4 | "p_partkey": {
5 | "distinctValuesCount": 200000,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 200000
9 | },
10 | "p_name": {
11 | "distinctValuesCount": 199997,
12 | "nullsCount": 0,
13 | "min": "almond antique blue royal burnished",
14 | "max": "yellow white seashell lavender black"
15 | },
16 | "p_mfgr": {
17 | "distinctValuesCount": 5,
18 | "nullsCount": 0,
19 | "min": "Manufacturer#1",
20 | "max": "Manufacturer#5"
21 | },
22 | "p_brand": {
23 | "distinctValuesCount": 25,
24 | "nullsCount": 0,
25 | "min": "Brand#11",
26 | "max": "Brand#55"
27 | },
28 | "p_type": {
29 | "distinctValuesCount": 150,
30 | "nullsCount": 0,
31 | "min": "ECONOMY ANODIZED BRASS",
32 | "max": "STANDARD POLISHED TIN"
33 | },
34 | "p_size": {
35 | "distinctValuesCount": 50,
36 | "nullsCount": 0,
37 | "min": 1,
38 | "max": 50
39 | },
40 | "p_container": {
41 | "distinctValuesCount": 40,
42 | "nullsCount": 0,
43 | "min": "JUMBO BAG",
44 | "max": "WRAP PKG"
45 | },
46 | "p_retailprice": {
47 | "distinctValuesCount": 20899,
48 | "nullsCount": 0,
49 | "min": 901.0,
50 | "max": 2098.99
51 | },
52 | "p_comment": {
53 | "distinctValuesCount": 131753,
54 | "nullsCount": 0,
55 | "min": " Tire",
56 | "max": "zzle. quickly si"
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpch/sf1/orders.o_orderstatus.F.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 729413,
3 | "columns": {
4 | "o_orderkey": {
5 | "distinctValuesCount": 729413,
6 | "nullsCount": 0,
7 | "min": 3,
8 | "max": 5999975
9 | },
10 | "o_custkey": {
11 | "distinctValuesCount": 99609,
12 | "nullsCount": 0,
13 | "min": 1,
14 | "max": 149999
15 | },
16 | "o_orderstatus": {
17 | "distinctValuesCount": 1,
18 | "nullsCount": 0,
19 | "min": "F",
20 | "max": "F"
21 | },
22 | "o_totalprice": {
23 | "distinctValuesCount": 720822,
24 | "nullsCount": 0,
25 | "min": 866.9,
26 | "max": 555285.16
27 | },
28 | "o_orderdate": {
29 | "distinctValuesCount": 1261,
30 | "nullsCount": 0,
31 | "min": 8035,
32 | "max": 9296
33 | },
34 | "o_orderpriority": {
35 | "distinctValuesCount": 5,
36 | "nullsCount": 0,
37 | "min": "1-URGENT",
38 | "max": "5-LOW"
39 | },
40 | "o_clerk": {
41 | "distinctValuesCount": 1000,
42 | "nullsCount": 0,
43 | "min": "Clerk#000000001",
44 | "max": "Clerk#000001000"
45 | },
46 | "o_shippriority": {
47 | "distinctValuesCount": 1,
48 | "nullsCount": 0,
49 | "min": 0,
50 | "max": 0
51 | },
52 | "o_comment": {
53 | "distinctValuesCount": 724600,
54 | "nullsCount": 0,
55 | "min": " Tiresias above the carefully ironic packages nag about the pend",
56 | "max": "zzle; ironic accounts affix slyly regular pinto b"
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/hive/statistics/TableStatistics.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table.hive.statistics;
16 |
17 | import com.fasterxml.jackson.annotation.JsonCreator;
18 | import com.fasterxml.jackson.annotation.JsonProperty;
19 | import com.google.common.collect.ImmutableMap;
20 |
21 | import java.util.Map;
22 |
23 | public class TableStatistics
24 | {
25 | private final long rowCount;
26 | private final Map columns;
27 |
28 | @JsonCreator
29 | public TableStatistics(
30 | @JsonProperty("rowCount") long rowCount,
31 | @JsonProperty("columns") Map columns)
32 | {
33 | this.rowCount = rowCount;
34 | this.columns = ImmutableMap.copyOf(columns);
35 | }
36 |
37 | public long getRowCount()
38 | {
39 | return rowCount;
40 | }
41 |
42 | public Map getColumns()
43 | {
44 | return columns;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/process/JavaProcessLauncherTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.process
15 |
16 | import spock.lang.Specification
17 |
18 | import static io.trino.tempto.process.JavaProcessLauncher.defaultJavaProcessLauncher
19 | import static io.trino.tempto.process.TestClassWithMain.EXPECTED_ARGUMENT
20 | import static io.trino.tempto.process.TestClassWithMain.EXPECTED_LINE
21 | import static io.trino.tempto.process.TestClassWithMain.PRODUCED_LINE
22 |
23 | class JavaProcessLauncherTest
24 | extends Specification
25 | {
26 | def 'test execute CLI Java process'()
27 | throws IOException, InterruptedException
28 | {
29 | setup:
30 | LocalCliProcess child = new LocalCliProcess(defaultJavaProcessLauncher().launch(TestClassWithMain.class, [EXPECTED_ARGUMENT]))
31 | child.getProcessInput().println(EXPECTED_LINE)
32 |
33 | expect:
34 | child.readRemainingOutputLines() == [PRODUCED_LINE]
35 | child.waitForWithTimeoutAndKill()
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tempto-ldap/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | io.trino.tempto
7 | tempto-root
8 | 203-SNAPSHOT
9 |
10 |
11 | tempto-ldap
12 | jar
13 |
14 |
15 | ${project.parent.basedir}
16 |
17 | true
18 |
19 |
20 |
21 |
22 |
23 | com.google.guava
24 | guava
25 |
26 |
27 |
28 | com.google.inject
29 | guice
30 |
31 |
32 | io.trino.tempto
33 | tempto-core
34 |
35 |
36 |
37 | org.apache.commons
38 | commons-lang3
39 |
40 |
41 |
42 | org.slf4j
43 | slf4j-api
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/command/Command.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.command;
16 |
17 | import java.util.Objects;
18 |
19 | public class Command
20 | {
21 | private final String command;
22 |
23 | public Command(String command)
24 | {
25 | this.command = command;
26 | }
27 |
28 | public String getCommand()
29 | {
30 | return command;
31 | }
32 |
33 | @Override
34 | public boolean equals(Object o)
35 | {
36 | if (this == o) { return true; }
37 | if (o == null || getClass() != o.getClass()) { return false; }
38 | Command command1 = (Command) o;
39 | return Objects.equals(command, command1.command);
40 | }
41 |
42 | @Override
43 | public int hashCode()
44 | {
45 | return Objects.hash(command);
46 | }
47 |
48 | @Override
49 | public String toString()
50 | {
51 | return "Command{" +
52 | "command='" + command + '\'' +
53 | '}';
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/hive/tpch/TpchTable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment.table.hive.tpch;
16 |
17 | /**
18 | * Enum containing names of all TPCH tables. Moreover it holds reference to
19 | * {@link io.trino.tpch.TpchTable} entity which is used for generating data.
20 | */
21 | public enum TpchTable
22 | {
23 | NATION(io.trino.tpch.TpchTable.NATION),
24 | REGION(io.trino.tpch.TpchTable.REGION),
25 | PART(io.trino.tpch.TpchTable.PART),
26 | ORDERS(io.trino.tpch.TpchTable.ORDERS),
27 | CUSTOMER(io.trino.tpch.TpchTable.CUSTOMER),
28 | SUPPLIER(io.trino.tpch.TpchTable.SUPPLIER),
29 | LINE_ITEM(io.trino.tpch.TpchTable.LINE_ITEM),
30 | PART_SUPPLIER(io.trino.tpch.TpchTable.PART_SUPPLIER);
31 |
32 | private final io.trino.tpch.TpchTable> entity;
33 |
34 | TpchTable(io.trino.tpch.TpchTable> entity)
35 | {
36 | this.entity = entity;
37 | }
38 |
39 | public io.trino.tpch.TpchTable> entity()
40 | {
41 | return entity;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/context/TestContextStack.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.context;
16 |
17 | import io.trino.tempto.context.TestContext;
18 |
19 | import java.util.Iterator;
20 | import java.util.Stack;
21 |
22 | public class TestContextStack
23 | implements Iterable
24 | {
25 | private final Stack testContextStack = new Stack<>();
26 |
27 | public void push(C testContext)
28 | {
29 | testContextStack.push(testContext);
30 | }
31 |
32 | public C pop()
33 | {
34 | return testContextStack.pop();
35 | }
36 |
37 | public C peek()
38 | {
39 | return testContextStack.peek();
40 | }
41 |
42 | public int size()
43 | {
44 | return testContextStack.size();
45 | }
46 |
47 | public boolean empty()
48 | {
49 | return testContextStack.empty();
50 | }
51 |
52 | @Override
53 | public Iterator iterator()
54 | {
55 | return testContextStack.iterator();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/RequirementFulfiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.fulfillment;
16 |
17 | import io.trino.tempto.Requirement;
18 | import io.trino.tempto.context.State;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 | import java.util.Set;
25 |
26 | public interface RequirementFulfiller
27 | {
28 | /**
29 | * Apply annotation to fulfillers which should be evaluated at suite level.
30 | */
31 | @Retention(RetentionPolicy.RUNTIME)
32 | @Target({ElementType.TYPE})
33 | @interface SuiteLevelFulfiller
34 | {}
35 |
36 | /**
37 | * Apply annotation to fulfillers which should be evaluated at testLevel.
38 | */
39 | @Retention(RetentionPolicy.RUNTIME)
40 | @Target({ElementType.TYPE})
41 | @interface TestLevelFulfiller
42 | {}
43 |
44 | Set fulfill(Set requirements);
45 |
46 | void cleanup(TestStatus status);
47 | }
48 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/catalog_page.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 11718,
3 | "columns": {
4 | "cp_catalog_page_sk": {
5 | "distinctValuesCount": 11718,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 11718
9 | },
10 | "cp_catalog_page_id": {
11 | "distinctValuesCount": 11718,
12 | "nullsCount": 0,
13 | "min": "AAAAAAAAAAABAAAA",
14 | "max": "AAAAAAAAPPPBAAAA"
15 | },
16 | "cp_start_date_sk": {
17 | "distinctValuesCount": 91,
18 | "nullsCount": 101,
19 | "min": 2450815,
20 | "max": 2453005
21 | },
22 | "cp_end_date_sk": {
23 | "distinctValuesCount": 97,
24 | "nullsCount": 108,
25 | "min": 2450844,
26 | "max": 2453186
27 | },
28 | "cp_department": {
29 | "distinctValuesCount": 1,
30 | "nullsCount": 120,
31 | "min": "DEPARTMENT",
32 | "max": "DEPARTMENT"
33 | },
34 | "cp_catalog_number": {
35 | "distinctValuesCount": 109,
36 | "nullsCount": 104,
37 | "min": 1,
38 | "max": 109
39 | },
40 | "cp_catalog_page_number": {
41 | "distinctValuesCount": 108,
42 | "nullsCount": 116,
43 | "min": 1,
44 | "max": 108
45 | },
46 | "cp_description": {
47 | "distinctValuesCount": 11609,
48 | "nullsCount": 109,
49 | "min": "A bit asleep rooms cannot feel short dry secondary leads. Ab",
50 | "max": "Youngsters should get very. Bad, necessary years must pick telecommunications. Co"
51 | },
52 | "cp_type": {
53 | "distinctValuesCount": 3,
54 | "nullsCount": 110,
55 | "min": "bi-annual",
56 | "max": "quarterly"
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/fulfillment/table/jdbc/LoaderFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.fulfillment.table.jdbc;
16 |
17 | import io.trino.tempto.query.QueryExecutor;
18 | import org.slf4j.Logger;
19 |
20 | import java.sql.JDBCType;
21 | import java.sql.SQLException;
22 | import java.util.List;
23 |
24 | import static org.slf4j.LoggerFactory.getLogger;
25 |
26 | class LoaderFactory
27 | {
28 | private static final Logger LOGGER = getLogger(LoaderFactory.class);
29 |
30 | Loader create(QueryExecutor queryExecutor, String tableName)
31 | throws SQLException
32 | {
33 | List columnTypes = queryExecutor.executeQuery("SELECT * FROM " + tableName + " WHERE 1=2").getColumnTypes();
34 |
35 | try {
36 | return new BatchLoader(queryExecutor, tableName, columnTypes.size());
37 | }
38 | catch (SQLException sqlException) {
39 | LOGGER.warn("Unable to insert data with PreparedStatement", sqlException);
40 | return new InsertLoader(queryExecutor, tableName, columnTypes);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/internal/configuration/KeyUtilsTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.configuration
16 |
17 | import spock.lang.Specification
18 |
19 | import static io.trino.tempto.configuration.KeyUtils.getKeyPrefix
20 | import static io.trino.tempto.configuration.KeyUtils.joinKey
21 | import static io.trino.tempto.configuration.KeyUtils.splitKey
22 |
23 | class KeyUtilsTest
24 | extends Specification
25 | {
26 | def "test split key"()
27 | {
28 | expect:
29 | splitKey('abc') == ['abc']
30 | splitKey('a.b.c') == ['a', 'b', 'c']
31 | }
32 |
33 | def "join key"()
34 | {
35 | expect:
36 | joinKey(['a', 'b', 'c']) == 'a.b.c'
37 | joinKey(['a', null, 'c']) == 'a.c'
38 | joinKey([null, 'b', 'c']) == 'b.c'
39 | joinKey('a', 'b', 'c') == 'a.b.c'
40 | }
41 |
42 | def "get key prefix"()
43 | {
44 | expect:
45 | getKeyPrefix('a.b.c', 1) == 'a'
46 | getKeyPrefix('a.b.c', 2) == 'a.b'
47 | getKeyPrefix('a.b.c', 3) == 'a.b.c'
48 | getKeyPrefix('a.b.c', 4) == 'a.b.c'
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/TableManagerDispatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package io.trino.tempto.fulfillment.table;
15 |
16 | import java.util.Collection;
17 |
18 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContext;
19 |
20 | /**
21 | * Returns an appropriate {@link TableManager} based on table type.
22 | */
23 | public interface TableManagerDispatcher
24 | {
25 | default TableManager getTableManagerFor(TableInstance tableInstance)
26 | {
27 | return getTableManagerFor(tableInstance.tableDefinition());
28 | }
29 |
30 | default TableManager getTableManagerFor(T tableDefinition)
31 | {
32 | return getTableManagerFor(tableDefinition, tableDefinition.getTableHandle());
33 | }
34 |
35 | TableManager getTableManagerFor(TableDefinition tableDefinition, TableHandle tableHandle);
36 |
37 | Collection getAllTableManagers();
38 |
39 | static TableManagerDispatcher getTableManagerDispatcher()
40 | {
41 | return testContext().getDependency(TableManagerDispatcher.class);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/configuration/EmptyConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package io.trino.tempto.internal.configuration;
16 |
17 | import io.trino.tempto.configuration.Configuration;
18 |
19 | import java.util.Collections;
20 | import java.util.Optional;
21 | import java.util.Set;
22 |
23 | public class EmptyConfiguration
24 | extends AbstractConfiguration
25 | {
26 | private static final EmptyConfiguration INSTANCE = new EmptyConfiguration();
27 |
28 | public static Configuration emptyConfiguration()
29 | {
30 | return INSTANCE;
31 | }
32 |
33 | private EmptyConfiguration() {}
34 |
35 | @Override
36 | public Optional