Skip to content
Snippets Groups Projects
Unverified Commit e9eca85f authored by Noah Moss's avatar Noah Moss Committed by GitHub
Browse files

Fix sync issue interfering with Cypress MongoDB snapshots (#19311)

parent df92ead3
No related branches found
No related tags found
No related merge requests found
......@@ -79,17 +79,9 @@ function recursiveCheck(id, i = 0) {
cy.wait(100);
cy.request("GET", `/api/database/${id}/metadata`).then(
({ body: { tables } }) => {
if (tables.length !== 4) {
recursiveCheck(id, ++i);
}
tables.forEach(({ fields }) => {
if (fields.length === 0) {
recursiveCheck(id, ++i);
}
});
},
);
cy.request("GET", `/api/database/${id}`).then(({ body: database }) => {
if (database.initial_sync_status !== "complete") {
recursiveCheck(id, ++i);
}
});
}
......@@ -17,13 +17,15 @@ describe("qa databases snapshots", () => {
restoreAndAuthenticate();
addMongoDatabase();
snapshot("mongo-4");
cy.wait(1000);
addMySQLDatabase();
snapshot("mysql-8");
restoreAndAuthenticate();
addMySQLDatabase();
snapshot("mysql-8");
cy.wait(1000);
addMongoDatabase();
snapshot("mongo-4");
restore("blank");
});
......
......@@ -78,7 +78,6 @@
(or (set-property! database (parse-keypath keypath) value)
(log/error (u/format-color 'red "Error syncing _metabase_metadata: no matching keypath: %s" keypath))))))
(s/defn is-metabase-metadata-table? :- s/Bool
"Is this TABLE the special `_metabase_metadata` table?"
[table :- i/DatabaseMetadataTable]
......@@ -91,9 +90,12 @@
[database :- i/DatabaseInstance]
(sync-util/with-error-handling (format "Error syncing _metabase_metadata table for %s"
(sync-util/name-for-logging database))
;; If there's more than one metabase metadata table (in different schemas) we'll sync each one in turn.
;; Hopefully this is never the case.
(doseq [table (:tables (fetch-metadata/db-metadata database))]
(when (is-metabase-metadata-table? table)
(sync-metabase-metadata-table! (driver.u/database->driver database) database table)))
{}))
(let [driver (driver.u/database->driver database)]
;; `sync-metabase-metadata-table!` relies on `driver/table-rows-seq` being defined
(when (get-method driver/table-rows-seq driver)
;; If there's more than one metabase metadata table (in different schemas) we'll sync each one in turn.
;; Hopefully this is never the case.
(doseq [table (:tables (fetch-metadata/db-metadata database))]
(when (is-metabase-metadata-table? table)
(sync-metabase-metadata-table! driver database table))))
{})))
......@@ -32,6 +32,8 @@
(defmethod driver/describe-table ::concurrent-sync-test [& _] nil)
(defmethod driver/table-rows-seq ::concurrent-sync-test [& _] [])
(deftest concurrent-sync-test
(testing "only one sync process be going on at a time"
;; describe-database gets called twice during a single sync process, once for syncing tables and a second time for
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment