Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Tests for SQL Interface #343

Merged
merged 34 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2ba5d31
Added Tests
S-Harshit Jun 20, 2021
07eaaf3
Tests For Functions
S-Harshit Jul 1, 2021
74ea3f2
Tests for Operators
S-Harshit Jul 8, 2021
f7aa4df
Merge branch 'master' into testing
S-Harshit Jul 8, 2021
a125262
Minor improvements for TrigonometricFunctionsTest and StringFunctions…
vogti Jul 14, 2021
c6f82fa
Merge remote-tracking branch 'origin/master' into testing
vogti Jul 14, 2021
8604ff6
Merge branch 'polypheny:master' into testing
S-Harshit Jul 15, 2021
83d1614
Fix test helper
vogti Jul 19, 2021
85f4f0d
Added Test Cases in DayTimeFunctionsTest and Fixed errors in existin…
S-Harshit Jul 19, 2021
9de7733
Merge branch 'polypheny:master' into testing
S-Harshit Jul 19, 2021
0b994a9
Fixed Clause Tests and TrigonometricfunctionsTest
S-Harshit Jul 20, 2021
b8c7a26
Test Data for UI Testing
S-Harshit Jul 24, 2021
7020fef
Added @Category Annotation
S-Harshit Aug 3, 2021
84529b0
Merge branch 'polypheny:master' into testing
S-Harshit Aug 12, 2021
bedfbde
Added more test cases and added true for ignoring row order
S-Harshit Aug 15, 2021
0fb253e
Merge branch 'master' into testing
S-Harshit Aug 16, 2021
96802f1
Updated Config and Monitoring Page
S-Harshit Aug 22, 2021
345c8e8
Merge branch 'master' into ui-testing
S-Harshit Aug 22, 2021
cb9d45a
Improve formatting and enable all tests
vogti Aug 24, 2021
ca675f6
Adjust and improve some of the test cases
vogti Aug 25, 2021
4ea3f63
Minor clean-up
vogti Aug 25, 2021
e6e6f49
Merge branch 'ui-testing' into testing
vogti Aug 25, 2021
6ec8a08
Merge branch 'master' into testing
vogti Aug 26, 2021
0d6444b
Remove redundant test
vogti Aug 26, 2021
c1b3b61
Add additional tests for time functions
vogti Aug 26, 2021
4a9f0e6
Minor improvements of code style
vogti Aug 31, 2021
62c2beb
Exclude cassandra
vogti Aug 31, 2021
137735f
Exclude additional tests for cassandra
vogti Aug 31, 2021
4e404ea
Add excludes for file store
vogti Aug 31, 2021
5c9c5ff
Add excludes for mongodb
vogti Aug 31, 2021
cd801e0
Merge branch 'master' into testing
vogti Aug 31, 2021
cace438
Add additional excludes
vogti Sep 1, 2021
c51c800
Add additional exclude for MonetDB
vogti Sep 1, 2021
eb8ba29
Disable additional tests for MonetDB
vogti Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions config/src/main/java/org/polypheny/db/webui/UiTestingConfigPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright 2019-2021 The Polypheny Project
*
* Licensed 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.
*/

package org.polypheny.db.webui;

import com.google.common.collect.ImmutableList;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.polypheny.db.config.Config;
import org.polypheny.db.config.ConfigBoolean;
import org.polypheny.db.config.ConfigClazz;
import org.polypheny.db.config.ConfigClazzList;
import org.polypheny.db.config.ConfigDecimal;
import org.polypheny.db.config.ConfigDouble;
import org.polypheny.db.config.ConfigEnum;
import org.polypheny.db.config.ConfigEnumList;
import org.polypheny.db.config.ConfigInteger;
import org.polypheny.db.config.ConfigLong;
import org.polypheny.db.config.ConfigManager;
import org.polypheny.db.config.WebUiGroup;
import org.polypheny.db.config.WebUiPage;


public class UiTestingConfigPage {


private static class TestClass {

int a;

}


private enum testEnum {FOO, BAR, FOO_BAR}


private static class FooImplementation extends TestClass {

int b;

}


private static class BarImplementation extends TestClass {

int c;

}


private static class FooBarImplementation extends TestClass {

int d;

}


static {
ConfigManager cm = ConfigManager.getInstance();

WebUiPage p1 = new WebUiPage( "uiconfigtest", "UiConfigTestPage", "Configuration Description" );

WebUiGroup g1 = new WebUiGroup( "g1", p1.getId(), 1 ).withTitle( "Config" ).withDescription( "Select Config Options" );
WebUiGroup g2 = new WebUiGroup( "g2", p1.getId() ).withTitle( "Config Too" ).withDescription( "Select Config Options" );

cm.registerWebUiPage( p1 );
cm.registerWebUiGroup( g1 );
cm.registerWebUiGroup( g2 );

Config c1 = new ConfigBoolean( "Boolean True Test", true ).withUi( "g1" );
Config c2 = new ConfigBoolean( "Boolean False Test", false ).withUi( "g1" );
Config c3 = new ConfigInteger( "Integer Test", 11 ).withUi( "g1" );
Config c4 = new ConfigInteger( "Negative Integer Test", -1 ).withUi( "g1" );
Config c5 = new ConfigClazz( "clazz Test", TestClass.class, FooImplementation.class ).withUi( "g1" );

List<Class> l = new ArrayList<>();
l.add( FooImplementation.class );
l.add( BarImplementation.class );

Config c6 = new ConfigEnumList( "enumList", "Test description", testEnum.class, ImmutableList.of( testEnum.BAR ) ).withUi( "g1" );
Config c7 = new ConfigClazzList( "clazzList Test", TestClass.class, l ).withUi( "g2" );
Config c8 = new ConfigDecimal( "Decimal Test", BigDecimal.valueOf( 43.43431 ) ).withUi( "g2" );
Config c9 = new ConfigDouble( "Double Test", Double.valueOf( 2.2 ) ).withUi( "g2" );
Config c10 = new ConfigEnum( "Enum Test", "Test description", testEnum.class, testEnum.FOO_BAR ).withUi( "g2" );
List<Integer> list = new ArrayList<Integer>();
list.add( 1 );
list.add( 2 );
list.add( 3 );

Config c11 = new ConfigLong( "Long", 12312L ).withUi( "g2" );

// Config c45 = new ConfigList("List",list,TestClass.class);

// int[] array = { 1, 2, 3, 4, 5 };
// Config c40 = new ConfigArray( "array", array ).withUi("g1");

// int[][] table = new int[][]{
// { 1, 2, 3 },
// { 4, 5, 6 }
// };
// Config c41 = new ConfigTable( "table", table ).withUi("g1");
cm.registerConfigs( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 );

}


}
8 changes: 8 additions & 0 deletions dbms/src/main/java/org/polypheny/db/PolyphenyDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import org.polypheny.db.webui.ConfigServer;
import org.polypheny.db.webui.HttpServer;
import org.polypheny.db.webui.InformationServer;
import org.polypheny.db.webui.UiTestingConfigPage;
import org.polypheny.db.webui.UiTestingMonitoringPage;


@Command(name = "polypheny-db", description = "Polypheny-DB command line hook.")
Expand Down Expand Up @@ -267,6 +269,12 @@ public void join( final long millis ) throws InterruptedException {
ExploreManager explore = ExploreManager.getInstance();
explore.setExploreQueryProcessor( exploreQueryProcessor );

// Add config and monitoring test page for UI testing
if ( testMode ) {
new UiTestingConfigPage();
new UiTestingMonitoringPage();
}

log.info( "****************************************************************************************************" );
log.info( " Polypheny-DB successfully started and ready to process your queries!" );
log.info( " The UI is waiting for you on port {}:", RuntimeConfig.WEBUI_SERVER_PORT.getInteger() );
Expand Down
145 changes: 145 additions & 0 deletions dbms/src/test/java/org/polypheny/db/sql/clause/GroupByTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright 2019-2021 The Polypheny Project
*
* Licensed 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.
*/

package org.polypheny.db.sql.clause;

import com.google.common.collect.ImmutableList;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.polypheny.db.AdapterTestSuite;
import org.polypheny.db.TestHelper;
import org.polypheny.db.TestHelper.JdbcConnection;
import org.polypheny.db.excluded.CassandraExcluded;
import org.polypheny.db.excluded.FileExcluded;


@SuppressWarnings({ "SqlDialectInspection", "SqlNoDataSourceInspection" })
@Slf4j
@Category({ AdapterTestSuite.class, CassandraExcluded.class })
public class GroupByTest {


@BeforeClass
public static void start() throws SQLException {
// Ensures that Polypheny-DB is running
//noinspection ResultOfMethodCallIgnored
TestHelper.getInstance();
addTestData();
}


private static void addTestData() throws SQLException {
try ( JdbcConnection jdbcConnection = new JdbcConnection( false ) ) {
Connection connection = jdbcConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
statement.executeUpdate( "CREATE TABLE TestTableA(Id INTEGER NOT NULL,Name VARCHAR(255), Primary key(Id))" );
statement.executeUpdate( "INSERT INTO TestTableA VALUES(1,'Name1')" );
statement.executeUpdate( "INSERT INTO TestTableA VALUES(2,'Name2')" );
statement.executeUpdate( "INSERT INTO TestTableA VALUES(3,'Name3')" );
statement.executeUpdate( "INSERT INTO TestTableA VALUES(4,'Name4')" );
statement.executeUpdate( "INSERT INTO TestTableA VALUES(5,'Name5')" );

statement.executeUpdate( "CREATE TABLE TestTableB(Id INTEGER NOT NULL,Row_Code VARCHAR(255) NOT NULL,Frequency INTEGER, Primary key(Id,Row_Code))" );
statement.executeUpdate( "INSERT INTO TestTableB VALUES(1,'A',86)" );
statement.executeUpdate( "INSERT INTO TestTableB VALUES(1,'B',86)" );
statement.executeUpdate( "INSERT INTO TestTableB VALUES(1,'C',90)" );
statement.executeUpdate( "INSERT INTO TestTableB VALUES(2,'A',89)" );
statement.executeUpdate( "INSERT INTO TestTableB VALUES(2,'C',92)" );
statement.executeUpdate( "INSERT INTO TestTableB VALUES(3,'C',80)" );

statement.executeUpdate( "CREATE TABLE TestTableC(Id INTEGER NOT NULL,Name VARCHAR(255),location VARCHAR(255), Primary key(Id))" );
statement.executeUpdate( "INSERT INTO TestTableC VALUES(1,'Name1','loc1')" );
statement.executeUpdate( "INSERT INTO TestTableC VALUES(2,'Name2','loc2')" );
statement.executeUpdate( "INSERT INTO TestTableC VALUES(3,'Name3','loc3')" );

statement.executeUpdate( "CREATE TABLE TestTableD(Row_Code VARCHAR(255) NOT NULL,differentname VARCHAR(255),spec VARCHAR(255), Primary key(Row_Code))" );
statement.executeUpdate( "INSERT INTO TestTableD VALUES('A','names1','spec1')" );
statement.executeUpdate( "INSERT INTO TestTableD VALUES('B','names2','spec2')" );
statement.executeUpdate( "INSERT INTO TestTableD VALUES('C','names3','spec3')" );

connection.commit();
}
}
}


@AfterClass
public static void stop() throws SQLException {
try ( JdbcConnection jdbcConnection = new JdbcConnection( true ) ) {
Connection connection = jdbcConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
statement.executeUpdate( "DROP TABLE TestTableA" );
statement.executeUpdate( "DROP TABLE TestTableB" );
statement.executeUpdate( "DROP TABLE TestTableC" );
statement.executeUpdate( "DROP TABLE TestTableD" );
}
connection.commit();
}
}

// --------------- Tests ---------------


@Test
public void groupByTest() throws SQLException {
try ( TestHelper.JdbcConnection polyphenyDbConnection = new TestHelper.JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
List<Object[]> expectedResult = ImmutableList.of(
new Object[]{ "Name1", 443 },
new Object[]{ "Name2", 443 },
new Object[]{ "Name3", 443 },
new Object[]{ "Name4", 443 },
new Object[]{ "Name5", 443 }
);
TestHelper.checkResultSet(
statement.executeQuery( "SELECT S.Name, sum (P.Frequency) FROM TestTableA S, TestTableB P WHERE P.Frequency > 84 GROUP BY S.Name ORDER BY S.Name" ),
expectedResult,
true
);
}
}
}


@Test
@Category(FileExcluded.class)
public void groupByWithInnerSelect() throws SQLException {
try ( TestHelper.JdbcConnection polyphenyDbConnection = new TestHelper.JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
List<Object[]> expectedResult = ImmutableList.of(
new Object[]{ 1, "Name1" },
new Object[]{ 2, "Name2" },
new Object[]{ 2, "Name2" }
);
TestHelper.checkResultSet(
statement.executeQuery( "SELECT s.id, s.name FROM TestTableC s, TestTableB t WHERE s.id = t.id AND Frequency > (SELECT AVG (Frequency) FROM TestTableB WHERE row_code = 'C' GROUP BY row_code='C')\n" ),
expectedResult,
true
);
}
}
}

}
Loading