drivaspreset commented on code in PR #43004:
URL: https://github.com/apache/superset/pull/43004#discussion_r4158969639


##########
superset-frontend/playwright/tests/dashboard/global-async-query-resilience.spec.ts:
##########
@@ -0,0 +1,424 @@
+/**
+ * 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.
+ */
+
+/**
+ * Global Async Queries (GAQ) under stress: a query that fails, a superseded
+ * query racing a newer one, a lost channel token, and a page torn down
+ * mid-flight.
+ *
+ * GAQ's happy path is visually identical to a synchronous load, so these are
+ * the cases where its machinery actually becomes observable -- or where it
+ * must stay invisible. The happy paths live in global-async-query.spec.ts.
+ *
+ * Requires the `GLOBAL_ASYNC_QUERIES` feature flag, Redis, and a running
+ * Celery worker.
+ */
+import { testWithAssets, expect } from '../../helpers/fixtures';
+import { apiGetChart, apiPutChart } from '../../helpers/api/chart';
+import { TIMEOUT } from '../../utils/constants';
+import { apiPost } from '../../helpers/api/requests';
+import {
+  BIG_NUMBER_COUNT_SPEC,
+  nativeFilterValuesIn,
+  setupDashboardWithBigNumberCharts,
+  setupDashboardWithSelectFilter,
+  sliceIdFromChartDataUrl,
+  trackGaqSignals,
+} from './dashboard-test-helpers';
+import { isFeatureEnabled } from '../../helpers/featureFlags';
+
+testWithAssets.beforeEach(async ({ page }) => {
+  await page.goto('chart/list/');
+  testWithAssets.skip(
+    !(await isFeatureEnabled(page, 'GLOBAL_ASYNC_QUERIES')),
+    'GLOBAL_ASYNC_QUERIES is not enabled on this instance',
+  );
+});
+
+testWithAssets(
+  'broken chart surfaces a clean error under GAQ instead of hanging, and 
recovers once fixed',
+  async ({ page, testAssets }) => {
+    // Two forced refreshes plus an API round-trip between them exceed the
+    // default timeout on a loaded runner.
+    testWithAssets.setTimeout(TIMEOUT.SLOW_TEST);
+
+    const BAD_COLUMN = 'this_column_does_not_exist_gaq_test';
+
+    // A custom SQL metric on a nonexistent column fails in Postgres, not in
+    // client-side validation -- so the job really is queued and run, and this
+    // exercises the async error path rather than a request that never ships.
+    const { dashboardId, dashboard, charts, valueLocators } =
+      await setupDashboardWithBigNumberCharts(
+        page,
+        testAssets,
+        testWithAssets.info(),
+        {
+          datasetName: 'birth_names',
+          chartNamePrefix: 'gaq_tc3_broken_chart',
+          chartSpecs: [
+            {
+              viz_type: 'big_number_total',
+              params: {
+                metric: {
+                  expressionType: 'SQL',
+                  sqlExpression: `SUM(${BAD_COLUMN})`,
+                  label: 'broken_metric',
+                  hasCustomLabel: true,
+                },
+              },
+            },
+          ],
+        },
+      );
+    const [chart] = charts;
+    const [value] = valueLocators;
+    const errorAlert = 
dashboard.getChart(chart.id).locator('.ant-alert-error');

Review Comment:
   Agreed on both halves: the alert is already on screen from the initial load, 
and the refresh re-runs the identical broken query, so those three assertions 
hold up whether the refresh completed or the DOM never changed.
   
   Fixed in 50d2bf7b7d by requiring the failure to come back over the wire on 
the refresh's own traffic, before the alert is looked at:
   
   ```ts
   expect(
     responseBodies.filter(body => body.includes(BAD_COLUMN)),
     "the refresh's own chart-data response should carry the failure, rather 
than the alert being left over from the initial load",
   ).not.toHaveLength(0);
   ```
   
   `responseBodies` is captured from a listener attached alongside 
`trackGaqSignals`, i.e. after the initial load has settled, so only the 
refresh's responses can satisfy it. That is stronger than the fresh-task-id 
option you suggested: it is not just that a new task was queued and polled, but 
that the rendered failure is the one this cycle produced.
   
   The alert assertions still run, moved below so they read as confirming the 
rendering rather than carrying the proof.



##########
superset-frontend/playwright/tests/dashboard/global-async-query-resilience.spec.ts:
##########
@@ -0,0 +1,424 @@
+/**
+ * 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.
+ */
+
+/**
+ * Global Async Queries (GAQ) under stress: a query that fails, a superseded
+ * query racing a newer one, a lost channel token, and a page torn down

Review Comment:
   Both correct. Fixed in 50d2bf7b7d — the header now names what the four tests 
here actually cover:
   
   ```
    * Global Async Queries (GAQ) under stress: a query that fails, a superseded
    * query racing a newer one, a programmatic request that must stay 
synchronous,
    * and a page torn down mid-flight.
   ```
   
   The "belongs to 'girl'" line is gone; it had been true of the original 
arrival-order check and stopped being true the moment the payload-correlated 
`statusesFor` landed. Both strings are now at zero occurrences in the file.
   
   While here I also cut the comment blocks that had drifted into restating the 
code rather than explaining it, across this file, `dashboard-test-helpers.ts` 
and the SQL Lab spec (comment lines 100 -> 92, 242 -> 220, 43 -> 34).



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to