Skip to content

Commit

Permalink
Fix E2E (metalbear-co#152)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Razz4780 authored Oct 2, 2024
1 parent 6c4a249 commit 85d1316
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 38 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/reusable_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
vscode-e2e:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
CI_BUILD_PLUGIN: "true"
steps:
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+fixed-ci.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pinned worker to `ubuntu-24.04`, changed towncrier check to run inside `uv`, fixed E2E test suite.
39 changes: 26 additions & 13 deletions src/tests/e2e.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,29 +23,42 @@ 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);

expect(podToSelect).to.not.be.undefined;
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() {
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 0 additions & 13 deletions test-workspace/app_flask.py

This file was deleted.

16 changes: 16 additions & 0 deletions test-workspace/http_server.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 85d1316

Please sign in to comment.