> getRequirementsSets();
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/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-core/src/main/java/io/trino/tempto/RequirementsProvider.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.configuration.Configuration;
18 |
19 | @FunctionalInterface
20 | public interface RequirementsProvider
21 | {
22 | Requirement getRequirements(Configuration configuration);
23 | }
24 |
--------------------------------------------------------------------------------
/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/TemptoPlugin.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;
15 |
16 | import com.google.common.collect.ImmutableList;
17 | import io.trino.tempto.fulfillment.RequirementFulfiller;
18 | import io.trino.tempto.fulfillment.table.TableDefinition;
19 | import io.trino.tempto.fulfillment.table.TableManager;
20 | import io.trino.tempto.initialization.SuiteModuleProvider;
21 | import io.trino.tempto.initialization.TestMethodModuleProvider;
22 |
23 | import java.util.List;
24 |
25 | public interface TemptoPlugin
26 | {
27 | default List> getFulfillers()
28 | {
29 | return ImmutableList.of();
30 | }
31 |
32 | default List> getSuiteModules()
33 | {
34 | return ImmutableList.of();
35 | }
36 |
37 | default List> getTestModules()
38 | {
39 | return ImmutableList.of();
40 | }
41 |
42 | default List> getTableManagers()
43 | {
44 | return ImmutableList.of();
45 | }
46 |
47 | default List getTables()
48 | {
49 | return ImmutableList.of();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/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/assertions/ValueComparator.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.assertions;
15 |
16 | import java.util.function.BiPredicate;
17 |
18 | interface ValueComparator
19 | extends BiPredicate {}
20 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/configuration/KeyUtils.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.configuration;
16 |
17 | import com.google.common.base.Joiner;
18 | import com.google.common.base.Splitter;
19 |
20 | import java.util.List;
21 |
22 | import static com.google.common.collect.Lists.newArrayList;
23 | import static java.util.Arrays.asList;
24 |
25 | public final class KeyUtils
26 | {
27 | private KeyUtils() {}
28 |
29 | private static final char KEY_SEPARATOR = '.';
30 | private static final Splitter KEY_SPLITTER = Splitter.on(KEY_SEPARATOR);
31 | private static final Joiner KEY_JOINER = Joiner.on(KEY_SEPARATOR).skipNulls();
32 |
33 | public static List splitKey(String key)
34 | {
35 | return newArrayList(KEY_SPLITTER.split(key));
36 | }
37 |
38 | public static String joinKey(List keyParts)
39 | {
40 | return KEY_JOINER.join(keyParts);
41 | }
42 |
43 | public static String joinKey(String... keyParts)
44 | {
45 | return joinKey(asList(keyParts));
46 | }
47 |
48 | public static String getKeyPrefix(String key, int prefixLen)
49 | {
50 | List keyParts = splitKey(key);
51 | if (keyParts.size() <= prefixLen) {
52 | return key;
53 | }
54 | else {
55 | return KEY_JOINER.join(keyParts.subList(0, prefixLen));
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/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-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/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 |
--------------------------------------------------------------------------------
/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/context/TestContextCloseCallback.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 | @FunctionalInterface
18 | public interface TestContextCloseCallback
19 | {
20 | void testContextClosed(TestContext testContext);
21 | }
22 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/context/TestContextDsl.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.context;
15 |
16 | import io.trino.tempto.threads.IndexedRunnable;
17 |
18 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.popTestContext;
19 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.pushTestContext;
20 | import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContext;
21 |
22 | public final class TestContextDsl
23 | {
24 | public static IndexedRunnable withChildTestContext(IndexedRunnable runnable)
25 | {
26 | return (int threadIndex) -> {
27 | pushTestContext(testContext().createChildContext());
28 | try {
29 | runnable.run(threadIndex);
30 | }
31 | finally {
32 | popTestContext();
33 | }
34 | };
35 | }
36 |
37 | public static Runnable withChildTestContext(Runnable runnable)
38 | {
39 | return () -> runWithChildTestContext(runnable);
40 | }
41 |
42 | public static void runWithChildTestContext(Runnable runnable)
43 | {
44 | runWithTestContext(testContext().createChildContext(), runnable);
45 | }
46 |
47 | public static void runWithTestContext(TestContext testContext, Runnable runnable)
48 | {
49 | pushTestContext(testContext);
50 | try {
51 | runnable.run();
52 | }
53 | finally {
54 | popTestContext();
55 | }
56 | }
57 |
58 | private TestContextDsl()
59 | {
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/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/java/io/trino/tempto/fulfillment/TestStatus.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 | public enum TestStatus
18 | {
19 | SUCCESS, FAILURE;
20 | }
21 |
--------------------------------------------------------------------------------
/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/command/CommandRequirement.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 io.trino.tempto.Requirement;
18 |
19 | import java.util.List;
20 | import java.util.Objects;
21 |
22 | import static java.util.Objects.requireNonNull;
23 |
24 | public abstract class CommandRequirement
25 | implements Requirement
26 | {
27 | private final List setupCommands;
28 |
29 | public CommandRequirement(List setupCommands)
30 | {
31 | this.setupCommands = requireNonNull(setupCommands, "setupCommands is null");
32 | }
33 |
34 | public List getSetupCommands()
35 | {
36 | return setupCommands;
37 | }
38 |
39 | @Override
40 | public String toString()
41 | {
42 | return "CommandRequirement{" +
43 | "setupCommands=" + setupCommands +
44 | '}';
45 | }
46 |
47 | @Override
48 | public boolean equals(Object o)
49 | {
50 | if (this == o) { return true; }
51 | if (o == null || getClass() != o.getClass()) { return false; }
52 | CommandRequirement that = (CommandRequirement) o;
53 | return Objects.equals(setupCommands, that.setupCommands);
54 | }
55 |
56 | @Override
57 | public int hashCode()
58 | {
59 | return Objects.hash(setupCommands);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/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/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/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-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/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/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/java/io/trino/tempto/fulfillment/table/TableInstance.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 io.trino.tempto.internal.fulfillment.table.TableName;
17 |
18 | import java.util.Optional;
19 |
20 | import static java.util.Objects.requireNonNull;
21 |
22 | /**
23 | * Describes a table that is instantiated during a test run.
24 | */
25 | public class TableInstance
26 | {
27 | private final TableName name;
28 | private final T tableDefinition;
29 |
30 | protected TableInstance(TableName name, T tableDefinition)
31 | {
32 | this.name = requireNonNull(name, "name is null");
33 | this.tableDefinition = requireNonNull(tableDefinition, "tableDefinition is null");
34 | }
35 |
36 | public String getName()
37 | {
38 | return name.getName();
39 | }
40 |
41 | public String getDatabase()
42 | {
43 | return name.getDatabase();
44 | }
45 |
46 | public Optional getSchema()
47 | {
48 | return name.getSchema();
49 | }
50 |
51 | public String getNameInDatabase()
52 | {
53 | return name.getNameInDatabase();
54 | }
55 |
56 | public T tableDefinition()
57 | {
58 | return tableDefinition;
59 | }
60 |
61 | public TableName getTableName()
62 | {
63 | return name;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/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/fulfillment/table/TableRequirement.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 io.trino.tempto.Requirement;
18 |
19 | import static java.util.Objects.requireNonNull;
20 | import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals;
21 | import static org.apache.commons.lang3.builder.HashCodeBuilder.reflectionHashCode;
22 |
23 | public abstract class TableRequirement
24 | implements Requirement
25 | {
26 | private final TableDefinition tableDefinition;
27 | private final TableHandle tableHandle;
28 |
29 | protected TableRequirement(TableDefinition tableDefinition, TableHandle tableHandle)
30 | {
31 | this.tableDefinition = requireNonNull(tableDefinition, "tableDefinition is null");
32 | this.tableHandle = requireNonNull(tableHandle, "tableHandle is null");
33 | }
34 |
35 | public TableDefinition getTableDefinition()
36 | {
37 | return tableDefinition;
38 | }
39 |
40 | public TableHandle getTableHandle()
41 | {
42 | return tableHandle;
43 | }
44 |
45 | public abstract T copyWithDatabase(String databaseName);
46 |
47 | @Override
48 | public boolean equals(Object o)
49 | {
50 | return reflectionEquals(this, o);
51 | }
52 |
53 | @Override
54 | public int hashCode()
55 | {
56 | return reflectionHashCode(this);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/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/fulfillment/table/hive/statistics/ColumnStatistics.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 |
20 | import java.util.Optional;
21 |
22 | import static java.util.Objects.requireNonNull;
23 |
24 | public class ColumnStatistics
25 | {
26 | private final long distinctValuesCount;
27 | private final long nullsCount;
28 | private final Optional min;
29 | private final Optional max;
30 |
31 | @JsonCreator
32 | public ColumnStatistics(
33 | @JsonProperty("distinctValuesCount") long distinctValuesCount,
34 | @JsonProperty("nullsCount") long nullsCount,
35 | @JsonProperty("min") Optional min,
36 | @JsonProperty("max") Optional max)
37 | {
38 | this.distinctValuesCount = distinctValuesCount;
39 | this.nullsCount = nullsCount;
40 | this.min = requireNonNull(min);
41 | this.max = requireNonNull(max);
42 | }
43 |
44 | public long getDistinctValuesCount()
45 | {
46 | return distinctValuesCount;
47 | }
48 |
49 | public long getNullsCount()
50 | {
51 | return nullsCount;
52 | }
53 |
54 | public Optional getMin()
55 | {
56 | return min;
57 | }
58 |
59 | public Optional getMax()
60 | {
61 | return max;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/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/main/java/io/trino/tempto/fulfillment/table/hive/statistics/TableStatisticsRepository.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.databind.ObjectMapper;
18 | import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
19 |
20 | import java.net.URL;
21 |
22 | import static com.google.common.base.Preconditions.checkState;
23 | import static java.lang.String.format;
24 | import static java.util.Locale.ENGLISH;
25 |
26 | public class TableStatisticsRepository
27 | {
28 | private final ObjectMapper objectMapper = new ObjectMapper()
29 | .registerModule(new Jdk8Module());
30 |
31 | public TableStatistics load(String benchmark, double scaleFactor, String table)
32 | {
33 | String schema = schema(scaleFactor);
34 | String resourcePath = "/statistics/" + benchmark.toLowerCase(ENGLISH) + "/" + schema + "/" + table.toLowerCase(ENGLISH) + ".json";
35 | URL resource = getClass().getResource(resourcePath);
36 | checkState(resource != null, "Unable to find statistics data file, trying with: %s", resourcePath);
37 | try {
38 | return objectMapper.readValue(resource, TableStatistics.class);
39 | }
40 | catch (Exception e) {
41 | throw new RuntimeException(format("Failed to parse stats from resource [%s]", resourcePath), e);
42 | }
43 | }
44 |
45 | private String schema(double scaleFactor)
46 | {
47 | return ("sf" + scaleFactor).replaceAll("\\.0*$", "");
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/fulfillment/table/hive/tpcds/TpcdsTable.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.tpcds;
16 |
17 | import io.trino.tpcds.Table;
18 |
19 | /**
20 | * Enum containing names of all TPCDS tables. Moreover it holds reference to
21 | * {@link Table} entity which is used for generating data.
22 | */
23 | public enum TpcdsTable
24 | {
25 | CATALOG_SALES(Table.CATALOG_SALES),
26 | CALL_CENTER(Table.CALL_CENTER),
27 | CATALOG_PAGE(Table.CATALOG_PAGE),
28 | CATALOG_RETURNS(Table.CATALOG_RETURNS),
29 | CUSTOMER(Table.CUSTOMER),
30 | CUSTOMER_ADDRESS(Table.CUSTOMER_ADDRESS),
31 | CUSTOMER_DEMOGRAPHICS(Table.CUSTOMER_DEMOGRAPHICS),
32 | DATE_DIM(Table.DATE_DIM),
33 | HOUSEHOLD_DEMOGRAPHICS(Table.HOUSEHOLD_DEMOGRAPHICS),
34 | INCOME_BAND(Table.INCOME_BAND),
35 | INVENTORY(Table.INVENTORY),
36 | ITEM(Table.ITEM),
37 | PROMOTION(Table.PROMOTION),
38 | REASON(Table.REASON),
39 | SHIP_MODE(Table.SHIP_MODE),
40 | STORE(Table.STORE),
41 | STORE_RETURNS(Table.STORE_RETURNS),
42 | STORE_SALES(Table.STORE_SALES),
43 | TIME_DIM(Table.TIME_DIM),
44 | WAREHOUSE(Table.WAREHOUSE),
45 | WEB_PAGE(Table.WEB_PAGE),
46 | WEB_RETURNS(Table.WEB_RETURNS),
47 | WEB_SALES(Table.WEB_SALES),
48 | WEB_SITE(Table.WEB_SITE);
49 |
50 | private final Table table;
51 |
52 | TpcdsTable(Table table)
53 | {
54 | this.table = table;
55 | }
56 |
57 | public Table getTable()
58 | {
59 | return table;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/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/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/fulfillment/table/jdbc/tpch/JdbcTpchTableDefinitions.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.tpch;
16 |
17 | import com.google.common.collect.ImmutableList;
18 | import io.trino.tempto.fulfillment.table.hive.tpch.TpchTable;
19 | import io.trino.tempto.fulfillment.table.jdbc.RelationalTableDefinition;
20 |
21 | import java.sql.JDBCType;
22 |
23 | import static io.trino.tempto.fulfillment.table.jdbc.RelationalTableDefinition.relationalTableDefinition;
24 | import static java.sql.JDBCType.BIGINT;
25 | import static java.sql.JDBCType.VARCHAR;
26 |
27 | public class JdbcTpchTableDefinitions
28 | {
29 | public static final double DEFAULT_SCALE_FACTOR = 0.01;
30 | public static final ImmutableList NATION_TYPES = ImmutableList.of(BIGINT, VARCHAR, BIGINT, VARCHAR);
31 |
32 | public static final RelationalTableDefinition NATION =
33 | relationalTableDefinition("nation_jdbc",
34 | "CREATE TABLE %NAME%(" +
35 | " n_nationkey BIGINT," +
36 | " n_name VARCHAR(25)," +
37 | " n_regionkey BIGINT," +
38 | " n_comment VARCHAR(152)) ", new JdbcTpchDataSource(TpchTable.NATION, NATION_TYPES, DEFAULT_SCALE_FACTOR));
39 |
40 | private JdbcTpchTableDefinitions() {}
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/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/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/internal/ReflectionHelper.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;
16 |
17 | import java.util.Collection;
18 | import java.util.List;
19 |
20 | import static java.util.stream.Collectors.toList;
21 |
22 | public final class ReflectionHelper
23 | {
24 | public static List extends T> instantiate(Collection> classes)
25 | {
26 | return classes
27 | .stream()
28 | .map(ReflectionHelper::instantiate)
29 | .collect(toList());
30 | }
31 |
32 | public static T instantiate(String className)
33 | {
34 | try {
35 | return instantiate((Class) Class.forName(className));
36 | }
37 | catch (ClassNotFoundException e) {
38 | throw new RuntimeException("Unable to find specified class: " + className, e);
39 | }
40 | }
41 |
42 | public static T instantiate(Class extends T> clazz)
43 | {
44 | try {
45 | return clazz.newInstance();
46 | }
47 | catch (InstantiationException | IllegalAccessException e) {
48 | throw new RuntimeException(e);
49 | }
50 | }
51 |
52 | private ReflectionHelper()
53 | {
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/RequirementsCollector.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;
16 |
17 | import io.trino.tempto.CompositeRequirement;
18 |
19 | import java.lang.reflect.Method;
20 |
21 | public interface RequirementsCollector
22 | {
23 | CompositeRequirement collect(Method method);
24 | }
25 |
--------------------------------------------------------------------------------
/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 get(String key)
37 | {
38 | return Optional.empty();
39 | }
40 |
41 | @Override
42 | public Set listKeys()
43 | {
44 | return Collections.emptySet();
45 | }
46 |
47 | @Override
48 | public Set listPrefixes()
49 | {
50 | return Collections.emptySet();
51 | }
52 |
53 | @Override
54 | public Configuration getSubconfiguration(String keyPrefix)
55 | {
56 | return emptyConfiguration();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/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/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/internal/convention/ConventionRequirements.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 | public final class ConventionRequirements
18 | {
19 | private ConventionRequirements()
20 | {
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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/internal/convention/ProcessUtils.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 java.io.IOException;
17 | import java.util.function.Consumer;
18 |
19 | import static com.google.common.base.Preconditions.checkState;
20 |
21 | public final class ProcessUtils
22 | {
23 | private static final int SUCCESS_EXIT_CODE = 0;
24 |
25 | public static void execute(String... cmdarray)
26 | {
27 | execute(process -> {}, cmdarray);
28 | }
29 |
30 | public static void execute(Consumer processConsumer, String... cmdarray)
31 | {
32 | checkState(cmdarray.length > 0);
33 |
34 | try {
35 | Process process = Runtime.getRuntime().exec(cmdarray);
36 | processConsumer.accept(process);
37 | process.waitFor();
38 | checkState(process.exitValue() == SUCCESS_EXIT_CODE, "%s exited with status code: %s", cmdarray[0], process.exitValue());
39 | }
40 | catch (IOException | InterruptedException e) {
41 | throw new RuntimeException(e);
42 | }
43 | }
44 |
45 | private ProcessUtils()
46 | {
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/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/convention/tabledefinitions/FileBasedRelationalDataSource.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.tabledefinitions;
16 |
17 | import io.trino.tempto.fulfillment.table.jdbc.RelationalDataSource;
18 |
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | import static com.google.common.base.Preconditions.checkNotNull;
23 | import static io.trino.tempto.internal.convention.tabledefinitions.JdbcDataFileDescriptor.sqlResultDescriptorFor;
24 | import static java.util.Collections.emptyIterator;
25 |
26 | public class FileBasedRelationalDataSource
27 | implements RelationalDataSource
28 | {
29 | private final ConventionTableDefinitionDescriptor tableDefinitionDescriptor;
30 |
31 | public FileBasedRelationalDataSource(ConventionTableDefinitionDescriptor tableDefinitionDescriptor)
32 | {
33 | this.tableDefinitionDescriptor = checkNotNull(tableDefinitionDescriptor, "tableDefinitionDescriptor is null");
34 | }
35 |
36 | @Override
37 | public Iterator> getDataRows()
38 | {
39 | return tableDefinitionDescriptor.getDataFile()
40 | .map(dataFile -> sqlResultDescriptorFor(dataFile).getRows().iterator())
41 | .orElse(emptyIterator());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/internal/convention/tabledefinitions/TableType.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.tabledefinitions;
16 |
17 | /**
18 | * Table types supported by convention based table definitions
19 | */
20 | public enum TableType
21 | {
22 | HIVE,
23 | JDBC
24 | }
25 |
--------------------------------------------------------------------------------
/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/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/resources/ResourcesState.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 com.google.common.io.Closer;
17 | import io.trino.tempto.context.State;
18 |
19 | import java.io.IOException;
20 | import java.io.UncheckedIOException;
21 |
22 | public abstract class ResourcesState
23 | implements State, AutoCloseable
24 | {
25 | private final Closer closer = Closer.create();
26 |
27 | public T register(T resource)
28 | {
29 | closer.register(() -> {
30 | try {
31 | resource.close();
32 | }
33 | catch (InterruptedException e) {
34 | Thread.currentThread().interrupt();
35 | throw new RuntimeException(e);
36 | }
37 | catch (Exception e) {
38 | throw new RuntimeException(e);
39 | }
40 | });
41 | return resource;
42 | }
43 |
44 | @Override
45 | public void close()
46 | {
47 | try {
48 | closer.close();
49 | }
50 | catch (IOException e) {
51 | throw new UncheckedIOException(e);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/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/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/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/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/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/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/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/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-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/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/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/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/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/java/io/trino/tempto/internal/initialization/modules/TestMethodInfoModuleProvider.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.initialization.modules;
15 |
16 | import com.google.inject.AbstractModule;
17 | import com.google.inject.Module;
18 | import io.trino.tempto.configuration.Configuration;
19 | import io.trino.tempto.initialization.TestMethodModuleProvider;
20 | import io.trino.tempto.internal.listeners.TestMetadata;
21 | import io.trino.tempto.internal.listeners.TestMetadataReader;
22 | import org.testng.ITestResult;
23 |
24 | public class TestMethodInfoModuleProvider
25 | implements TestMethodModuleProvider
26 | {
27 | private final TestMetadataReader testMetadataReader = new TestMetadataReader();
28 |
29 | public Module getModule(Configuration configuration, ITestResult testResult)
30 | {
31 | TestMetadata testMetadata = testMetadataReader.readTestMetadata(testResult);
32 | return new AbstractModule()
33 | {
34 | @Override
35 | protected void configure()
36 | {
37 | bind(TestMetadata.class).toInstance(testMetadata);
38 | }
39 | };
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/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-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/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/process/JavaProcessLauncher.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.process;
15 |
16 | import com.google.common.collect.ImmutableList;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 | import java.util.List;
21 |
22 | /**
23 | * Launches a Java class with main() method as a separate process.
24 | */
25 | public final class JavaProcessLauncher
26 | {
27 | private final String javaBin;
28 | private final String classpath;
29 |
30 | public static JavaProcessLauncher defaultJavaProcessLauncher()
31 | {
32 | return new JavaProcessLauncher(
33 | System.getProperty("java.home") + File.separator + "bin" + File.separator + "java",
34 | System.getProperty("java.class.path")
35 | );
36 | }
37 |
38 | public JavaProcessLauncher(String javaBin, String classpath)
39 | {
40 | this.javaBin = javaBin;
41 | this.classpath = classpath;
42 | }
43 |
44 | public Process launch(Class clazz, List arguments)
45 | throws IOException
46 | {
47 | String className = clazz.getCanonicalName();
48 | List command = ImmutableList.builder()
49 | .add(javaBin, "-cp", classpath, className)
50 | .addAll(arguments)
51 | .build();
52 | return new ProcessBuilder(command).start();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/process/TimeoutRuntimeException.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 TimeoutRuntimeException
18 | extends RuntimeException
19 | {
20 | public TimeoutRuntimeException(String msg)
21 | {
22 | super(msg);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/query/QueryExecutionException.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.query;
16 |
17 | public class QueryExecutionException
18 | extends RuntimeException
19 | {
20 | public QueryExecutionException(Throwable e)
21 | {
22 | super(e);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tempto-core/src/main/java/io/trino/tempto/query/QueryExecutorDispatcher.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.query;
15 |
16 | public interface QueryExecutorDispatcher
17 | {
18 | QueryExecutor getQueryExecutor(String connectionName);
19 | }
20 |
--------------------------------------------------------------------------------
/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/ssh/SshClient.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.ssh;
15 |
16 | import com.google.common.base.Joiner;
17 | import io.trino.tempto.process.CliProcess;
18 |
19 | import java.io.Closeable;
20 | import java.io.IOException;
21 | import java.nio.file.Path;
22 | import java.util.List;
23 |
24 | /**
25 | * Simple SSH client.
26 | */
27 | public interface SshClient
28 | extends Closeable
29 | {
30 | default String command(String command)
31 | {
32 | try (CliProcess cliProcess = execute(command)) {
33 | String output = Joiner.on("\n").join(cliProcess.readRemainingOutputLines());
34 | cliProcess.waitForWithTimeoutAndKill();
35 | return output;
36 | }
37 | catch (IOException | InterruptedException e) {
38 | throw new RuntimeException(e);
39 | }
40 | }
41 |
42 | /**
43 | * Executes command on a remote machine.
44 | *
45 | * @param command Command to be executed on remote machine.
46 | * @return CLIProcess
47 | */
48 | CliProcess execute(String command);
49 |
50 | CliProcess execute(List command);
51 |
52 | /**
53 | * Uploads file to a remote machine. It works like SCP.
54 | *
55 | * @param file Local path to file which is to be uploaded
56 | * @param remotePath Destination path for file on remote machine.
57 | */
58 | void upload(Path file, String remotePath);
59 | }
60 |
--------------------------------------------------------------------------------
/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/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/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-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-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/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/META-INF/services/io.trino.tempto.TemptoPlugin:
--------------------------------------------------------------------------------
1 | io.trino.tempto.internal.initialization.TemptoBuiltins
2 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor:
--------------------------------------------------------------------------------
1 | io.trino.tempto.dns.TemptoNameServiceDescriptor
2 |
--------------------------------------------------------------------------------
/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/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/resources/statistics/tpcds/sf1/dbgen_version.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 1,
3 | "columns": {
4 | "dv_version": {
5 | "distinctValuesCount": 1,
6 | "nullsCount": 0,
7 | "min": "2.0.0",
8 | "max": "2.0.0"
9 | },
10 | "dv_create_date": {
11 | "distinctValuesCount": 1,
12 | "nullsCount": 0,
13 | "min": 17381,
14 | "max": 17381
15 | },
16 | "dv_create_time": {
17 | "distinctValuesCount": 1,
18 | "nullsCount": 0,
19 | "min": 78548000,
20 | "max": 78548000
21 | },
22 | "dv_cmdline_args": {
23 | "distinctValuesCount": 1,
24 | "nullsCount": 0,
25 | "min": "",
26 | "max": ""
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/household_demographics.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 7200,
3 | "columns": {
4 | "hd_demo_sk": {
5 | "distinctValuesCount": 7200,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 7200
9 | },
10 | "hd_income_band_sk": {
11 | "distinctValuesCount": 20,
12 | "nullsCount": 0,
13 | "min": 1,
14 | "max": 20
15 | },
16 | "hd_buy_potential": {
17 | "distinctValuesCount": 6,
18 | "nullsCount": 0,
19 | "min": "0-500",
20 | "max": "Unknown"
21 | },
22 | "hd_dep_count": {
23 | "distinctValuesCount": 10,
24 | "nullsCount": 0,
25 | "min": 0,
26 | "max": 9
27 | },
28 | "hd_vehicle_count": {
29 | "distinctValuesCount": 6,
30 | "nullsCount": 0,
31 | "min": -1,
32 | "max": 4
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/income_band.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 20,
3 | "columns": {
4 | "ib_income_band_sk": {
5 | "distinctValuesCount": 20,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 20
9 | },
10 | "ib_lower_bound": {
11 | "distinctValuesCount": 20,
12 | "nullsCount": 0,
13 | "min": 0,
14 | "max": 190001
15 | },
16 | "ib_upper_bound": {
17 | "distinctValuesCount": 20,
18 | "nullsCount": 0,
19 | "min": 10000,
20 | "max": 200000
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/inventory.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 11745000,
3 | "columns": {
4 | "inv_date_sk": {
5 | "distinctValuesCount": 261,
6 | "nullsCount": 0,
7 | "min": 2450815,
8 | "max": 2452635
9 | },
10 | "inv_item_sk": {
11 | "distinctValuesCount": 18000,
12 | "nullsCount": 0,
13 | "min": 1,
14 | "max": 18000
15 | },
16 | "inv_warehouse_sk": {
17 | "distinctValuesCount": 5,
18 | "nullsCount": 0,
19 | "min": 1,
20 | "max": 5
21 | },
22 | "inv_quantity_on_hand": {
23 | "distinctValuesCount": 1001,
24 | "nullsCount": 586913,
25 | "min": 0,
26 | "max": 1000
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tempto-core/src/main/resources/statistics/tpcds/sf1/reason.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 35,
3 | "columns": {
4 | "r_reason_sk": {
5 | "distinctValuesCount": 35,
6 | "nullsCount": 0,
7 | "min": 1,
8 | "max": 35
9 | },
10 | "r_reason_id": {
11 | "distinctValuesCount": 35,
12 | "nullsCount": 0,
13 | "min": "AAAAAAAAABAAAAAA",
14 | "max": "AAAAAAAAPBAAAAAA"
15 | },
16 | "r_reason_desc": {
17 | "distinctValuesCount": 34,
18 | "nullsCount": 0,
19 | "min": "Did not fit",
20 | "max": "unauthoized purchase"
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/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/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/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/resources/statistics/tpch/sf1/nation.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 25,
3 | "columns": {
4 | "n_nationkey": {
5 | "distinctValuesCount": 25,
6 | "nullsCount": 0,
7 | "min": 0,
8 | "max": 24
9 | },
10 | "n_name": {
11 | "distinctValuesCount": 25,
12 | "nullsCount": 0,
13 | "min": "ALGERIA",
14 | "max": "VIETNAM"
15 | },
16 | "n_regionkey": {
17 | "distinctValuesCount": 5,
18 | "nullsCount": 0,
19 | "min": 0,
20 | "max": 4
21 | },
22 | "n_comment": {
23 | "distinctValuesCount": 25,
24 | "nullsCount": 0,
25 | "min": " haggle. carefully final deposits detect slyly agai",
26 | "max": "y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be"
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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/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/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/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/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/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/resources/statistics/tpch/sf1/region.json:
--------------------------------------------------------------------------------
1 | {
2 | "rowCount": 5,
3 | "columns": {
4 | "r_regionkey": {
5 | "distinctValuesCount": 5,
6 | "nullsCount": 0,
7 | "min": 0,
8 | "max": 4
9 | },
10 | "r_name": {
11 | "distinctValuesCount": 5,
12 | "nullsCount": 0,
13 | "min": "AFRICA",
14 | "max": "MIDDLE EAST"
15 | },
16 | "r_comment": {
17 | "distinctValuesCount": 5,
18 | "nullsCount": 0,
19 | "min": "ges. thinly even pinto beans ca",
20 | "max": "uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl"
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/test/groovy/io/trino/tempto/fulfillment/table/hive/tpcds/TpcdsDataSourceTest.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.tpcds;
16 |
17 | import io.trino.tempto.fulfillment.table.hive.statistics.ColumnStatistics;
18 | import io.trino.tempto.fulfillment.table.hive.statistics.TableStatistics;
19 | import org.junit.jupiter.api.Test;
20 |
21 | import static org.junit.jupiter.api.Assertions.assertEquals;
22 | import static org.junit.jupiter.api.Assertions.assertTrue;
23 |
24 | public class TpcdsDataSourceTest
25 | {
26 | @Test
27 | public void testStatistics()
28 | {
29 | TpcdsDataSource callCenterDataSource = new TpcdsDataSource(TpcdsTable.CALL_CENTER, 1);
30 |
31 | assertTrue(callCenterDataSource.getStatistics().isPresent());
32 |
33 | TableStatistics nationStatistics = callCenterDataSource.getStatistics().get();
34 | assertEquals(nationStatistics.getRowCount(), 6);
35 |
36 | ColumnStatistics nameStatistics = nationStatistics.getColumns().get("cc_name");
37 | assertEquals(nameStatistics.getNullsCount(), 0);
38 | assertEquals(nameStatistics.getDistinctValuesCount(), 3);
39 | assertEquals(nameStatistics.getMin().get(), "Mid Atlantic");
40 | assertEquals(nameStatistics.getMax().get(), "North Midwest");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/fulfillment/table/hive/tpch/TpchDataSourceTest.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.hive.tpch;
15 |
16 | import io.trino.tempto.fulfillment.table.hive.statistics.ColumnStatistics;
17 | import io.trino.tempto.fulfillment.table.hive.statistics.TableStatistics;
18 | import org.junit.jupiter.api.Test;
19 |
20 | import static org.junit.jupiter.api.Assertions.assertEquals;
21 | import static org.junit.jupiter.api.Assertions.assertTrue;
22 |
23 | public class TpchDataSourceTest
24 | {
25 | @Test
26 | public void testStatistics()
27 | {
28 | TpchDataSource nationDataSource = new TpchDataSource(TpchTable.NATION, 1);
29 |
30 | assertTrue(nationDataSource.getStatistics().isPresent());
31 |
32 | TableStatistics nationStatistics = nationDataSource.getStatistics().get();
33 | assertEquals(nationStatistics.getRowCount(), 25);
34 |
35 | ColumnStatistics nationkeyStatistics = nationStatistics.getColumns().get("n_nationkey");
36 | assertEquals(nationkeyStatistics.getNullsCount(), 0);
37 | assertEquals(nationkeyStatistics.getDistinctValuesCount(), 25);
38 | assertEquals(nationkeyStatistics.getMin().get(), 0);
39 | assertEquals(nationkeyStatistics.getMax().get(), 24);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/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-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/test/groovy/io/trino/tempto/internal/query/QueryRowMapperTest.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.internal.query
15 |
16 | import com.google.common.collect.ImmutableList
17 | import spock.lang.Specification
18 | import spock.lang.Unroll
19 |
20 | import java.sql.JDBCType
21 |
22 | class QueryRowMapperTest
23 | extends Specification
24 | {
25 | @Unroll
26 | def 'convert binary #value'()
27 | {
28 | setup:
29 | QueryRowMapper rowMapper = new QueryRowMapper(ImmutableList.of(JDBCType.BINARY))
30 |
31 | expect:
32 | rowMapper.mapToRow(ImmutableList.of(value)).getValues()[0] == expected
33 |
34 | where:
35 | value | expected
36 | '0000' | bytes(0x00, 0x00)
37 | '0ab0' | bytes(0x0a, 0xb0)
38 | }
39 |
40 | def 'should fail when incorrect hex'()
41 | {
42 | setup:
43 | QueryRowMapper rowMapper = new QueryRowMapper(ImmutableList.of(JDBCType.BINARY))
44 |
45 | when:
46 | rowMapper.mapToRow(ImmutableList.of('1a0'))
47 |
48 | then:
49 | thrown(IllegalArgumentException)
50 | }
51 |
52 | private byte[] bytes(int ... bytes)
53 | {
54 | return bytes
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/tempto-core/src/test/groovy/io/trino/tempto/internal/ssh/TestCommand.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.internal.ssh
15 |
16 | import org.apache.sshd.server.Command
17 | import org.apache.sshd.server.Environment
18 | import org.apache.sshd.server.ExitCallback
19 |
20 | class TestCommand
21 | implements Command
22 | {
23 | private final String response;
24 | private final int errorCode;
25 |
26 | private InputStream input;
27 | private OutputStream output;
28 | private OutputStream error;
29 | private ExitCallback callback;
30 |
31 | TestCommand(String response, int errorCode)
32 | {
33 | this.response = response;
34 | this.errorCode = errorCode;
35 | }
36 |
37 | void setInputStream(InputStream input)
38 | {
39 | this.input = input;
40 | }
41 |
42 | void setOutputStream(OutputStream out)
43 | {
44 | this.output = out;
45 | }
46 |
47 | void setErrorStream(OutputStream err)
48 | {
49 | this.error = err;
50 | }
51 |
52 | void setExitCallback(ExitCallback callback)
53 | {
54 | this.callback = callback;
55 | }
56 |
57 | void start(Environment env)
58 | throws IOException
59 | {
60 | output.write(response.getBytes());
61 | output.flush();
62 | callback.onExit(errorCode, response);
63 | }
64 |
65 | void destroy()
66 | {
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/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-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/test/groovy/io/trino/tempto/sql/view/ContextDslTest.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.sql.view
16 |
17 | import io.trino.tempto.context.ContextDsl
18 | import io.trino.tempto.context.ContextRunnable
19 | import io.trino.tempto.query.QueryExecutor
20 | import io.trino.tempto.query.QueryResult
21 | import spock.lang.Specification
22 |
23 | import static io.trino.tempto.internal.configuration.TestConfigurationFactory.TEST_CONFIGURATION_URIS_KEY
24 |
25 | class ContextDslTest
26 | extends Specification
27 | {
28 | def setupSpec()
29 | {
30 | System.setProperty(TEST_CONFIGURATION_URIS_KEY, "/configuration/global-configuration-tempto.yaml");
31 | }
32 |
33 | def 'executeWithView'()
34 | {
35 | setup:
36 | String viewName = "test_view";
37 | String selectSql = "SELECT * FROM nation"
38 | ContextRunnable testRunnable = Mock(ContextRunnable)
39 | QueryExecutor queryExecutor = Mock(QueryExecutor)
40 | queryExecutor.executeQuery("DROP VIEW test_view") >> QueryResult.forSingleIntegerValue(1)
41 | queryExecutor.executeQuery("CREATE VIEW test_view AS SELECT * FROM nation") >> QueryResult.forSingleIntegerValue(1)
42 | queryExecutor.executeQuery("DROP VIEW test_view") >> QueryResult.forSingleIntegerValue(1)
43 |
44 | ViewContextProvider contextProvider = new ViewContextProvider(viewName, selectSql, queryExecutor)
45 |
46 | when:
47 | ContextDsl.executeWith(contextProvider, testRunnable)
48 |
49 | then:
50 | 1 * testRunnable.run(_)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/tempto-core/src/test/resources/configuration/global-configuration-tempto.yaml:
--------------------------------------------------------------------------------
1 | value:
2 | default: ${not.exisiting.key:-default_value}
3 | both: global
4 | global: global
5 | "with.dot": 1
6 |
7 | resolve:
8 | both: ${value.both}
9 | global: ${value.global}
10 | local: ${value.local}
11 |
--------------------------------------------------------------------------------
/tempto-core/src/test/resources/configuration/local-configuration-tempto.yaml:
--------------------------------------------------------------------------------
1 | value:
2 | both: local
3 | local: local
4 |
--------------------------------------------------------------------------------
/tempto-core/src/test/resources/convention/sample-test/query1.result:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trinodb/tempto/4ab8a3b662ff1d40d01d72ca410de963e7f0fa11/tempto-core/src/test/resources/convention/sample-test/query1.result
--------------------------------------------------------------------------------
/tempto-core/src/test/resources/convention/sample-test/query1.sql:
--------------------------------------------------------------------------------
1 | -- groups: tpch,quarantine
--------------------------------------------------------------------------------
/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/test/resources/ssh/ssh.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEpQIBAAKCAQEAqACaXCACnn8FmwklRVq56p/PgEAPbt5NbXDzKxmHtqbzkvPL
3 | UJZIaeCrvjbAUxj8mrl2LqYIsPTAIhmzWL08XjVpBRVSbNemYPJ6P28IN699qjmw
4 | 9SSqRZXahRni7hhFwGZfAQJool9dbxGycEbGTmwOmSZB07l3yKBlJffSys0jSzTz
5 | Hnz0ZA50aVNGfs2nIPY4JFpJmn5MDYjT4naH6eJ/TPws6+BjyGwrkgSTlmE/E6Fi
6 | UeJyDhdSV0OLeL+pHH1/LAWy1XrOZXEYgRfxTP51tBRqSsL431aQVEV3p8AFmyzu
7 | LtoyqhkZlkhpnNiEoK/Es/8yGl1tw1NwtZXLtQIDAQABAoIBAQCds8syNT4gJ95M
8 | NR6OZubkblVq7zdNfFG0LPWmfJWfiEJWrJEquZeKA8NTj7OjjW35k6Rzj5nS+jyt
9 | BfELmL9lM7+8bNJtp1Tf5l2I1CIjm5FbzEHnLB7FqTByBuW1WIWJYM9HdEpiOSDM
10 | 1RDqQhV+ogJmErpyE8R0SNQJ+wMdKEPd8OO8ClPEMz+EJNZhPFI/N/eLlzFdkWBX
11 | FW4MUNO1kzH+y14UB/PK0ndkLQMRLNPFLEHUM45wWPhMwqaKNYazL3iWMw/4ysnS
12 | vP6j59ZJL6uGYlk/CZJpx9WPRc8R6bBd6SFYdsRdY36xLhYSy+xsXM2M024w5OuC
13 | ZSlr2jE1AoGBANGKCfccNBQZW6brkqENzGrocv4V2mM8w/IS9j9Xx2IxjSn7XHDB
14 | XE1SVSXbTxKRghTNyp7Ke0EDnBn8hDjAZ+kj+6T7SEE6a88dn0Cvg5QG0s4XM6m0
15 | fubOMclVnGbf0Ja50qnUgShvpMFqNZI6rOVuu5BOuXBWY07jotx/im3TAoGBAM1A
16 | 1GwMab42a5huzKhlSa113KvMuylOWUoGzKrheAwY30H6Iovo6JWR0vNcEMb7glwU
17 | YJ2eD1KdZigyfKDjB37AaoiCYM/qCYXCdWbo/Caj3NyGEf6jj+NL5XDQP2qog6IQ
18 | 7lea1/TmpFlZ5iB/j9Et/t3Hg06N0jqB/aOTGwNXAoGBAJQdBABFUlamug9aUzI+
19 | o7EqECakYdNl34fceW266XfyWLtFL0mQlGMfgIqa4+DXM+Dqun/V1pvVJmGECh5n
20 | esvkoHs1GBTra8tiP/CkX9ihnh8JbX5W1KDnPW/4cO6S5Em2nj9ns8hWalpBbg6o
21 | JRCkXjaaPyA2IEpiQ/uit8H7AoGAVB858H616AuN1Y+zuWCp7bnck1z5aFiAJ+LZ
22 | hz+ZX/vhpLzL4+O1T3fQqYUWKzdxmiOP5YmeZhG0iM0IXzgtHjnmb8RfwVb+SCAG
23 | 1gKvNXb7UjZwsZh/pHy6sJ3pH+Go8YdW5/jCgdD1ktlRhAhD/UuIpYTbwBpIC0qz
24 | lZL5A0kCgYEAq5DTU6hI4J1OaGKzNMKl5M3Stu9rstjtAVxu3HTt9/+OSA4Q7a6n
25 | fIt22PcLwQKJ9/DUGTT2r9BdPRwe0d2H45slBN0SelY4u9WUcKSfYRvEGMvrI2n1
26 | 8POWoOlZKLMFs2xtqO+SnErU4cUAhL09r+Ppinak4LYP5kBI0VRVpvc=
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/tempto-core/src/test/resources/ssh/ssh.pub:
--------------------------------------------------------------------------------
1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoAJpcIAKefwWbCSVFWrnqn8+AQA9u3k1tcPMrGYe2pvOS88tQlkhp4Ku+NsBTGPyauXYupgiw9MAiGbNYvTxeNWkFFVJs16Zg8no/bwg3r32qObD1JKpFldqFGeLuGEXAZl8BAmiiX11vEbJwRsZObA6ZJkHTuXfIoGUl99LKzSNLNPMefPRkDnRpU0Z+zacg9jgkWkmafkwNiNPidofp4n9M/Czr4GPIbCuSBJOWYT8ToWJR4nIOF1JXQ4t4v6kcfX8sBbLVes5lcRiBF/FM/nW0FGpKwvjfVpBURXenwAWbLO4u2jKqGRmWSGmc2ISgr8Sz/zIaXW3DU3C1lcu1 kogut@haxu
2 |
--------------------------------------------------------------------------------
/tempto-examples/docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 | services:
3 | hadoop-master:
4 | hostname: hadoop-master
5 | image: 'ghcr.io/trinodb/testing/hdp2.6-hive:53'
6 | ports:
7 | - '1080:1080'
8 | - '8020:8020'
9 | - '8088:8088'
10 | - '9083:9083'
11 | - '10000:10000'
12 | - '50070:50070'
13 | - '50075:50075'
14 |
15 | psql1:
16 | hostname: psql1
17 | image: 'postgres:13.4'
18 | ports:
19 | - '15432:5432'
20 | environment:
21 | POSTGRES_USER: blah
22 | POSTGRES_PASSWORD: blah
23 |
24 | psql2:
25 | hostname: psql2
26 | image: 'postgres:13.4'
27 | ports:
28 | - '15433:5432'
29 | environment:
30 | POSTGRES_USER: blah
31 | POSTGRES_PASSWORD: blah
32 |
33 | cassandra:
34 | hostname: cassandra
35 | image: 'cassandra:2.1.15'
36 | ports:
37 | - '9042:9042'
38 | - '9160:9160'
39 |
40 | kafka:
41 | hostname: kafka
42 | image: spotify/kafka
43 | ports:
44 | - 9092:9092
45 | - 2181:2181
46 | command: bash -c "sed -i 's/#delete.topic.enable=true/delete.topic.enable=true/' /opt/kafka_2.11-0.10.1.0/config/server.properties; exec supervisord -n"
47 |
48 |
49 | ssh:
50 | hostname: ssh
51 | build: 'ssh'
52 | ports:
53 | - '2222:22'
54 |
55 | trino-master:
56 | hostname: trino-master
57 | build: 'trino-server'
58 | ports:
59 | - '8080:8080'
60 | depends_on:
61 | - 'cassandra'
62 | - 'hadoop-master'
63 | - 'psql1'
64 | - 'psql2'
65 | - 'kafka'
66 |
67 | trino-cli:
68 | build: 'trino-cli'
69 | depends_on:
70 | - 'trino-master'
71 |
72 | runner:
73 | image: 'eclipse-temurin:22-jdk'
74 | ports:
75 | - '5005:5005'
76 | volumes:
77 | - '..:/workspace'
78 | depends_on:
79 | - 'trino-master'
80 |
81 |
--------------------------------------------------------------------------------
/tempto-examples/docker/ssh/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ghcr.io/trinodb/testing/centos7-oj11:53
2 |
3 | RUN yum install -y openssh-server openssh-clients passwd
4 | RUN echo s3cr37_p@55 | passwd --stdin root
5 |
6 | RUN mkdir /var/run/sshd && mkdir /root/.ssh
7 |
8 | RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
9 |
10 | COPY keys/key.pub /root/.ssh/authorized_keys
11 |
12 | RUN chmod 400 /root/.ssh/authorized_keys
13 |
14 | EXPOSE 22
15 |
16 | CMD /usr/sbin/sshd -D
17 |
--------------------------------------------------------------------------------
/tempto-examples/docker/ssh/keys/key:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEowIBAAKCAQEAnQ2UUCYAq5cqmO+hdKv2UoO6CSBQGhp+bp5B8P3ZArhz/NkQ
3 | ZMWp5haW82mBn5d7ioTGUHQWttqs5WQbUsOFbpQydYI5d2YUBHc6g9c6QFBDjx8C
4 | sJ0cpfkczeRsCoXu6a+VboXl2BPD7jGXSSGJQxFrKGzhywg1NOKaOklmljYKz3gS
5 | 3BLGiBeJ04oceUMTKLKWs7UEnNqBaV/7y0GqYnhWsvxNKYvzkCuZEavYyLU+H6JA
6 | l/03HbKmUesPUSaurfk67/VHEH1vXICFnNvQ/LB9mvZJpcmuOFTdG0mukdta7rad
7 | kVNCHp6xrq5h6RCHA3Ivx7yP3HIDjvRPdV694wIDAQABAoIBAFFTo9axJy2z9OIH
8 | TPNOzRpDjkWFjxVFXO1JVFpICWVIQP/RI5UbanR0hCx+GRqcZeQAB3XH968uo9OR
9 | uDhueR0e7tY83ic/G+SIHSwCeu6s4Z8ubsUoRpqH2muf+nakjmhCfT4jZjczXQVu
10 | dqnvDNZHIddoMrBhirPdGAJQ2iez+sm+R57rYxPYuf5HCUISxtdBGLBHuffz6Hok
11 | ydSqmt3gkS3aYvqtA+yKcDxDJsGCx/VX2dXZANOeBm0gcgTl92IW8jOfldWJl4ZU
12 | 7GW655Yc6pnMJNr6FsIKzUUOAnAGeN8xcLMyx3f8zKIJSgmOsvgMvOeMRfnX18TP
13 | O5mjXVkCgYEAy7pT9/1VaDpDsqlUl2d8YYVXykA2LLhgH/ozBjJBSDlQO1Njb7Bf
14 | SYb50hrVUAB1un73QUMZgw1UKdwzlQWdLSbrQdnAu27oTW++XScaB3qJJ4F1++hm
15 | kERGL3CUIcModd7pr6oVcljxsqvSM/P6FTAI7fz/bjVkVWLz8sZSt+UCgYEAxVl2
16 | BBCd1kekteng+hyhfZS4kikZdVNQYiC8yhOQLdYQHlekYpk90DdjLjhq1lLBecZm
17 | xB5Gy7kOM5ja0y8LvY6zevT8W9ukC5rCJw1PFmfUuxe5DiIN2yfYlRdv/wtTYZNP
18 | Qds8fnil8Do03dkFTVUyh7HC5AHRHg7cfXnSMicCgYA2vtRPoKDxyC5m9T/JC8MN
19 | xbJIpCaqr8UM8sQBV0HZsaUQvCDNY5zHemDph9JolCcOvY2d2PUjFVLXiNfHpOGO
20 | v5WadXRoKa59GJkUGSzSc6glmJFm5xWgkOg3WU5FIFdgDU3IqbDnsGUKuUdcNKSw
21 | St8rbMALEofqthON2qNhzQKBgQCmQhP2oLkYSQsuZnauv2gdkClemVllSmcyBDqI
22 | U6rnsquppFRM7KTywXbA/a6kGNv+Z3M0Tf1+q8yXE3Nm7v+JFquGLtZb3NJ7JEnk
23 | 9IVobtj9NaMlkPLzasI/+JrV1wjL73qaFMUGF0ZU9/SJ4cdhuyDyyINT62PtWr/O
24 | xc6biQKBgGT3rab4YTD/L3LKJfCYnojRLAfqJKYeQSjrlSHgoj61OGuH05tJ2fZG
25 | OOyScySWsqUUEqkd0IJ/3uVHPjGrff/CraerTW8xHSrQcImdm2d7p2IP2CMUUC0p
26 | H/jEYfrjCTz9TShBjtxbv1O/85tJRKl6Irtu9J+tLGkByeK/qQ/8
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/tempto-examples/docker/ssh/keys/key.pub:
--------------------------------------------------------------------------------
1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCdDZRQJgCrlyqY76F0q/ZSg7oJIFAaGn5unkHw/dkCuHP82RBkxanmFpbzaYGfl3uKhMZQdBa22qzlZBtSw4VulDJ1gjl3ZhQEdzqD1zpAUEOPHwKwnRyl+RzN5GwKhe7pr5VuheXYE8PuMZdJIYlDEWsobOHLCDU04po6SWaWNgrPeBLcEsaIF4nTihx5QxMospaztQSc2oFpX/vLQapieFay/E0pi/OQK5kRq9jItT4fokCX/TcdsqZR6w9RJq6t+Trv9UcQfW9cgIWc29D8sH2a9kmlya44VN0bSa6R21rutp2RU0IenrGurmHpEIcDci/HvI/ccgOO9E91Xr3j kogut@haxu
2 |
--------------------------------------------------------------------------------
/tempto-examples/docker/tempto-configuration-docker-local.yaml:
--------------------------------------------------------------------------------
1 | cluster:
2 | trino: trino-master
3 | hadoop: hadoop-master
4 | cassandra: cassandra
5 | psql1: psql1
6 | psql2: psql2
7 | ssh: ssh
8 |
9 | psql1:
10 | port: 5432
11 | psql2:
12 | port: 5432
13 |
14 | ssh:
15 | identity: /workspace/docker/ssh/keys/key
16 | roles:
17 | host_by_identity:
18 | user: root
19 | host_by_password:
20 | user: root
21 | password: s3cr37_p@55
22 |
--------------------------------------------------------------------------------
/tempto-examples/docker/tempto-configuration-local.yaml:
--------------------------------------------------------------------------------
1 | hosts:
2 | hadoop-master: ${DOCKER_MACHINE}
3 | ssh:
4 | identity: ssh/keys/key
5 | roles:
6 | host_by_identity:
7 | port: 2222
8 | user: root
9 | host_by_password:
10 | port: 2222
11 | user: root
12 | password: s3cr37_p@55
13 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-cli/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ghcr.io/trinodb/testing/centos7-oj11:53
2 |
3 | RUN curl -SL https://repo1.maven.org/maven2/io/trino/trino-cli/356/trino-cli-356-executable.jar -o trino-cli.jar
4 |
5 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ghcr.io/trinodb/testing/centos7-oj11:53
2 |
3 | RUN yum install -y tar
4 |
5 | RUN curl -SL https://repo1.maven.org/maven2/io/trino/trino-server/356/trino-server-356.tar.gz \
6 | | tar xz \
7 | && mv $(find -type d -name 'trino-server*') trino-server
8 |
9 | RUN mkdir /trino-server/etc
10 |
11 | COPY etc /trino-server/etc/
12 |
13 | CMD /trino-server/bin/launcher run
14 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/blackhole.properties:
--------------------------------------------------------------------------------
1 | connector.name=blackhole
2 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/cassandra.properties:
--------------------------------------------------------------------------------
1 | connector.name=cassandra
2 | cassandra.contact-points=cassandra
3 | cassandra.load-policy.dc-aware.local-dc=datacenter1
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/hive.properties:
--------------------------------------------------------------------------------
1 | connector.name=hive-hadoop2
2 | hive.metastore.uri=thrift://hadoop-master:9083
3 | hive.allow-drop-table=true
4 | hive.allow-rename-table=true
5 | hive.metastore-cache-ttl=0s
6 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/jmx.properties:
--------------------------------------------------------------------------------
1 | connector.name=jmx
2 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/kafka.properties:
--------------------------------------------------------------------------------
1 | connector.name=kafka
2 | kafka.table-names=default.simple_key_and_value
3 | kafka.nodes=kafka:9092
4 | kafka.table-description-dir=/trino-server/etc/catalog/kafka
5 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/kafka/simple_key_and_value.json:
--------------------------------------------------------------------------------
1 | {
2 | "tableName": "simple_key_and_value",
3 | "schemaName": "default",
4 | "topicName": "simple_key_and_value",
5 | "message": {
6 | "dataFormat": "csv",
7 | "fields": [
8 | {
9 | "name": "varchar_value",
10 | "type": "VARCHAR",
11 | "mapping": "0"
12 | },
13 | {
14 | "name": "bigint_value",
15 | "type": "BIGINT",
16 | "mapping": "1"
17 | }
18 | ]
19 | },
20 | "key": {
21 | "dataFormat": "csv",
22 | "fields": [
23 | {
24 | "name": "varchar_key",
25 | "type": "VARCHAR",
26 | "mapping": "0"
27 | },
28 | {
29 | "name": "bigint_key",
30 | "type": "BIGINT",
31 | "mapping": "1"
32 | }
33 | ]
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/psql.properties:
--------------------------------------------------------------------------------
1 | connector.name=postgresql
2 | connection-url=jdbc:postgresql://psql1:5432/postgres
3 | connection-user=blah
4 | connection-password=blah
5 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/psql2.properties:
--------------------------------------------------------------------------------
1 | connector.name=postgresql
2 | connection-url=jdbc:postgresql://psql2:5432/postgres
3 | connection-user=blah
4 | connection-password=blah
5 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/catalog/tpch.properties:
--------------------------------------------------------------------------------
1 | connector.name=tpch
2 | tpch.splits-per-node=4
3 |
4 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/config.properties:
--------------------------------------------------------------------------------
1 | node.id=trino-master
2 | node.environment=test
3 | coordinator=true
4 | node-scheduler.include-coordinator=true
5 | http-server.http.port=8080
6 | query.max-memory=256MB
7 | query.max-memory-per-node=128MB
8 | discovery-server.enabled=true
9 | discovery.uri=http://trino-master:8080
10 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/jvm.config:
--------------------------------------------------------------------------------
1 | -server
2 | -Xmx2G
3 | -XX:-UseBiasedLocking
4 | -XX:+UseG1GC
5 | -XX:G1HeapRegionSize=32M
6 | -XX:+ExplicitGCInvokesConcurrent
7 | -XX:+ExitOnOutOfMemoryError
8 | -XX:+HeapDumpOnOutOfMemoryError
9 | -XX:ReservedCodeCacheSize=512M
10 | -XX:PerMethodRecompilationCutoff=10000
11 | -XX:PerBytecodeRecompilationCutoff=10000
12 | -Djdk.attach.allowAttachSelf=true
13 | -Djdk.nio.maxCachedBufferSize=2000000
14 |
--------------------------------------------------------------------------------
/tempto-examples/docker/trino-server/etc/log.properties:
--------------------------------------------------------------------------------
1 | io.trino=INFO
2 | com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory=WARN
3 | io.airlift.discovery.client=INFO
4 |
--------------------------------------------------------------------------------
/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/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-examples/src/main/java/io/trino/tempto/examples/CommandTest.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.examples;
16 |
17 | import io.trino.tempto.Requirement;
18 | import io.trino.tempto.Requirements;
19 | import io.trino.tempto.RequirementsProvider;
20 | import io.trino.tempto.configuration.Configuration;
21 | import org.testng.annotations.Test;
22 |
23 | import java.io.File;
24 |
25 | import static io.trino.tempto.fulfillment.command.SuiteCommandRequirement.suiteCommand;
26 | import static io.trino.tempto.fulfillment.command.TestCommandRequirement.testCommand;
27 | import static org.assertj.core.api.Assertions.assertThat;
28 |
29 | public class CommandTest
30 | implements RequirementsProvider
31 | {
32 | @Override
33 | public Requirement getRequirements(Configuration configuration)
34 | {
35 | return Requirements.compose(
36 | testCommand("echo this is a test command output"),
37 | suiteCommand("echo this is a suite command output"),
38 | suiteCommand("touch commandTestFile"));
39 | }
40 |
41 | @Test(groups = "command")
42 | public void commandTest()
43 | {
44 | assertThat(new File("commandTestFile").exists()).isTrue();
45 | }
46 |
47 | @Test(groups = "command")
48 | public void configurationcommandTest()
49 | {
50 | assertThat(new File("configuratioCommandTestFile").exists()).isTrue();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/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-examples/src/main/java/io/trino/tempto/examples/TemptoExamples.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.examples;
16 |
17 | import io.trino.tempto.another.examples.MultiplePackagesTest;
18 | import io.trino.tempto.runner.TemptoRunner;
19 | import io.trino.tempto.runner.TemptoRunnerCommandLineParser;
20 |
21 | import static io.trino.tempto.internal.configuration.TestConfigurationFactory.DEFAULT_TEST_CONFIGURATION_LOCATION;
22 | import static org.testng.Assert.assertTrue;
23 |
24 | public class TemptoExamples
25 | {
26 | public static void main(String[] args)
27 | {
28 | TemptoRunnerCommandLineParser parser = TemptoRunnerCommandLineParser
29 | .builder("tempto examples")
30 | .setTestsPackage("io.trino.tempto.examples,io.trino.tempto.another.examples", false)
31 | .setConfigFile(DEFAULT_TEST_CONFIGURATION_LOCATION, true)
32 | .build();
33 | TemptoRunner.runTempto(parser, args);
34 |
35 | if (parser.parseCommandLine(args).getTestGroups().isEmpty()) {
36 | assertTrue(MultiplePackagesTest.called.get(), "Tests from io.trino.tempto.another.examples were not called");
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/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-examples/src/main/resources/META-INF/services/io.trino.tempto.TemptoPlugin:
--------------------------------------------------------------------------------
1 | io.trino.tempto.examples.TemptoExamplesPlugin
2 |
--------------------------------------------------------------------------------
/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-examples/src/main/resources/sql-tests/datasets/no_data_jdbc_table.ddl:
--------------------------------------------------------------------------------
1 | -- type: jdbc
2 | CREATE TABLE %NAME% (
3 | id INT,
4 | name VARCHAR(100)
5 | )
6 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/datasets/sample_hive_table.data:
--------------------------------------------------------------------------------
1 | 1|A|
2 | 2|B|
3 | 3|C|
4 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/datasets/sample_hive_table.data-revision:
--------------------------------------------------------------------------------
1 | v.1.0
2 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/datasets/sample_hive_table.ddl:
--------------------------------------------------------------------------------
1 | -- type: hive
2 | CREATE TABLE %NAME% (
3 | id INT,
4 | name STRING
5 | )
6 | ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
7 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/datasets/sample_jdbc_table.data:
--------------------------------------------------------------------------------
1 | -- delimiter: |; types: INTEGER|VARCHAR
2 | 3|A|
3 | 2|null|
4 | 1|C|
5 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/datasets/sample_jdbc_table.data-revision:
--------------------------------------------------------------------------------
1 | v.1.0
2 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/datasets/sample_jdbc_table.ddl:
--------------------------------------------------------------------------------
1 | -- type: jdbc
2 | CREATE TABLE %NAME% (
3 | id BIGINT,
4 | name VARCHAR(100)
5 | )
6 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/generated/nation.generator:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | cat >$1/generated_nation.sql << EOF
4 | -- database: hive; tables: sample_hive_table; groups: generated
5 | SELECT * FROM sample_hive_table
6 | EOF
7 |
8 | cat >$1/generated_nation.result << EOF
9 | -- delimiter: |; ignoreOrder: false; types: INTEGER|VARCHAR; groups: generated
10 | 1|A|
11 | 2|B|
12 | 3|C|
13 | EOF
14 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_hive_table/allRows.result:
--------------------------------------------------------------------------------
1 | -- delimiter: |; ignoreOrder: false; types: INTEGER|VARCHAR
2 | 1|A|
3 | 2|B|
4 | 3|C|
5 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_hive_table/allRows.sql:
--------------------------------------------------------------------------------
1 | -- database: hive; tables: sample_hive_table; groups: hive_convention
2 | SELECT * FROM sample_hive_table;
3 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_psql_table/allRows.result:
--------------------------------------------------------------------------------
1 | -- delimiter: |; ignoreOrder: false; types: BIGINT|VARCHAR
2 | 3|A|
3 | 2|null|
4 | 1|C|
5 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_psql_table/allRows.sql:
--------------------------------------------------------------------------------
1 | -- database: psql; tables: sample_jdbc_table; groups: psql_convention
2 | SELECT * FROM sample_jdbc_table
3 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_psql_table/allRowsOnPsql2.result:
--------------------------------------------------------------------------------
1 | -- delimiter: |; ignoreOrder: false; types: BIGINT|VARCHAR
2 | 3|A|
3 | 2|null|
4 | 1|C|
5 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_psql_table/allRowsOnPsql2.sql:
--------------------------------------------------------------------------------
1 | -- database: psql2; tables: sample_jdbc_table; groups: psql_convention
2 | SELECT * FROM sample_jdbc_table
3 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_psql_table/noData.sql:
--------------------------------------------------------------------------------
1 | -- database: psql; tables: no_data_jdbc_table; groups: psql_convention
2 | -- delimiter: |; ignoreOrder: false; types: INTEGER|VARCHAR
3 | --!
4 | SELECT * FROM no_data_jdbc_table
5 | --!
6 | --!
7 | SELECT * FROM no_data_jdbc_table WHERE true
8 | --!
9 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_table_insert/insert.sql:
--------------------------------------------------------------------------------
1 | -- database: hive; tables: sample_hive_table; mutable_tables: sample_hive_table|created|sample_table_created, sample_hive_table|prepared|sample_table_prepared; groups: insert
2 | -- delimiter: |; ignoreOrder: false; types: INTEGER|VARCHAR
3 | --!
4 | INSERT INTO TABLE ${mutableTables.hive.sample_table_created} SELECT * from sample_hive_table;
5 | SELECT * from ${mutableTables.hive.sample_table_created}
6 | --!
7 | 1|A|
8 | 2|B|
9 | 3|C|
10 | --!
11 | CREATE TABLE ${mutableTables.hive.sample_table_prepared} ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' AS SELECT * from sample_hive_table;
12 | SELECT * from ${mutableTables.hive.sample_table_prepared}
13 | --!
14 | 1|A|
15 | 2|B|
16 | 3|C|
17 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_trino_table/allRows.sql:
--------------------------------------------------------------------------------
1 | -- database: trino; tables: sample_jdbc_table; groups: trino_convention
2 | -- delimiter: |; ignoreOrder: false; types: BIGINT|VARCHAR
3 | --!
4 | SELECT * FROM sample_jdbc_table ORDER BY id;
5 | --!
6 | 1|C|
7 | 2|null|
8 | 3|A|
9 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_trino_table/in-memory.sql:
--------------------------------------------------------------------------------
1 | -- database: trino; groups: trino_convention, in_memory
2 | --!
3 | SELECT count(*) FROM tpch.tiny.nation
4 | --!
5 | 25|
6 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_trino_table/psqlOverTrinoAllRows.result:
--------------------------------------------------------------------------------
1 | -- delimiter: |; ignoreOrder: false; types: BIGINT|VARCHAR
2 | 3|A|
3 | 2|null|
4 | 1|C|
5 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/sample_trino_table/psqlOverTrinoAllRows.sql:
--------------------------------------------------------------------------------
1 | -- database: trino; tables: psql.public.sample_jdbc_table; groups: trino_convention
2 | SELECT * FROM psql.public.sample_jdbc_table
3 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/tpcds/select_count_from_customer.sql:
--------------------------------------------------------------------------------
1 | -- database: trino_tpcds; groups: tpcds; tables: tpcds.customer
2 | -- delimiter: |; ignoreOrder: false; types: BIGINT
3 | --! name: query_1
4 | SELECT count(*) FROM customer
5 | --!
6 | 100000|
7 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/tpch/after:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo hello world after
3 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/sql-tests/testcases/tpch/before:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo hello world before
--------------------------------------------------------------------------------
/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-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-examples/src/main/resources/sql-tests/testcases/tpch/show_stats_for_partsupp.sql:
--------------------------------------------------------------------------------
1 | -- database: trino; groups: stats, tpch; tables: partsupp
2 | -- delimiter: |; ignoreOrder: true; types: VARCHAR|DOUBLE|DOUBLE|DOUBLE|DOUBLE|VARCHAR|VARCHAR
3 | --! name: show stats for partsupp
4 | SHOW STATS FOR partsupp
5 | --!
6 | ps_partkey|null|200000.00000000000|0.00000000000|null|1|200000|
7 | ps_suppkey|null|10000.00000000000|0.00000000000|null|1|10000|
8 | ps_availqty|null|9999.00000000000|0.00000000000|null|1|9999|
9 | ps_supplycost|null|1999.00000000000|0.00000000000|null|0.02|20.0|
10 | ps_comment|53066639.99999999000|799124.00000000000|0.00000000000|null|null|null|
11 | null|null|null|null|800000.00000000000|null|null|
12 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/tempto-configuration-no-db.yaml:
--------------------------------------------------------------------------------
1 | DOCKER_MACHINE: localhost
2 |
3 | cluster:
4 | ssh: ${DOCKER_MACHINE}
5 |
6 | ssh:
7 | identity: ${IDENTITY}
8 | roles:
9 | host_by_password:
10 | host: ${cluster.ssh}
11 | port: 22
12 | user: ${USER_A}
13 | password: ${USER_A_PASSWORD}
14 |
15 | host_by_identity:
16 | host: ${cluster.ssh}
17 | port: 22
18 | user: ${USER_B}
19 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/tempto-configuration-read-only.yaml:
--------------------------------------------------------------------------------
1 | DOCKER_MACHINE: localhost
2 |
3 | cluster:
4 | trino: ${DOCKER_MACHINE}
5 | ssh: ${DOCKER_MACHINE}
6 |
7 | databases:
8 | default:
9 | alias: trino
10 |
11 | trino:
12 | jdbc_driver_class: io.trino.jdbc.TrinoDriver
13 | jdbc_url: jdbc:trino://${cluster.trino}:8080/hive/default
14 | jdbc_user: hdfs
15 |
16 | ssh:
17 | identity: ${IDENTITY}
18 | roles:
19 | host_by_password:
20 | host: ${cluster.ssh}
21 | password: ${USER_A_PASSWORD}
22 |
23 | host_by_identity:
24 | host: ${cluster.ssh}
25 |
--------------------------------------------------------------------------------
/tempto-examples/src/main/resources/tempto.env:
--------------------------------------------------------------------------------
1 | TEMPTO_VERSION=${project.version}
2 |
--------------------------------------------------------------------------------
/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-kafka/src/main/java/io/trino/tempto/fulfillment/table/kafka/KafkaDataSource.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 java.util.Iterator;
18 |
19 | public interface KafkaDataSource
20 | {
21 | Iterator getMessages();
22 | }
23 |
--------------------------------------------------------------------------------
/tempto-kafka/src/main/java/io/trino/tempto/fulfillment/table/kafka/KafkaMessage.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 java.util.Optional;
18 | import java.util.OptionalInt;
19 |
20 | import static java.util.Objects.requireNonNull;
21 |
22 | public class KafkaMessage
23 | {
24 | private final OptionalInt partition;
25 | private final Optional key;
26 | private final byte[] value;
27 |
28 | public KafkaMessage(byte[] value)
29 | {
30 | this(Optional.empty(), value, OptionalInt.empty());
31 | }
32 |
33 | public KafkaMessage(byte[] value, OptionalInt partition)
34 | {
35 | this(Optional.empty(), value, partition);
36 | }
37 |
38 | public KafkaMessage(byte[] key, byte[] value)
39 | {
40 | this(Optional.of(key), value, OptionalInt.empty());
41 | }
42 |
43 | public KafkaMessage(Optional key, byte[] value, OptionalInt partition)
44 | {
45 | this.partition = requireNonNull(partition, "partition is null");
46 | this.key = requireNonNull(key, "key is null");
47 | this.value = requireNonNull(value, "value is null");
48 | }
49 |
50 | public OptionalInt getPartition()
51 | {
52 | return partition;
53 | }
54 |
55 | public Optional getKey()
56 | {
57 | return key;
58 | }
59 |
60 | public byte[] getValue()
61 | {
62 | return value;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/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-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-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-ldap/src/main/java/io/trino/tempto/fulfillment/ldap/LdapObjectRequirement.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.ldap;
16 |
17 | import com.google.common.collect.ImmutableList;
18 | import io.trino.tempto.Requirement;
19 |
20 | import java.util.List;
21 |
22 | import static java.util.Objects.requireNonNull;
23 | import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals;
24 | import static org.apache.commons.lang3.builder.HashCodeBuilder.reflectionHashCode;
25 |
26 | public class LdapObjectRequirement
27 | implements Requirement
28 | {
29 | private final List ldapObjectDefinitions;
30 |
31 | public LdapObjectRequirement(List ldapObjectDefinitions)
32 | {
33 | this.ldapObjectDefinitions = ImmutableList.copyOf(requireNonNull(ldapObjectDefinitions, "ldapObjectDefinition is null"));
34 | }
35 |
36 | public List getLdapObjectDefinitions()
37 | {
38 | return ldapObjectDefinitions;
39 | }
40 |
41 | @Override
42 | public boolean equals(Object o)
43 | {
44 | return reflectionEquals(this, o);
45 | }
46 |
47 | @Override
48 | public int hashCode()
49 | {
50 | return reflectionHashCode(this);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/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-ldap/src/main/java/io/trino/tempto/internal/fulfillment/ldap/LdapObjectFulfiller.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.Inject;
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 | import io.trino.tempto.fulfillment.ldap.LdapObjectRequirement;
23 |
24 | import java.util.Set;
25 |
26 | import static com.google.common.collect.Sets.newHashSet;
27 |
28 | @RequirementFulfiller.SuiteLevelFulfiller
29 | public class LdapObjectFulfiller
30 | implements RequirementFulfiller
31 | {
32 | @Inject
33 | LdapObjectEntryManager ldapObjectEntryManager;
34 |
35 | @Override
36 | public Set fulfill(Set requirements)
37 | {
38 | requirements.stream()
39 | .filter(LdapObjectRequirement.class::isInstance)
40 | .map(LdapObjectRequirement.class::cast)
41 | .map(requirement -> requirement.getLdapObjectDefinitions())
42 | .distinct()
43 | .forEach(ldapObjectEntryManager::addLdapDefinitions);
44 |
45 | return newHashSet();
46 | }
47 |
48 | @Override
49 | public void cleanup(TestStatus status)
50 | {
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/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-runner/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | io.trino.tempto
7 | tempto-root
8 | 203-SNAPSHOT
9 |
10 |
11 | tempto-runner
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 | commons-cli
29 | commons-cli
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 | org.testng
48 | testng
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------