tbonelee commented on code in PR #5128:
URL: https://github.com/apache/zeppelin/pull/5128#discussion_r2597207702
##########
zeppelin-web-angular/pom.xml:
##########
@@ -151,9 +151,15 @@
<configuration>
<skip>${web.e2e.disabled}</skip>
<target unless="skipTests">
- <exec executable="./zeppelin-daemon.sh"
dir="${zeppelin.daemon.package.base}" spawn="false">
- <arg value="start" />
- </exec>
+ <condition property="zeppelin.notebook.dir"
value="${env.ZEPPELIN_E2E_TEST_NOTEBOOK_DIR}">
+ <isset property="env.ZEPPELIN_E2E_TEST_NOTEBOOK_DIR" />
+ </condition>
+ <property name="zeppelin.notebook.dir"
value="/tmp/zeppelin-e2e-notebooks" />
+ <exec executable="./zeppelin-daemon.sh"
dir="${zeppelin.daemon.package.base}" spawn="false">
+ <arg value="start" />
+ <env key="ZEPPELIN_NOTEBOOK_DIR"
value="${zeppelin.notebook.dir}" />
+ <env key="PATH" value="${env.PATH}" />
+ </exec>
Review Comment:
If my understanding is correct, it seems that
`ZEPPELIN_E2E_TST_NOTEBOOK_DIR` is implicitly required to match
`zeppelin.notebook.dir` to clean up the test notebook directory.
If we can't immediately restructure the code to remove this implicit
constraint, it may help to explicitly document the constraint in a comment so
the relationship is clearer to future readers.
##########
zeppelin-web-angular/e2e/cleanup-util.ts:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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 { E2E_TEST_FOLDER } from './models/base-page';
+
+export const cleanupTestNotebooks = async () => {
+ try {
+ console.log('Cleaning up test folder via API...');
+
+ const baseURL = 'http://localhost:4200';
Review Comment:
Can we extract the URL or port to somewhere so that we have a single source
of truth for the base URL?
##########
zeppelin-web-angular/e2e/cleanup-util.ts:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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 { E2E_TEST_FOLDER } from './models/base-page';
+
+export const cleanupTestNotebooks = async () => {
+ try {
+ console.log('Cleaning up test folder via API...');
+
+ const baseURL = 'http://localhost:4200';
+
+ // Get all notebooks and folders
+ const response = await fetch(`${baseURL}/api/notebook`);
+ const data = await response.json();
+ if (!data.body || !Array.isArray(data.body)) {
+ console.log('No notebooks found or invalid response format');
+ return;
+ }
+
+ // Find the test folder
+ const testFolders = data.body.filter(
+ (item: { path: string }) =>
+ item.path && item.path.split(E2E_TEST_FOLDER)[0] === '/' &&
!item.path.includes(`~Trash`)
+ );
+
+ if (testFolders.length === 0) {
+ console.log('No test folder found to clean up');
+ return;
+ }
+
+ await Promise.all(
+ testFolders.map(async (testFolder: { id: string; path: string }) => {
+ try {
+ console.log(`Deleting test folder: ${testFolder.id}
(${testFolder.path})`);
+
+ const deleteResponse = await
fetch(`${baseURL}/api/notebook/${testFolder.id}`, {
+ method: 'DELETE'
+ });
+
+ // Although a 500 status code is generally not considered a
successful response,
+ // this API returns 500 even when the operation actually succeeds.
+ // I'll investigate this further and create an issue.
+ if (deleteResponse.status === 200 || deleteResponse.status === 500) {
+ console.log(`Deleted test folder: ${testFolder.path}`);
+ } else {
+ console.warn(`Failed to delete test folder ${testFolder.path}:
${deleteResponse.status}`);
+ }
+ } catch (error) {
+ console.error(`Error deleting test folder ${testFolder.path}:`,
error);
+ }
+ })
+ );
+
+ console.log('Test folder cleanup completed');
+ } catch (error) {
+ if (error instanceof Error && error.message.includes('ECONNREFUSED')) {
+ console.error('Failed to connect to local server. Please start the
frontend server first:');
+ console.error(' npm start');
+ console.error(' or make sure http://localhost:4200 is running');
Review Comment:
The same comment applies to this URL string as well.
--
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]