From 85d1316e925a50350a6e4e15b57a729a82933282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Smolarek?= <34063647+Razz4780@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:25:38 +0200 Subject: [PATCH] Fix E2E (#152) * Log editor tabs * Fixed towncrier CI * Changelog entry * This may work * Manually open file * Debug log * Maybe works? * Maybe * ??? * media * God this works * No flask * lint --- .github/workflows/ci.yaml | 14 +++++++---- .github/workflows/release.yaml | 6 ++--- .github/workflows/reusable_e2e.yaml | 5 +--- changelog.d/+fixed-ci.internal.md | 1 + src/tests/e2e.ts | 39 +++++++++++++++++++---------- test-workspace/app_flask.py | 13 ---------- test-workspace/http_server.py | 16 ++++++++++++ 7 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 changelog.d/+fixed-ci.internal.md delete mode 100644 test-workspace/app_flask.py create mode 100644 test-workspace/http_server.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bfd47b00..349ccf1a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,18 +18,22 @@ concurrency: jobs: towncrier_check: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Install uv + uses: astral-sh/setup-uv@v2 + - run: uv python install + - run: uv venv - name: install towncrier - run: pip install towncrier==23.11.0 + run: uv pip install towncrier==23.11.0 - name: verify newsfragment exist - run: towncrier check + run: uv run towncrier check lint: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -50,7 +54,7 @@ jobs: # We want this to run even if some of the required jobs got skipped if: always() needs: [towncrier_check, e2e, lint] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: CI succeeded # We have to do it in the shell since if it's in the if condition diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bfcb2084..2613ec77 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,7 @@ on: jobs: release: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -42,7 +42,7 @@ jobs: release_gh: needs: [release] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 if: github.event_name != 'workflow_dispatch' permissions: packages: write @@ -67,7 +67,7 @@ jobs: files: /tmp/release/** update_latest: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: release_gh if: github.event_name != 'workflow_dispatch' steps: diff --git a/.github/workflows/reusable_e2e.yaml b/.github/workflows/reusable_e2e.yaml index ad8ca747..2c5711cb 100644 --- a/.github/workflows/reusable_e2e.yaml +++ b/.github/workflows/reusable_e2e.yaml @@ -17,7 +17,7 @@ on: jobs: vscode-e2e: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 env: CI_BUILD_PLUGIN: "true" steps: @@ -97,9 +97,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.10" - - name: Install dependencies - run: | - pip install flask # we can't run chrome like apps in the CI, we use a virtual frame buffer: # refer: http://elementalselenium.com/tips/38-headless - name: Run vscode e2e in headless state diff --git a/changelog.d/+fixed-ci.internal.md b/changelog.d/+fixed-ci.internal.md new file mode 100644 index 00000000..2e42d7a1 --- /dev/null +++ b/changelog.d/+fixed-ci.internal.md @@ -0,0 +1 @@ +Pinned worker to `ubuntu-24.04`, changed towncrier check to run inside `uv`, fixed E2E test suite. \ No newline at end of file diff --git a/src/tests/e2e.ts b/src/tests/e2e.ts index 103ec6d0..4a4a13d7 100644 --- a/src/tests/e2e.ts +++ b/src/tests/e2e.ts @@ -1,6 +1,6 @@ import { expect, assert } from "chai"; import { join } from "path"; -import { VSBrowser, StatusBar, ActivityBar, DebugView, InputBox, DebugToolbar, BottomBarPanel, EditorView } from "vscode-extension-tester"; +import { VSBrowser, StatusBar, ActivityBar, DebugView, InputBox, DebugToolbar, BottomBarPanel, EditorView, SideBarView, DefaultTreeSection, TitleBar, Workbench, until } from "vscode-extension-tester"; import get from "axios"; const kubeService = process.env.KUBE_SERVICE; @@ -23,10 +23,9 @@ describe("mirrord sample flow test", function() { let browser: VSBrowser; const testWorkspace = join(__dirname, '../../test-workspace'); - const fileName = "app_flask.py"; const defaultTimeout = 40000; // = 40 seconds - before(async function() { + before("open local app in the editor", async function() { console.log("podToSelect: " + podToSelect); console.log("kubeService: " + kubeService); @@ -34,18 +33,32 @@ describe("mirrord sample flow test", function() { expect(kubeService).to.not.be.undefined; browser = VSBrowser.instance; - - await browser.openResources(testWorkspace, join(testWorkspace, fileName)); await browser.waitForWorkbench(); - const ew = new EditorView(); - try { - await ew.closeEditor('Welcome'); - } catch (error) { - console.log("Welcome page is not displayed" + error); - // continue - Welcome page is not displayed + const workbench = new Workbench(); + + const titleBar = new TitleBar(); + const item = await titleBar.getItem('File'); + const fileMenu = await item!.select(); + const items = await fileMenu.getItems(); + let openItem = null; + for (const item of items) { + const label = await item.getLabel(); + if (label.startsWith("Open Folder...")) { + openItem = item; + } } - await ew.openEditor('app_flask.py'); + await openItem!.select(); + const input = await InputBox.create(); + await input.setText(testWorkspace); + await input.confirm(); + + await browser.driver.wait(until.stalenessOf(workbench)); + await browser.waitForWorkbench(); + + const view = new SideBarView(); + const tree = await view.getContent().getSection('test-workspace'); + await tree.openItem('http_server.py'); }); it("enable mirrord button", async function() { @@ -119,7 +132,7 @@ describe("mirrord sample flow test", function() { await browser.driver.wait(async () => { const text = await terminal.getText(); - return await terminal.isDisplayed() && text.includes("Press CTRL+C to quit"); + return await terminal.isDisplayed() && text.includes("Local app started"); }, 4 * defaultTimeout, "terminal text not found -- timed out"); await sendTrafficToPod(); diff --git a/test-workspace/app_flask.py b/test-workspace/app_flask.py deleted file mode 100644 index a380b4b9..00000000 --- a/test-workspace/app_flask.py +++ /dev/null @@ -1,13 +0,0 @@ -from flask import Flask - -app = Flask(__name__) - - -@app.route("/", methods=["GET"]) -def get(): - print("GET: Request completed") - return "GET" - - -if __name__ == "__main__": - app.run(host="0.0.0.0", port=80) diff --git a/test-workspace/http_server.py b/test-workspace/http_server.py new file mode 100644 index 00000000..3216a616 --- /dev/null +++ b/test-workspace/http_server.py @@ -0,0 +1,16 @@ +from http.server import BaseHTTPRequestHandler, HTTPServer + +class HTTPRequestHandler(BaseHTTPRequestHandler): + def do_GET(self): + print("GET: Request completed") + self.send_response(200) + self.send_header("Content-type", "application/json") + self.send_header("Content-Length", len("GET")) + self.end_headers() + self.wfile.write("GET".encode('utf8')) + +if __name__ == "__main__": + server_address = ('0.0.0.0', 80) + httpd = HTTPServer(server_address, HTTPRequestHandler) + print("Local app started") + httpd.serve_forever()