From 87d185428daf327a6c6c4ebb3d48eb0f7335663f Mon Sep 17 00:00:00 2001 From: Ondrej Dockal Date: Tue, 25 Oct 2022 16:07:47 +0200 Subject: [PATCH] Clean up of test env. before ui-test (#313) * Clean up of test env. before ui-test Signed-off-by: Ondrej Dockal --- .github/workflows/main.yml | 2 +- Jenkinsfile | 16 ++++++++++++++++ test/ui-test/extensionUITest.ts | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eebe6ae0..ba850a6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: if: failure() with: name: screenshots-${{ matrix.os }} - path: ~/**/screenshots/*.png + path: 'test-resources/**/screenshots/*.png' retention-days: 2 if-no-files-found: warn - uses: codecov/codecov-action@v1 diff --git a/Jenkinsfile b/Jenkinsfile index 73470dff..06f8e922 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,6 +26,22 @@ node('rhel8'){ } } + stage('UI Tests') { + wrap([$class: 'Xvnc']) { + try { + sh """ + if [ -f \$HOME/.vs-kn/kn ]; then + rm \$HOME/.vs-kn/kn + fi + """ + sh "npm run base-ui-test" + } + finally { + archiveArtifacts artifacts: 'test-resources/*.log,test-resources/**/*.png' + } + } + } + stage('Package') { def packageJson = readJSON file: 'package.json' packageJson.extensionDependencies = ["ms-kubernetes-tools.vscode-kubernetes-tools"] diff --git a/test/ui-test/extensionUITest.ts b/test/ui-test/extensionUITest.ts index 12658bfb..e96e3282 100644 --- a/test/ui-test/extensionUITest.ts +++ b/test/ui-test/extensionUITest.ts @@ -2,6 +2,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/await-thenable */ +import fs = require('fs'); +import os = require('os'); +import path = require('path'); import { expect } from 'chai'; import { ActivityBar, @@ -37,12 +40,29 @@ function execShellCommand(cmd) { export function extensionsUITest(clusterIsAvailable: boolean): void { let driver: WebDriver; let kubectlExists: boolean; + const homeDir = os.homedir(); + const vskn = path.join(homeDir, '.vs-kn'); + const vsfunc = path.join(homeDir, '.vs-func'); + const vskubectl = path.join(homeDir, '.vs-kubectl'); before(async () => { driver = VSBrowser.instance.driver; // check existence of kubectl on the path or in the home folder const kubectl = await execShellCommand('kubectl version --output json'); kubectlExists = !(kubectl as string).includes('kubectl: command not found'); + if (fs.existsSync(vsfunc)) { + console.log(`.vs-func does exist - removing`); + fs.rmSync(vsfunc, { recursive: true, force: true }); + } + if (fs.existsSync(vskn)) { + console.log(`.vs-kn does exist - removing`); + fs.rmSync(vskn, { recursive: true, force: true }); + } + if (fs.existsSync(vskubectl)) { + console.log(`.vs-kubectl does exist - removing`); + fs.rmSync(vskubectl, { recursive: true, force: true }); + } + console.log(`kubectl is on path: ${kubectlExists === true ? 'true' : 'false'}`); }); describe('Knative extension UI', () => {