Sega76 commented on a change in pull request #8219: URL: https://github.com/apache/ignite/pull/8219#discussion_r487902509
########## File path: modules/ducktests/tests/ignitetest/tests/sql_jdbc_test.py ########## @@ -0,0 +1,128 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This module contains SQL tests using the JDBC driver. +""" +from ducktape.mark.resource import cluster + +from ignitetest.services.ignite import IgniteService +from ignitetest.services.utils.ignite_configuration import IgniteConfiguration +from ignitetest.services.utils.sql_util import connection +from ignitetest.utils import ignite_versions +from ignitetest.utils.ignite_test import IgniteTest +from ignitetest.utils.version import DEV_BRANCH, V_2_8_1, V_2_8_0, V_2_7_6, IgniteVersion + + +# pylint: disable=W0223 +class SqlJdbcTest(IgniteTest): + """ + SQL tests using the JDBC driver. + """ + NUM_NODES = 3 + + @cluster(num_nodes=NUM_NODES) + # Note: DEV version does not support earlier versions before IGNITE-13414 resolution + @ignite_versions( + (str(DEV_BRANCH), str(DEV_BRANCH)), + (str(V_2_8_1), str(V_2_8_1)), (str(V_2_8_0), str(V_2_8_1)), + (str(V_2_8_1), str(V_2_8_0)), (str(V_2_8_0), str(V_2_8_0)), + (str(V_2_8_1), str(V_2_7_6)), (str(V_2_8_0), str(V_2_7_6)), (str(V_2_7_6), str(V_2_7_6)) + ) + def sql_test(self, ignite_version_1, ignite_version_2): + """ + SQL test with different versions jdbc driver. + """ + self.check_connection(ignite_version=IgniteVersion(ignite_version_1), jar_ver=IgniteVersion(ignite_version_2)) + + def check_connection(self, ignite_version: IgniteVersion, jar_ver: IgniteVersion = None): + """ + Check SQL commands. + :param ignite_version: IgniteVersion. + :param jar_ver: Version JDBC driver. + """ + self.stage("Starting nodes") + + config = IgniteConfiguration(version=ignite_version) + + service = IgniteService(self.test_context, config=config, num_nodes=self.NUM_NODES) + service.start() + + with connection(ignite_service=service, ver=jar_ver) as conn: + with conn.cursor() as curs: + curs.execute('CREATE TABLE users (id int, name varchar, PRIMARY KEY (id))') + self.logger.info("Created a table of users") + + curs.execute('CREATE INDEX name_idx ON users (name)') + self.logger.info("Created a index") + + insert(curs) + update(curs) + delete(curs) + + curs.execute('DROP INDEX name_idx') + self.logger.info("Droped a index") + + curs.execute('DROP TABLE users') + self.logger.info("Deleted the users table") + + +def insert(curs, size=100): Review comment: fixed ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
