You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@zeppelin.apache.org by "kimyenac (via GitHub)" <gi...@apache.org> on 2026/10/03 14:11:32 UTC

[PR] [ZEPPELIN-6675] Prove the notebook route can consume the Shared Notebook Core port [zeppelin]

kimyenac opened a new pull request, #5527:
URL: https://github.com/apache/zeppelin/pull/5527

   ### What is this PR for?
   
   Add a browser proof that the current Angular notebook route can hand one host-owned `NotebookCorePort` to a separately built React consumer. This builds on the ZEPPELIN-6674 port identity proof and moves it onto the real notebook route.
   
   * The proof harness bootstraps the production `WorkspaceModule` and `NotebookModule` lazy routes and asserts that the activated component is the production `NotebookComponent`.
   * It reads the activated `/notebook/:noteId` and `/notebook/:noteId/revision/:revisionId` parameters into one host-owned test Core. The React consumer reads the snapshot and receives route-driven subscription updates (note → other note → revision), always through the same port object.
   * A browser-only `MessageService` double records the production component's `getNote`, `noteRevision` and `listRevisionHistory` requests, and the test asserts their exact order.
   
   This is a seam-only proof. It does not switch the production renderer, move notebook state out of Angular, or implement re-subscription, recovery or mutation reducers (ZEPPELIN-6687).
   
   The implementation is based on the `ZEPPELIN-6675-notebook-route-boundary` branch in the voidmatcha fork (`823183338`), which was written before ZEPPELIN-6674 merged. Porting it onto current `master`:
   
   * **CI wiring:** the route proof runs in the `integration-test` phase behind `web.e2e.core.port.proof.disabled`, the same as the merged port identity proof, so it runs on the anonymous leg of `run-playwright-e2e-tests`. The branch bound it to the `test` phase with `${skipTests}`, which `frontend.yml`'s `-DskipTests` build skips.
   * **Shared static server:** it now returns 404 for unknown paths, matching the merged ZEPPELIN-6674 review change, instead of serving `index.html`.
   * **Message double:** it gains `receiveEnvelope`, added to `MessageService` by ZEPPELIN-6683. Without it, the workspace route did not render.
   * **Theme double:** it gains `getCurrentTheme` and `theme$`. Without them, `ThemeToggleComponent` throws in `ngOnInit`. The original test did not catch this, because Angular's `ErrorHandler` reports it through `console.error('ERROR', ...)` and never as a `pageerror`. The test now fails on those errors too. Removing the theme fix makes it fail with `this.themeService.getCurrentTheme is not a function`.
   * **Lifecycle boundary is now asserted, not only documented:**
     * the port's own keys are exactly `getSnapshot` and `subscribe`, and the port is frozen;
     * route activation and port consumption make no `bootstrap`, `connect` or `close` call.
   * **README:** the section moves to the end of `e2e/core-contract/README.md` instead of splitting the replay subsections. It describes the actual CI wiring and notes that ZEPPELIN-6683's stale-reply rejection lives inside `NotebookComponent` and is not moved into the Core.
   * **Kept as is:** the route path constants (`notebook-route-boundary.ts`). Production code changes are limited to extracting the existing route paths into those constants, which both the routing modules and the proof use.
   * **Dropped from the branch:** the `./NotebookRouteBoundaryProbe` webpack alias (it re-exposed the same module), and unused route-proof `proofs` state.
   
   ### What type of PR is it?
   Improvement
   
   ### Todos
   * [x] Run the route proof on the production notebook routes with one host-owned port
   * [x] Assert route-driven snapshot and subscription updates through the same port
   * [x] Assert the port shape and that the connection lifecycle is not reached
   * [x] Run it through the normal browser CI path
   * [x] Record host-side responsibilities and what remains outside this proof
   
   ### What is the Jira issue?
   [ZEPPELIN-6675](https://issues.apache.org/jira/browse/ZEPPELIN-6675)
   
   ### How should this be tested?
   
   ```bash
   cd zeppelin-web-angular
   npm run build:projects
   npm run build:notebook-core-port-proof
   npm run test:notebook-core-port-identity
   npm run test:notebook-route-boundary
   ```
   
   What I ran locally (after rebasing onto `6a5ed4459`):
   * Both browser proofs passed. Also passing:
     * `test:notebook-core`, `typecheck:notebook-core`
     * `check:core-contract-fixtures`, `test:shell`
     * prettier and eslint on the changed files
   * `./mvnw verify -pl zeppelin-web-angular -Pweb-e2e` (before the rebase): the proof build, the port identity proof and the route proof passed in `integration-test`.
   * The main Playwright suite finished with 749 passed and 20 failed. Rerunning only the failing specs with one worker left 6 failures:
     * `paragraph-functionality.spec.ts:174` and `:335`, on all three browsers;
     * both execute `%python`, and every failure context shows `Fail to launch python process` from my local Python setup;
     * the other 14 failures passed when run serially.
   * **Not run locally:** the classic UI e2e. The maven run stopped after the main suite because I ran it without `CI=true`, so the HTML reporter waited for input. This PR does not touch `zeppelin-web`.
   * I checked that each build setting kept from the branch is still required by building without it:
     * `mathjax` types: without them, the `MathJax` directive fails to compile;
     * the custom webpack builder: without it, Monaco CSS fails to parse;
     * the style include paths: without them, the components' `.less` imports fail to resolve.
   
   ### Screenshots (if appropriate)
   
   N/A.
   
   ### Questions:
   * Does the license files need to update? No. New files carry the ASF header.
   * Is there breaking changes for older versions? No. Route shapes and behaviour are unchanged.
   * Does this needs documentation? `e2e/core-contract/README.md` is updated.
   
   Unrelated, found while testing: production `main.js` builds the Monaco `codicon.ttf` URL from the build machine's absolute `file:///` path, so the browser refuses to load that font. It also happens on `master`.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6675] Prove the notebook route can consume the Shared Notebook Core port [zeppelin]

Posted by "voidmatcha (via GitHub)" <gi...@apache.org>.
voidmatcha commented on code in PR #5527:
URL: https://github.com/apache/zeppelin/pull/5527#discussion_r4175363232


##########
zeppelin-web-angular/e2e/core-contract/proof-browser-harness.mjs:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+import assert from 'node:assert/strict';
+import { createReadStream, existsSync, statSync } from 'node:fs';
+import { createServer } from 'node:http';
+import { extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
+import { pathToFileURL } from 'node:url';
+
+import { chromium } from '@playwright/test';
+
+const angularDistRoot = resolve('dist/notebook-core-port-proof');
+const angularIndexPath = join(angularDistRoot, 'index.html');
+const remoteEntryPath = join(angularDistRoot, 'assets/react/remoteEntry.js');
+
+const contentTypes = new Map([
+  ['.css', 'text/css; charset=utf-8'],
+  ['.html', 'text/html; charset=utf-8'],
+  ['.js', 'text/javascript; charset=utf-8']
+]);
+
+function resolveStaticFile(requestPath) {
+  let decodedPath;
+  try {
+    decodedPath = decodeURIComponent(requestPath.replace(/^\//, ''));
+  } catch {
+    return null;
+  }
+
+  const filePath = resolve(angularDistRoot, decodedPath);
+  const rootRelativePath = relative(angularDistRoot, filePath);
+  const escapesRoot =
+    rootRelativePath === '..' || rootRelativePath.startsWith(`..${sep}`) || isAbsolute(rootRelativePath);
+
+  if (escapesRoot || !existsSync(filePath) || !statSync(filePath).isFile()) {
+    return null;
+  }
+
+  return filePath;
+}
+
+function serveFile(response, filePath) {
+  response.writeHead(200, {
+    'cache-control': 'no-store',
+    'content-type': contentTypes.get(extname(filePath)) ?? 'application/octet-stream'
+  });
+  createReadStream(filePath).pipe(response);
+}
+
+export async function startNotebookCoreProofHarness() {
+  assert.ok(
+    existsSync(angularIndexPath),
+    `Angular host build output is missing: run "npm run build:notebook-core-port-proof" before this proof (${pathToFileURL(
+      angularIndexPath
+    )})`
+  );
+  assert.ok(
+    existsSync(remoteEntryPath),
+    `React remote asset is missing: run "npm run build:notebook-core-port-proof" before this proof (${pathToFileURL(
+      remoteEntryPath
+    )})`
+  );
+
+  const server = createServer((request, response) => {
+    const requestPath = request.url?.split('?')[0] ?? '/';
+    const staticFilePath = resolveStaticFile(requestPath);
+
+    if (requestPath === '/') {
+      serveFile(response, angularIndexPath);
+      return;
+    }
+
+    if (staticFilePath) {
+      serveFile(response, staticFilePath);
+      return;
+    }
+
+    response.writeHead(404, { 'cache-control': 'no-store' });
+    response.end();
+  });
+
+  await new Promise(resolveListen => {
+    server.listen(0, '127.0.0.1', resolveListen);
+  });
+  const address = server.address();
+  assert.ok(address && typeof address === 'object');
+  const browser = await chromium.launch();

Review Comment:
   If Chromium fails to launch, the harness never returns its cleanup handle, leaving the HTTP server open. We close local test servers on failure in [capture-fixtures.spec.ts](https://github.com/apache/zeppelin/blob/7c00dee8673e1da2f6b85329389cd0918e5c3d9a/zeppelin-web-angular/e2e/tests/notebook/core-contract/capture-fixtures.spec.ts#L205-L212). Could we cover this failure path here too?
   
   ```suggestion
     let browser;
     try {
       browser = await chromium.launch();
     } catch (error) {
       await new Promise(resolve => server.close(resolve));
       throw error;
     }
   ```



-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6675] Prove the notebook route can consume the Shared Notebook Core port [zeppelin]

Posted by "voidmatcha (via GitHub)" <gi...@apache.org>.
voidmatcha commented on PR #5527:
URL: https://github.com/apache/zeppelin/pull/5527#issuecomment-6030203563

   Merged into master (6c87bece).


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6675] Prove the notebook route can consume the Shared Notebook Core port [zeppelin]

Posted by "kimyenac (via GitHub)" <gi...@apache.org>.
kimyenac commented on code in PR #5527:
URL: https://github.com/apache/zeppelin/pull/5527#discussion_r4191262461


##########
zeppelin-web-angular/e2e/core-contract/proof-browser-harness.mjs:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+import assert from 'node:assert/strict';
+import { createReadStream, existsSync, statSync } from 'node:fs';
+import { createServer } from 'node:http';
+import { extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
+import { pathToFileURL } from 'node:url';
+
+import { chromium } from '@playwright/test';
+
+const angularDistRoot = resolve('dist/notebook-core-port-proof');
+const angularIndexPath = join(angularDistRoot, 'index.html');
+const remoteEntryPath = join(angularDistRoot, 'assets/react/remoteEntry.js');
+
+const contentTypes = new Map([
+  ['.css', 'text/css; charset=utf-8'],
+  ['.html', 'text/html; charset=utf-8'],
+  ['.js', 'text/javascript; charset=utf-8']
+]);
+
+function resolveStaticFile(requestPath) {
+  let decodedPath;
+  try {
+    decodedPath = decodeURIComponent(requestPath.replace(/^\//, ''));
+  } catch {
+    return null;
+  }
+
+  const filePath = resolve(angularDistRoot, decodedPath);
+  const rootRelativePath = relative(angularDistRoot, filePath);
+  const escapesRoot =
+    rootRelativePath === '..' || rootRelativePath.startsWith(`..${sep}`) || isAbsolute(rootRelativePath);
+
+  if (escapesRoot || !existsSync(filePath) || !statSync(filePath).isFile()) {
+    return null;
+  }
+
+  return filePath;
+}
+
+function serveFile(response, filePath) {
+  response.writeHead(200, {
+    'cache-control': 'no-store',
+    'content-type': contentTypes.get(extname(filePath)) ?? 'application/octet-stream'
+  });
+  createReadStream(filePath).pipe(response);
+}
+
+export async function startNotebookCoreProofHarness() {
+  assert.ok(
+    existsSync(angularIndexPath),
+    `Angular host build output is missing: run "npm run build:notebook-core-port-proof" before this proof (${pathToFileURL(
+      angularIndexPath
+    )})`
+  );
+  assert.ok(
+    existsSync(remoteEntryPath),
+    `React remote asset is missing: run "npm run build:notebook-core-port-proof" before this proof (${pathToFileURL(
+      remoteEntryPath
+    )})`
+  );
+
+  const server = createServer((request, response) => {
+    const requestPath = request.url?.split('?')[0] ?? '/';
+    const staticFilePath = resolveStaticFile(requestPath);
+
+    if (requestPath === '/') {
+      serveFile(response, angularIndexPath);
+      return;
+    }
+
+    if (staticFilePath) {
+      serveFile(response, staticFilePath);
+      return;
+    }
+
+    response.writeHead(404, { 'cache-control': 'no-store' });
+    response.end();
+  });
+
+  await new Promise(resolveListen => {
+    server.listen(0, '127.0.0.1', resolveListen);
+  });
+  const address = server.address();
+  assert.ok(address && typeof address === 'object');
+  const browser = await chromium.launch();

Review Comment:
   Applied in f38120bd0. I named the callback `resolveClose` instead of `resolve`, because this file imports `resolve` from `node:path`. I checked the failure path by pointing `PLAYWRIGHT_BROWSERS_PATH` at an empty directory. Before the change the process never exited because the server stayed open. After it, the proof fails immediately with the launch error.



-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6675] Prove the notebook route can consume the Shared Notebook Core port [zeppelin]

Posted by "voidmatcha (via GitHub)" <gi...@apache.org>.
voidmatcha merged PR #5527:
URL: https://github.com/apache/zeppelin/pull/5527


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org