ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843 Implemented test drive for metadata.
Date Fri, 21 Aug 2015 08:32:02 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 b88a5a850 -> bc9c86073


IGNITE-843 Implemented test drive for metadata.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bc9c8607
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bc9c8607
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bc9c8607

Branch: refs/heads/ignite-843
Commit: bc9c86073ab97224be52f713149ce7797f40c144
Parents: b88a5a8
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Aug 21 15:31:59 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Aug 21 15:31:59 2015 +0700

----------------------------------------------------------------------
 modules/control-center-agent/pom.xml            |  6 ++
 .../apache/ignite/agent/AgentConfiguration.java | 38 +++++++++-
 .../org/apache/ignite/agent/AgentLauncher.java  |  7 ++
 .../agent/testdrive/AgentMetadataTestDrive.java | 75 ++++++++++++++++++++
 .../agent/testdrive/AgentSqlTestDrive.java      | 15 ++++
 5 files changed, 139 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc9c8607/modules/control-center-agent/pom.xml
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/pom.xml b/modules/control-center-agent/pom.xml
index 2f24f22..2d5123e 100644
--- a/modules/control-center-agent/pom.xml
+++ b/modules/control-center-agent/pom.xml
@@ -67,6 +67,12 @@
             <artifactId>httpclient</artifactId>
             <version>4.5</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <version>1.4.188</version>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc9c8607/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
index 911ebd1..ae74e38 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
@@ -61,12 +61,12 @@ public class AgentConfiguration {
     private String driversFolder;
 
     /** */
-    @Parameter(names = { "-tm", "--test-metadata" },
+    @Parameter(names = { "-tm", "--test-drive-metadata" },
         description = "Start H2 database with sample tables in same process.")
     private boolean meta;
 
     /** */
-    @Parameter(names = { "-ts", "--test-sql" },
+    @Parameter(names = { "-ts", "--test-drive-sql" },
         description = "Create cache and populate it with sample data for use in query.")
     private boolean sql;
 
@@ -159,6 +159,34 @@ public class AgentConfiguration {
     }
 
     /**
+     * @return {@code true} If metadata test drive should be started.
+     */
+    public boolean isTestDriveMeta() {
+        return meta;
+    }
+
+    /**
+     * @param meta Set to {@code true} if metadata test drive should be started.
+     */
+    public void setTestDriveMeta(boolean meta) {
+        this.meta = meta;
+    }
+
+    /**
+     * @return {@code true} If SQL test drive should be started.
+     */
+    public boolean isTestDriveSql() {
+        return sql;
+    }
+
+    /**
+     * @param sql Set to {@code true} if SQL test drive should be started.
+     */
+    public void setTestDriveSql(boolean sql) {
+        this.sql = sql;
+    }
+
+    /**
      * @param cfgUrl URL.
      */
     public void load(URL cfgUrl) throws IOException {
@@ -218,6 +246,12 @@ public class AgentConfiguration {
 
         if (cmd.getDriversFolder() != null)
             setDriversFolder(cmd.getDriversFolder());
+
+        if (cmd.isTestDriveMeta())
+            setTestDriveMeta(true);
+
+        if (cmd.isTestDriveSql())
+            setTestDriveSql(true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc9c8607/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
index a3afea2..163c4c0 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
@@ -19,6 +19,7 @@ package org.apache.ignite.agent;
 
 import com.beust.jcommander.*;
 import org.apache.ignite.agent.handlers.*;
+import org.apache.ignite.agent.testdrive.*;
 import org.eclipse.jetty.util.ssl.*;
 import org.eclipse.jetty.websocket.client.*;
 
@@ -76,6 +77,12 @@ public class AgentLauncher {
             cfg.setPassword(new String(System.console().readPassword()));
         }
 
+        if (cfg.isTestDriveMeta())
+            AgentMetadataTestDrive.testDrive();
+
+        if (cfg.isTestDriveSql())
+            AgentSqlTestDrive.testDrive();
+
         RestExecutor restExecutor = new RestExecutor(cfg);
 
         restExecutor.start();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc9c8607/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
new file mode 100644
index 0000000..6c75417
--- /dev/null
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
@@ -0,0 +1,75 @@
+package org.apache.ignite.agent.testdrive;
+
+import org.h2.tools.*;
+
+import java.sql.*;
+import java.util.logging.*;
+
+/**
+ * Test drive for metadata load from database.
+ *
+ * H2 database will be started and several tables will be created.
+ */
+public class AgentMetadataTestDrive {
+    /** */
+    private static final Logger log = Logger.getLogger(AgentMetadataTestDrive.class.getName());
+
+    /**
+     * Execute query.
+     *
+     * @param conn Connection to database.
+     * @param qry Statement to execute.
+     */
+    private static void query(Connection conn, String qry) throws SQLException {
+        try (PreparedStatement ps = conn.prepareStatement(qry)) {
+            ps.executeUpdate();
+        }
+    }
+
+    /**
+     * Start H2 database and populate it with several tables.
+     */
+    public static void testDrive() {
+        log.log(Level.INFO, "Starting in-memory H2 database for metadata test drive...");
+
+        try {
+            Connection conn = DriverManager.getConnection("jdbc:h2:mem:test-driver-db;DB_CLOSE_DELAY=-1",
"sa", "");
+
+            query(conn, "CREATE TABLE COUNTRY(ID INTEGER NOT NULL PRIMARY KEY, COUNTRY_NAME
VARCHAR(100))");
+            log.log(Level.INFO, "Table COUNTRY created.");
+
+            query(conn, "CREATE TABLE DEPARTMENT(" +
+                " DEPARTMENT_ID INTEGER  NOT NULL PRIMARY KEY," +
+                " DEPARTMENT_NAME VARCHAR(50) NOT NULL," +
+                " COUNTRY_ID INTEGER," +
+                " MANAGER_ID INTEGER)");
+            log.log(Level.INFO, "Table DEPARTMENT created.");
+
+            query(conn, "CREATE TABLE EMPLOYEE(" +
+                " EMPLOYEE_ID INTEGER NOT NULL PRIMARY KEY," +
+                " FIRST_NAME VARCHAR(20) NOT NULL," +
+                " LAST_NAME VARCHAR(30) NOT NULL," +
+                " EMAIL VARCHAR(25) NOT NULL," +
+                " PHONE_NUMBER VARCHAR(20)," +
+                " HIRE_DATE DATE NOT NULL," +
+                " JOB VARCHAR(50) NOT NULL," +
+                " SALARY DOUBLE," +
+                " MANAGER_ID INTEGER," +
+                " DEPARTMENT_ID INTEGER)");
+            log.log(Level.INFO, "Table EMPLOYEE created.");
+
+            query(conn, "CREATE INDEX EMP_SALARY_A ON EMPLOYEE(SALARY ASC)");
+            query(conn, "CREATE INDEX EMP_SALARY_B ON EMPLOYEE(SALARY DESC)");
+            query(conn, "CREATE INDEX EMP_NAMES ON EMPLOYEE(FIRST_NAME ASC, LAST_NAME  ASC)");
+            log.log(Level.INFO, "Indexes for table EMPLOYEE created.");
+
+            conn.close();
+
+            Server.createTcpServer("-tcpDaemon").start();
+
+            log.log(Level.INFO, "TcpServer stared.");
+        } catch (SQLException e) {
+            log.log(Level.SEVERE, "Failed to start test drive for metadata!", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bc9c8607/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
new file mode 100644
index 0000000..9c5c7e5
--- /dev/null
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
@@ -0,0 +1,15 @@
+package org.apache.ignite.agent.testdrive;
+
+/**
+ * Test drive for SQL.
+ *
+ * Cache will be created and populated with data to query.
+ */
+public class AgentSqlTestDrive {
+    /**
+     * TODO IGNITE-843
+     */
+    public static void testDrive() {
+
+    }
+}


Mime
View raw message