Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitin Sreeram committed Jun 24, 2024
1 parent 4c48d16 commit 1da8f2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
npx playwright test
- name: Delete test environments
if: always()
run: npx ts-node post_delete_env
run: npx ts-node post_delete_env.ts
- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
46 changes: 21 additions & 25 deletions .tests/tests/jupytertest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,69 +36,69 @@ const files = readFileIntoArray(FILE_NAME).filter((name) => skipfiles.indexOf(na
const testCount = Math.ceil(files.length / CSAE_CI_JOB_COUNT);

for (let i = 0; i < testCount; i++) {

const idx = i * CSAE_CI_JOB_COUNT + CSAE_CI_JOB_IDX;
if(idx >= files.length) {
break;
}

const name = files[idx];
if(name === '') {
continue;
}

test(`test ${i}: ${name}`, async ({page},testInfo) => {
test.setTimeout(10800000);

// Create Env or get existing Env
const env = await envPool.getEnv(testInfo.parallelIndex);

await sleep(5000);
console.log('url:'+env.getJuypterUrl(name.substring(3)));

await page.goto(env.getJuypterUrl(name.substring(3)));

await page.waitForLoadState();

// Wait for content to appear before moving on. Jupyter is slow to load (Done) (Hack job)
await page.locator('span[class="f1235lqo"]').getByText('| Idle').waitFor({timeout: 300000})

const data = JSON.parse(fs.readFileSync(name, 'utf8'));
console.log('data: ' + data.metadata.kernelspec.language);
const juypterNotebookData = JSON.parse(fs.readFileSync(name, 'utf8'));

let strKernelType = '';
if (data.metadata.kernelspec.language === 'python') {
if (juypterNotebookData.metadata.kernelspec.language === 'python') {
console.log('Python Notebook');
strKernelType = "Python 3 (ipykernel) ";
}
else if (data.metadata.kernelspec.language === 'Teradata SQL') {
else if (juypterNotebookData.metadata.kernelspec.language === 'Teradata SQL') {
console.log('Teradata SQL Notebook');
strKernelType = 'Teradata SQL ';
} else if (data.metadata.kernelspec.language === 'R') {
} else if (juypterNotebookData.metadata.kernelspec.language === 'R') {
console.log('R Notebook');
strKernelType = 'R ';
}

console.log('Kernel Type: ' + strKernelType);
expect(strKernelType).not.toBe('');

await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});

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

var dm = await jpCells.count(); // Default Number of iterations for each Notebook demo

var dm = await juypterNotebookData.cells.length; // Default Number of iterations for each Notebook demo

//Clicking to activate the note book
jpCells.first().click();

for (let i = 0; i < dm; i++) {
await sleep(100);
//Check for any errors so far
expect(await page.locator(".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']")).toHaveCount(0);
await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});
if (await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').isVisible())

// To continute the notebook the kernel should be in Idle state. i.e previous cell execution should be completed.
// await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});
if (await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').isVisible({timeout: 600000}))
{
// Go to next step by clicking Shift+Enter
// Go to next step by clicking the Run button
await page.getByRole('button', { name: 'Run the selected cells and' }).click();

}
}

// Wait to see if the kernel is started because of the cell execution (some cell does not have execution like text).
try{
await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Busy"').waitFor({timeout: 2000});
expect
Expand All @@ -108,18 +108,14 @@ for (let i = 0; i < testCount; i++) {

if (await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Busy"').isVisible())
{
// Check if wating for Password Prompt
await sleep(1000); // Wait one sec... It's slow to load
//if (await page.locator('pre', { hasText: 'Enter password:'}).isVisible())
const passwordField = await page.locator('pre[class="jp-Stdin-prompt"]', { hasText: 'password'})
if (await passwordField.isVisible())
if (await passwordField.isVisible({timeout: 1000}))
{
await page.fill('input[class="jp-Stdin-input"]', CSAE_ENV_PASSWORD);
await page.locator('input[class="jp-Stdin-input"]').click();
await page.keyboard.press('Enter');
}
}

}
});
}

0 comments on commit 1da8f2e

Please sign in to comment.