Skip to content

Commit 57fb861

Browse files
martinpittjelly
authored andcommitted
base1: Clean up pybridge special cases
As we only have the Python bridge now, we can drop the dynamic special casese and C bridge fallbacks from the unit tests. Drop the fencing and HTTP connection sharing tests -- we haven't missed these features in years, so it's unlikely we'll bring them back. However, do keep `skipWithPybridge` for now -- the D-Bus tests still need to be adjusted or the Python bridge fixed, and that makes them easy to grep.
1 parent d0a8934 commit 57fb861

File tree

6 files changed

+16
-138
lines changed

6 files changed

+16
-138
lines changed

pkg/base1/test-dbus.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cockpit from "cockpit";
2-
import QUnit, { mock_info, skipWithPybridge } from "qunit-tests";
2+
import QUnit, { skipWithPybridge } from "qunit-tests";
33

44
import { common_dbus_tests, dbus_track_tests } from "./test-dbus-common.js";
55

@@ -547,15 +547,9 @@ QUnit.test("nonexisting address", async assert => {
547547
await dbus.call("/org/freedesktop/DBus", "org.freedesktop.DBus", "Hello", []);
548548
assert.ok(false, "should not be reached");
549549
} catch (ex) {
550-
if (await mock_info("pybridge")) {
551-
assert.equal(ex.problem, "protocol-error", "got right close code");
552-
assert.equal(ex.message, "failed to connect to none bus: [Errno 2] sd_bus_start: No such file or directory",
553-
"error message");
554-
} else {
555-
// C bridge has a weird error code
556-
assert.equal(ex.problem, "internal-error", "got right close code");
557-
assert.equal(ex.message, "Could not connect: No such file or directory", "error message");
558-
}
550+
assert.equal(ex.problem, "protocol-error", "got right close code");
551+
assert.equal(ex.message, "failed to connect to none bus: [Errno 2] sd_bus_start: No such file or directory",
552+
"error message");
559553
}
560554
});
561555

pkg/base1/test-echo.js

+1-44
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cockpit from "cockpit";
2-
import QUnit, { mock_info } from "qunit-tests";
2+
import QUnit from "qunit-tests";
33

44
QUnit.test("basic", function (assert) {
55
const done = assert.async();
@@ -79,47 +79,4 @@ QUnit.test("binary", function (assert) {
7979
channel.send(buffer);
8080
});
8181

82-
QUnit.test("fence", async assert => {
83-
const done = assert.async();
84-
85-
// This is implemented in the C bridge, but not in Python.
86-
if (await mock_info("pybridge")) {
87-
assert.ok(true, "skipping on python bridge, not implemented");
88-
done();
89-
return;
90-
}
91-
92-
assert.expect(2);
93-
94-
const before = cockpit.channel({ payload: "echo" });
95-
before.addEventListener("message", onMessage);
96-
97-
const fence = cockpit.channel({ payload: "echo", group: "fence" });
98-
fence.addEventListener("message", onMessage);
99-
100-
const after = cockpit.channel({ payload: "echo" });
101-
after.addEventListener("message", onMessage);
102-
103-
const received = [];
104-
function onMessage(ev, payload) {
105-
received.push(payload);
106-
if (received.length == 3) {
107-
assert.deepEqual(received, ["1", "2", "3"], "got back before and fence data");
108-
fence.close();
109-
} else if (received.length == 5) {
110-
assert.deepEqual(received, ["1", "2", "3", "4", "5"], "got back data in right order");
111-
before.close();
112-
after.close();
113-
done();
114-
}
115-
}
116-
117-
/* We send messages in this order, but they should echoed in numeric order */
118-
before.send("1");
119-
after.send("4");
120-
after.send("5");
121-
fence.send("2");
122-
fence.send("3");
123-
});
124-
12582
QUnit.start();

pkg/base1/test-http.js

+4-63
Original file line numberDiff line numberDiff line change
@@ -297,60 +297,6 @@ QUnit.test("http promise recursive", assert => {
297297
assert.equal(typeof promise3.input, "function", "promise3.input()");
298298
});
299299

300-
QUnit.test("http keep alive", async assert => {
301-
assert.expect(1);
302-
303-
// connection sharing is not implemented in the pybridge
304-
if (await mock_info("pybridge")) {
305-
assert.rejects(
306-
cockpit.http({ port: test_server.port, connection: "one" }).get("/mock/connection"),
307-
ex => ex.problem == "protocol-error" && ex.status == undefined,
308-
"rejects connection option on python bridge");
309-
return;
310-
}
311-
312-
/*
313-
* The /mock/connection handler returns an identifier that changes if
314-
* a different connection is used.
315-
*/
316-
const first = await cockpit.http({ port: test_server.port, connection: "marmalade" }).get("/mock/connection");
317-
const second = await cockpit.http({ port: test_server.port, connection: "marmalade" }).get("/mock/connection");
318-
assert.equal(first, second, "same connection");
319-
});
320-
321-
QUnit.test("http connection different", async assert => {
322-
assert.expect(1);
323-
324-
// connection sharing is not implemented in the pybridge
325-
if (await mock_info("pybridge")) {
326-
assert.ok(true);
327-
return;
328-
}
329-
330-
/*
331-
* The /mock/connection handler returns an identifier that changes if
332-
* a different connection is used.
333-
*/
334-
const first = await cockpit.http({ port: test_server.port, connection: "one" }).get("/mock/connection");
335-
const second = await cockpit.http({ port: test_server.port, connection: "two" }).get("/mock/connection");
336-
assert.notEqual(first, second, "different connection");
337-
});
338-
339-
QUnit.test("http connection without address", async assert => {
340-
assert.expect(1);
341-
342-
// connection sharing is not implemented in the pybridge
343-
if (await mock_info("pybridge")) {
344-
assert.ok(true);
345-
return;
346-
}
347-
348-
// Able to reuse connection client info and not specify address again.
349-
const first = await cockpit.http({ port: test_server.port, connection: "one" }).get("/mock/connection");
350-
const second = await cockpit.http({ connection: "one" }).get("/mock/connection");
351-
assert.equal(first, second, "same connection");
352-
});
353-
354300
QUnit.test("no dns address", assert => {
355301
assert.expect(1);
356302

@@ -406,15 +352,10 @@ QUnit.test("wrong options", async assert => {
406352
ex => ex.problem == "protocol-error" && ex.status == undefined,
407353
"rejects request with both port and unix option");
408354

409-
// This is disallowed in the pybridge, but allowed in the C bridge
410-
if (await mock_info("pybridge")) {
411-
assert.rejects(
412-
cockpit.http({ unix: "/nonexisting/socket", tls: {} }).get("/"),
413-
ex => ex.problem == "protocol-error" && ex.status == undefined,
414-
"rejects request with both unix and tls option");
415-
} else {
416-
assert.ok(true, "skipping on python bridge, not implemented");
417-
}
355+
assert.rejects(
356+
cockpit.http({ unix: "/nonexisting/socket", tls: {} }).get("/"),
357+
ex => ex.problem == "protocol-error" && ex.status == undefined,
358+
"rejects request with both unix and tls option");
418359
});
419360

420361
QUnit.test("parallel stress test", async assert => {

pkg/base1/test-stream.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cockpit from "cockpit";
2-
import QUnit, { mock_info } from "qunit-tests";
2+
import QUnit from "qunit-tests";
33

44
const QS_REQUEST = "HEAD /mock/qs HTTP/1.0\nHOST: localhost\n\n";
55

@@ -12,18 +12,13 @@ QUnit.test("TCP stream port without a service", async assert => {
1212
const done = assert.async();
1313
assert.expect(2);
1414

15-
const is_pybridge = await mock_info("pybridge");
16-
1715
const channel = cockpit.channel({ payload: "stream", address: "127.0.0.99", port: 2222 });
1816

1917
channel.addEventListener("close", (ev, options) => {
2018
assert.equal(options.problem, "not-found", "channel should have failed");
21-
if (is_pybridge)
22-
assert.equal(options.message,
23-
"[Errno 111] Connect call failed ('127.0.0.99', 2222)",
24-
"detailed error message");
25-
else
26-
assert.equal(options.message, undefined, "C bridge does not give detailed error message");
19+
assert.equal(options.message,
20+
"[Errno 111] Connect call failed ('127.0.0.99', 2222)",
21+
"detailed error message");
2722
done();
2823
});
2924
});

pkg/lib/qunit-tests.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,11 @@ export const mock_info = async (key: string) => {
2828
return (await response.json())[key];
2929
};
3030

31-
// Convenience for skipping tests that the python bridge can't yet
32-
// handle.
33-
34-
let is_pybridge: boolean | null = null;
31+
// Convenience for skipping tests that our python bridge can't yet
32+
// handle (the C bridge implemented these features)
3533

3634
export const skipWithPybridge = async (name: string, callback: (assert: unknown) => void | Promise<void>) => {
37-
if (is_pybridge === null)
38-
is_pybridge = await mock_info("pybridge");
39-
40-
if (is_pybridge)
41-
QUnit.skip(name, callback);
42-
else
43-
QUnit.test(name, callback);
35+
QUnit.skip(name, callback);
4436
};
4537

4638
/* Always use explicit start */

src/ws/test-server.c

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ mock_http_info (CockpitWebRequest *request,
121121
CockpitWebResponse *response)
122122
{
123123
g_autoptr(JsonObject) info = json_object_new ();
124-
json_object_set_boolean_member (info, "pybridge", strstr (bridge_argv[0], "py") != NULL);
125124
json_object_set_boolean_member (info, "skip_slow_tests", g_getenv ("COCKPIT_SKIP_SLOW_TESTS") != NULL);
126125

127126
g_autoptr(GBytes) bytes = cockpit_json_write_bytes (info);

0 commit comments

Comments
 (0)