Skip to content

Commit 1da8f2e

Browse files
author
Nitin Sreeram
committed
Code cleanup
1 parent 4c48d16 commit 1da8f2e

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
npx playwright test
4646
- name: Delete test environments
4747
if: always()
48-
run: npx ts-node post_delete_env
48+
run: npx ts-node post_delete_env.ts
4949
- uses: actions/upload-artifact@v3
5050
if: always()
5151
with:

.tests/tests/jupytertest.spec.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,69 +36,69 @@ const files = readFileIntoArray(FILE_NAME).filter((name) => skipfiles.indexOf(na
3636
const testCount = Math.ceil(files.length / CSAE_CI_JOB_COUNT);
3737

3838
for (let i = 0; i < testCount; i++) {
39+
3940
const idx = i * CSAE_CI_JOB_COUNT + CSAE_CI_JOB_IDX;
4041
if(idx >= files.length) {
4142
break;
4243
}
43-
4444
const name = files[idx];
4545
if(name === '') {
4646
continue;
4747
}
48+
4849
test(`test ${i}: ${name}`, async ({page},testInfo) => {
4950
test.setTimeout(10800000);
5051

5152
// Create Env or get existing Env
5253
const env = await envPool.getEnv(testInfo.parallelIndex);
53-
54-
await sleep(5000);
5554
console.log('url:'+env.getJuypterUrl(name.substring(3)));
56-
5755
await page.goto(env.getJuypterUrl(name.substring(3)));
5856

5957
await page.waitForLoadState();
6058

61-
// Wait for content to appear before moving on. Jupyter is slow to load (Done) (Hack job)
62-
await page.locator('span[class="f1235lqo"]').getByText('| Idle').waitFor({timeout: 300000})
63-
64-
const data = JSON.parse(fs.readFileSync(name, 'utf8'));
65-
console.log('data: ' + data.metadata.kernelspec.language);
59+
const juypterNotebookData = JSON.parse(fs.readFileSync(name, 'utf8'));
6660

6761
let strKernelType = '';
68-
if (data.metadata.kernelspec.language === 'python') {
62+
if (juypterNotebookData.metadata.kernelspec.language === 'python') {
6963
console.log('Python Notebook');
7064
strKernelType = "Python 3 (ipykernel) ";
7165
}
72-
else if (data.metadata.kernelspec.language === 'Teradata SQL') {
66+
else if (juypterNotebookData.metadata.kernelspec.language === 'Teradata SQL') {
7367
console.log('Teradata SQL Notebook');
7468
strKernelType = 'Teradata SQL ';
75-
} else if (data.metadata.kernelspec.language === 'R') {
69+
} else if (juypterNotebookData.metadata.kernelspec.language === 'R') {
7670
console.log('R Notebook');
7771
strKernelType = 'R ';
7872
}
7973

8074
console.log('Kernel Type: ' + strKernelType);
8175
expect(strKernelType).not.toBe('');
76+
8277
await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});
8378

8479
//Get the number of cells in the notebook
8580
const jpCells = await page.locator('div.jp-NotebookPanel:not(.p-mod-hidden)> div > div.jp-Cell');
8681
await jpCells.first().waitFor({timeout: 300000});
8782
console.log('jpCells: ' + await jpCells.count());
8883

89-
var dm = await jpCells.count(); // Default Number of iterations for each Notebook demo
90-
84+
var dm = await juypterNotebookData.cells.length; // Default Number of iterations for each Notebook demo
85+
86+
//Clicking to activate the note book
9187
jpCells.first().click();
88+
9289
for (let i = 0; i < dm; i++) {
93-
await sleep(100);
90+
//Check for any errors so far
9491
expect(await page.locator(".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']")).toHaveCount(0);
95-
await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});
96-
if (await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').isVisible())
92+
93+
// To continute the notebook the kernel should be in Idle state. i.e previous cell execution should be completed.
94+
// await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});
95+
if (await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').isVisible({timeout: 600000}))
9796
{
98-
// Go to next step by clicking Shift+Enter
97+
// Go to next step by clicking the Run button
9998
await page.getByRole('button', { name: 'Run the selected cells and' }).click();
100-
101-
}
99+
}
100+
101+
// Wait to see if the kernel is started because of the cell execution (some cell does not have execution like text).
102102
try{
103103
await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Busy"').waitFor({timeout: 2000});
104104
expect
@@ -108,18 +108,14 @@ for (let i = 0; i < testCount; i++) {
108108

109109
if (await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Busy"').isVisible())
110110
{
111-
// Check if wating for Password Prompt
112-
await sleep(1000); // Wait one sec... It's slow to load
113-
//if (await page.locator('pre', { hasText: 'Enter password:'}).isVisible())
114111
const passwordField = await page.locator('pre[class="jp-Stdin-prompt"]', { hasText: 'password'})
115-
if (await passwordField.isVisible())
112+
if (await passwordField.isVisible({timeout: 1000}))
116113
{
117114
await page.fill('input[class="jp-Stdin-input"]', CSAE_ENV_PASSWORD);
118115
await page.locator('input[class="jp-Stdin-input"]').click();
119116
await page.keyboard.press('Enter');
120117
}
121118
}
122-
123119
}
124120
});
125121
}

0 commit comments

Comments
 (0)