From d61520f1d221cf1dbd37e49f9cd4af15987f0530 Mon Sep 17 00:00:00 2001 From: Cam Saul <cam@geotip.com> Date: Mon, 29 Jun 2015 21:42:50 -0700 Subject: [PATCH] :generic-sql "dataset" -> :h2 --- circle.yml | 2 +- src/metabase/driver/sync.clj | 2 +- test/metabase/api/meta/db_test.clj | 4 +-- test/metabase/driver/query_processor_test.clj | 22 +++++++-------- test/metabase/test/data/datasets.clj | 27 +++++++++---------- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/circle.yml b/circle.yml index 6ef77e78377..71826e82dc7 100644 --- a/circle.yml +++ b/circle.yml @@ -11,5 +11,5 @@ test: # 2) runs Eastwood linter + Bikeshed linter # 3) runs JS linter + JS test # 4) runs lein uberjar - - case $CIRCLE_NODE_INDEX in 0) MB_TEST_DATASETS=generic-sql,mongo,postgres lein test ;; 1) MB_DB_TYPE=postgres MB_DB_DBNAME=circle_test MB_DB_PORT=5432 MB_DB_USER=ubuntu MB_DB_HOST=localhost lein test ;; 2) lein eastwood && lein bikeshed --max-line-length 240 ;; 3) npm run lint && npm run build && npm run test ;; 4) CI_DISABLE_WEBPACK_MINIFICATION=1 lein uberjar ;; esac: + - case $CIRCLE_NODE_INDEX in 0) MB_TEST_DATASETS=h2,mongo,postgres lein test ;; 1) MB_DB_TYPE=postgres MB_DB_DBNAME=circle_test MB_DB_PORT=5432 MB_DB_USER=ubuntu MB_DB_HOST=localhost lein test ;; 2) lein eastwood && lein bikeshed --max-line-length 240 ;; 3) npm run lint && npm run build && npm run test ;; 4) CI_DISABLE_WEBPACK_MINIFICATION=1 lein uberjar ;; esac: parallel: true diff --git a/src/metabase/driver/sync.clj b/src/metabase/driver/sync.clj index 1989db72a26..90fcc3abb97 100644 --- a/src/metabase/driver/sync.clj +++ b/src/metabase/driver/sync.clj @@ -34,7 +34,7 @@ (binding [qp/*disable-qp-logging* true] (sync-in-context driver database (fn [] - (log/info (color/blue (format "Syncing database %s..." (:name database)))) + (log/info (u/format-color 'blue "Syncing %s database %s..." (name (:engine database)) (:name database))) (let [active-table-names (active-table-names driver database) table-name->id (sel :many :field->id [Table :name] :db_id (:id database) :active true)] diff --git a/test/metabase/api/meta/db_test.clj b/test/metabase/api/meta/db_test.clj index 3d5975dcd1f..3ac321a74f7 100644 --- a/test/metabase/api/meta/db_test.clj +++ b/test/metabase/api/meta/db_test.clj @@ -109,7 +109,7 @@ (let [db-name (str "A" (random-name))] ; make sure this name comes before "Test Database" (expect-eval-actual-first (set (filter identity - [(datasets/when-testing-dataset :generic-sql + [(datasets/when-testing-dataset :h2 (match-$ (sel :one Database :name db-name) {:created_at $ :engine "postgres" @@ -141,7 +141,7 @@ (do ;; Delete all the randomly created Databases we've made so far (cascade-delete Database :id [not-in (set (filter identity - [(datasets/when-testing-dataset :generic-sql + [(datasets/when-testing-dataset :h2 (db-id)) (datasets/when-testing-dataset :mongo @mongo-test-data/mongo-test-db-id)]))]) diff --git a/test/metabase/driver/query_processor_test.clj b/test/metabase/driver/query_processor_test.clj index 1654dfed893..64c0f97de7f 100644 --- a/test/metabase/driver/query_processor_test.clj +++ b/test/metabase/driver/query_processor_test.clj @@ -615,7 +615,7 @@ ;;; SQL-Only for the time being ;; ## "STDDEV" AGGREGATION -(qp-expect-with-datasets #{:generic-sql} +(qp-expect-with-datasets #{:h2 :postgres} {:columns ["stddev"] :cols [(aggregate-col :stddev (venues-col :latitude))] :rows [[3.43467255295115]]} @@ -635,7 +635,7 @@ ;;; ## order_by aggregate fields (SQL-only for the time being) ;;; ### order_by aggregate ["count"] -(qp-expect-with-datasets #{:generic-sql} +(qp-expect-with-datasets #{:h2 :postgres} {:columns [(format-name "price") "count"] :rows [[4 6] @@ -667,7 +667,7 @@ ;;; ### order_by aggregate ["distinct" field-id] -(qp-expect-with-datasets #{:generic-sql} +(qp-expect-with-datasets #{:h2 :postgres} {:columns [(format-name "price") "count"] :rows [[4 6] @@ -683,7 +683,7 @@ ;;; ### order_by aggregate ["avg" field-id] -(qp-expect-with-datasets #{:generic-sql} +(qp-expect-with-datasets #{:h2 :postgres} {:columns [(format-name "price") "avg"] :rows [[3 22] @@ -698,7 +698,7 @@ :order_by [[["aggregation" 0] "ascending"]]}) ;;; ### order_by aggregate ["stddev" field-id] -(qp-expect-with-datasets #{:generic-sql} +(qp-expect-with-datasets #{:h2 :postgres} {:columns [(format-name "price") "stddev"] :rows [[3 26.19160170741759] @@ -782,7 +782,7 @@ :query ~query}))) ;; There were 9 "sad toucan incidents" on 2015-06-02 -(datasets/expect-with-datasets #{:generic-sql :postgres} +(datasets/expect-with-datasets #{:h2 :postgres} 9 (->> (query-with-temp-db defs/sad-toucan-incidents :source_table &incidents:id @@ -803,7 +803,7 @@ (map (fn [[^java.util.Date date count]] [(.toString date) (int count)]))))] - (datasets/expect-with-dataset :generic-sql + (datasets/expect-with-dataset :h2 [["2015-06-01" 6] ["2015-06-02" 9] ["2015-06-03" 5] @@ -839,7 +839,7 @@ ;; The top 10 cities by number of Tupac sightings ;; Test that we can breakout on an FK field ;; (Note how the FK Field is returned in the results) -(datasets/expect-with-datasets #{:generic-sql} +(datasets/expect-with-datasets #{:h2 :postgres} [[16 "Arlington"] [15 "Albany"] [14 "Portland"] @@ -862,7 +862,7 @@ ;; Number of Tupac sightings in the Expa office ;; (he was spotted here 60 times) ;; Test that we can filter on an FK field -(datasets/expect-with-datasets #{:generic-sql} +(datasets/expect-with-datasets #{:h2 :postgres} 60 (-> (query-with-temp-db defs/tupac-sightings :source_table &sightings:id @@ -874,7 +874,7 @@ ;; THE 10 MOST RECENT TUPAC SIGHTINGS (!) ;; (What he was doing when we saw him, sighting ID) ;; Check that we can include an FK field in the :fields clause -(datasets/expect-with-datasets #{:generic-sql} +(datasets/expect-with-datasets #{:h2 :postgres} [["In the Park" 772] ["Working at a Pet Store" 894] ["At the Airport" 684] @@ -897,7 +897,7 @@ ;; (this query targets sightings and orders by cities.name and categories.name) ;; 2. Check that we can join MULTIPLE tables in a single query ;; (this query joins both cities and categories) -(datasets/expect-with-datasets #{:generic-sql} +(datasets/expect-with-datasets #{:h2 :postgres} ;; CITY_ID, CATEGORY_ID, ID ;; Cities are already alphabetized in the source data which is why CITY_ID is sorted [[1 12 6] diff --git a/test/metabase/test/data/datasets.clj b/test/metabase/test/data/datasets.clj index 0a52ebeb28b..4d4fda20b8f 100644 --- a/test/metabase/test/data/datasets.clj +++ b/test/metabase/test/data/datasets.clj @@ -67,14 +67,12 @@ (field-name->id [_ table-name field-name] (mongo-data/field-name->id table-name (if (= field-name :id) :_id field-name))) - (fks-supported? [_] false) - (format-name [_ table-or-field-name] (if (= table-or-field-name "id") "_id" table-or-field-name)) - (id-field-type [_] :IntegerField) - + (fks-supported? [_] false) + (id-field-type [_] :IntegerField) (timestamp-field-type [_] :DateField)) @@ -160,10 +158,9 @@ (def dataset-name->dataset "Map of dataset keyword name -> dataset instance (i.e., an object that implements `IDataset`)." - {:mongo (MongoDriverData.) - :generic-sql (H2DriverData. (promise)) - :postgres (PostgresDriverData. (promise))}) -;; TODO - :generic-sql should be renamed H2 + {:mongo (MongoDriverData.) + :h2 (H2DriverData. (promise)) + :postgres (PostgresDriverData. (promise))}) (def ^:const all-valid-dataset-names "Set of names of all valid datasets." @@ -172,13 +169,13 @@ ;; # Logic for determining which datasets to test against -;; By default, we'll test against against only the :generic-sql (H2) dataset; otherwise, you can specify which +;; By default, we'll test against against only the :h2 (H2) dataset; otherwise, you can specify which ;; datasets to test against by setting the env var `MB_TEST_DATASETS` to a comma-separated list of dataset names, e.g. ;; -;; # test against :generic-sql and :mongo +;; # test against :h2 and :mongo ;; MB_TEST_DATASETS=generic-sql,mongo ;; -;; # just test against :generic-sql (default) +;; # just test against :h2 (default) ;; MB_TEST_DATASETS=generic-sql (defn- get-test-datasets-from-env @@ -197,9 +194,9 @@ (def test-dataset-names "Delay that returns set of names of drivers we should run tests against. - By default, this returns only `:generic-sql`, but can be overriden by setting env var `MB_TEST_DATASETS`." + By default, this returns only `:h2` but can be overriden by setting env var `MB_TEST_DATASETS`." (delay (let [datasets (or (get-test-datasets-from-env) - #{:generic-sql})] + #{:h2})] (log/info (color/green "Running QP tests against these datasets: " datasets)) datasets))) @@ -208,8 +205,8 @@ (def ^:dynamic *dataset* "The dataset we're currently testing against, bound by `with-dataset`. - Defaults to `:generic-sql`." - (dataset-name->dataset :generic-sql)) + Defaults to `:h2`." + (dataset-name->dataset :h2)) (defmacro with-dataset "Bind `*dataset*` to the dataset with DATASET-NAME and execute BODY." -- GitLab