Skip to content

Commit 4832462

Browse files
Add UI table to regression and functionality tests
1 parent a8ba6f7 commit 4832462

File tree

3 files changed

+66
-13
lines changed

3 files changed

+66
-13
lines changed

.github/workflows/ui_notebooks_test.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ jobs:
8686
jq -r 'del(.cells[] | select(.source[] | contains("Create authentication object for user permissions")))' 3_widget_example.ipynb > 3_widget_example.ipynb.tmp && mv 3_widget_example.ipynb.tmp 3_widget_example.ipynb
8787
jq -r 'del(.cells[] | select(.source[] | contains("auth.logout()")))' 3_widget_example.ipynb > 3_widget_example.ipynb.tmp && mv 3_widget_example.ipynb.tmp 3_widget_example.ipynb
8888
# Set explicit namespace as SDK need it (currently) to resolve local queues
89-
sed -i "s/head_memory_limits=2,/head_memory_limits=2, namespace='default',/" 3_widget_example.ipynb
89+
sed -i "s/head_memory_limits=2,/head_memory_limits=2, namespace='default', image="quay.io/modh/ray:2.35.0-py39-cu121",/" 3_widget_example.ipynb
90+
sed -i "s/view_clusters()/view_clusters('default')/" 3_widget_example.ipynb
9091
working-directory: demo-notebooks/guided-demos
9192

9293
- name: Run UI notebook tests

demo-notebooks/guided-demos/3_widget_example.ipynb

+14-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"outputs": [],
2020
"source": [
2121
"# Import pieces from codeflare-sdk\n",
22-
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication"
22+
"from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication, view_clusters"
2323
]
2424
},
2525
{
@@ -61,7 +61,7 @@
6161
"# Create and configure our cluster object\n",
6262
"# The SDK will try to find the name of your default local queue based on the annotation \"kueue.x-k8s.io/default-queue\": \"true\" unless you specify the local queue manually below\n",
6363
"cluster = Cluster(ClusterConfiguration(\n",
64-
" name='raytest', \n",
64+
" name='raytest',\n",
6565
" head_cpu_requests='500m',\n",
6666
" head_cpu_limits='500m',\n",
6767
" head_memory_requests=2,\n",
@@ -73,12 +73,22 @@
7373
" worker_cpu_limits=1,\n",
7474
" worker_memory_requests=2,\n",
7575
" worker_memory_limits=2,\n",
76-
" # image=\"\", # Optional Field \n",
77-
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources \n",
76+
" # image=\"\", # Optional Field\n",
77+
" write_to_file=False, # When enabled Ray Cluster yaml files are written to /HOME/.codeflare/resources\n",
7878
" # local_queue=\"local-queue-name\" # Specify the local queue manually\n",
7979
"))"
8080
]
8181
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": null,
85+
"id": "3de6403c",
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"view_clusters()"
90+
]
91+
},
8292
{
8393
"cell_type": "code",
8494
"execution_count": null,

ui-tests/tests/widget_notebook_example.test.ts

+50-8
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ test.describe("Visual Regression", () => {
3030
tmpPath,
3131
}) => {
3232
const notebook = "3_widget_example.ipynb";
33+
const namespace = 'default';
3334
await page.notebook.openByPath(`${tmpPath}/${notebook}`);
3435
await page.notebook.activate(notebook);
3536

3637
const captures: (Buffer | null)[] = []; // Array to store cell screenshots
3738
const cellCount = await page.notebook.getCellCount();
39+
console.log(`Cell count: ${cellCount}`);
3840

3941
// Run all cells and capture their screenshots
4042
await page.notebook.runCellByCell({
@@ -59,25 +61,27 @@ test.describe("Visual Regression", () => {
5961
}
6062
}
6163

62-
const widgetCellIndex = 3;
64+
// At this point, all cells have been ran, and their screenshots have been captured.
65+
// We now interact with the widgets in the notebook.
66+
const upDownWidgetCellIndex = 3; // 4 on OpenShift
6367

64-
await waitForWidget(page, widgetCellIndex, 'input[type="checkbox"]');
65-
await waitForWidget(page, widgetCellIndex, 'button:has-text("Cluster Down")');
66-
await waitForWidget(page, widgetCellIndex, 'button:has-text("Cluster Up")');
68+
await waitForWidget(page, upDownWidgetCellIndex, 'input[type="checkbox"]');
69+
await waitForWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Down")');
70+
await waitForWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Up")');
6771

68-
await interactWithWidget(page, widgetCellIndex, 'input[type="checkbox"]', async (checkbox) => {
72+
await interactWithWidget(page, upDownWidgetCellIndex, 'input[type="checkbox"]', async (checkbox) => {
6973
await checkbox.click();
7074
const isChecked = await checkbox.isChecked();
7175
expect(isChecked).toBe(true);
7276
});
7377

74-
await interactWithWidget(page, widgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
78+
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
7579
await button.click();
7680
const clusterDownMessage = await page.waitForSelector('text=No instances found, nothing to be done.', { timeout: 5000 });
7781
expect(clusterDownMessage).not.toBeNull();
7882
});
7983

80-
await interactWithWidget(page, widgetCellIndex, 'button:has-text("Cluster Up")', async (button) => {
84+
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Up")', async (button) => {
8185
await button.click();
8286

8387
const successMessage = await page.waitForSelector('text=Ray Cluster: \'raytest\' has successfully been created', { timeout: 10000 });
@@ -95,13 +99,51 @@ test.describe("Visual Regression", () => {
9599

96100
await runPreviousCell(page, cellCount, '(<CodeFlareClusterStatus.READY: 1>, True)');
97101

98-
await interactWithWidget(page, widgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
102+
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Down")', async (button) => {
99103
await button.click();
100104
const clusterDownMessage = await page.waitForSelector('text=Ray Cluster: \'raytest\' has successfully been deleted', { timeout: 5000 });
101105
expect(clusterDownMessage).not.toBeNull();
102106
});
103107

104108
await runPreviousCell(page, cellCount, '(<CodeFlareClusterStatus.UNKNOWN: 6>, False)');
109+
110+
// view_clusters table with buttons
111+
await interactWithWidget(page, upDownWidgetCellIndex, 'input[type="checkbox"]', async (checkbox) => {
112+
await checkbox.click();
113+
const isChecked = await checkbox.isChecked();
114+
expect(isChecked).toBe(false);
115+
});
116+
117+
await interactWithWidget(page, upDownWidgetCellIndex, 'button:has-text("Cluster Up")', async (button) => {
118+
await button.click();
119+
const successMessage = await page.waitForSelector('text=Ray Cluster: \'raytest\' has successfully been created', { timeout: 10000 });
120+
expect(successMessage).not.toBeNull();
121+
});
122+
123+
const viewClustersCellIndex = 4; // 5 on OpenShift
124+
await page.notebook.runCell(cellCount - 2, true);
125+
await interactWithWidget(page, viewClustersCellIndex, 'button:has-text("Open Ray Dashboard")', async (button) => {
126+
await button.click();
127+
const successMessage = await page.waitForSelector('text=Opening Ray Dashboard for raytest cluster', { timeout: 5000 });
128+
expect(successMessage).not.toBeNull();
129+
});
130+
131+
await interactWithWidget(page, viewClustersCellIndex, 'button:has-text("View Jobs")', async (button) => {
132+
await button.click();
133+
const successMessage = await page.waitForSelector('text=Opening Ray Jobs Dashboard for raytest cluster', { timeout: 5000 });
134+
expect(successMessage).not.toBeNull();
135+
});
136+
137+
await interactWithWidget(page, viewClustersCellIndex, 'button:has-text("Delete Cluster")', async (button) => {
138+
await button.click();
139+
140+
const noClustersMessage = await page.waitForSelector(`text=No clusters found in the ${namespace} namespace.`, { timeout: 5000 });
141+
expect(noClustersMessage).not.toBeNull();
142+
const successMessage = await page.waitForSelector(`text=Cluster raytest in the ${namespace} namespace was deleted successfully.`, { timeout: 5000 });
143+
expect(successMessage).not.toBeNull();
144+
});
145+
146+
await runPreviousCell(page, cellCount, '(<CodeFlareClusterStatus.UNKNOWN: 6>, False)');
105147
});
106148
});
107149

0 commit comments

Comments
 (0)