diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e751356b..e9944684 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/.tests/tests/jupytertest.spec.ts b/.tests/tests/jupytertest.spec.ts index 5d8f8448..c66f0c80 100644 --- a/.tests/tests/jupytertest.spec.ts +++ b/.tests/tests/jupytertest.spec.ts @@ -36,49 +36,44 @@ 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 @@ -86,19 +81,24 @@ for (let i = 0; i < testCount; i++) { 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 @@ -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'); } } - } }); } \ No newline at end of file