merge 036, everything broken

This commit is contained in:
Matt Hill
2024-03-20 13:32:57 -06:00
parent f4fadd366e
commit 5e6a7e134f
429 changed files with 42285 additions and 27221 deletions

View File

@@ -10,7 +10,7 @@ export async function getConfig(effects) {
volumeId: "main",
});
throw new Error(
"Expecting that the ../test.log should not be a valid path since we are breaking out of the parent",
"Expecting that the ../test.log should not be a valid path since we are breaking out of the parent"
);
} catch (e) {}
try {
@@ -20,7 +20,7 @@ export async function getConfig(effects) {
volumeId: "main",
});
throw new Error(
"Expecting that using a symlink to break out of parent still fails for writing",
"Expecting that using a symlink to break out of parent still fails for writing"
);
} catch (e) {}
try {
@@ -29,7 +29,7 @@ export async function getConfig(effects) {
volumeId: "main",
});
throw new Error(
"Expecting that using a symlink to break out of parent still fails for writing dir",
"Expecting that using a symlink to break out of parent still fails for writing dir"
);
} catch (e) {}
try {
@@ -38,7 +38,7 @@ export async function getConfig(effects) {
volumeId: "main",
});
throw new Error(
"Expecting that using a symlink to break out of parent still fails for reading",
"Expecting that using a symlink to break out of parent still fails for reading"
);
} catch (e) {}
@@ -81,7 +81,7 @@ export async function getConfig(effects) {
`Read results are ${await effects.readFile({
path: "./test.log",
volumeId: "main",
})}`,
})}`
);
// Testing loging
effects.trace("trace");
@@ -730,47 +730,48 @@ export async function setConfig(effects) {
const assert = (condition, message) => {
if (!condition) {
throw ({ error: message });
throw new Error(message);
}
};
const ackermann = (m, n) => {
if (m === 0) {
return n + 1;
return n+1
}
if (n === 0) {
return ackermann(m - 1, 1);
return ackermann((m - 1), 1);
}
if (m !== 0 && n !== 0) {
return ackermann(m - 1, ackermann(m, n - 1));
return ackermann((m-1), ackermann(m, (n-1)))
}
};
}
export const action = {
async slow(effects, _input) {
while (true) {
while(true) {
effects.error("A");
await ackermann(3, 10);
await ackermann(3,10);
// await effects.sleep(100);
}
},
async fetch(effects, _input) {
const example = await effects.fetch(
"https://postman-echo.com/get?foo1=bar1&foo2=bar2",
"https://postman-echo.com/get?foo1=bar1&foo2=bar2"
);
assert(
Number(example.headers["content-length"]) > 0 &&
Number(example.headers["content-length"]) <= 1000000,
"Should have content length",
"Should have content length"
);
assert(
example.text() instanceof Promise,
"example.text() should be a promise",
"example.text() should be a promise"
);
assert(example.body === undefined, "example.body should not be defined");
assert(
JSON.parse(await example.text()).args.foo1 === "bar1",
"Body should be parsed",
"Body should be parsed"
);
const message = `This worked @ ${new Date().toISOString()}`;
const secondResponse = await effects.fetch(
@@ -781,11 +782,11 @@ export const action = {
headers: {
test: "1234",
},
},
}
);
assert(
(await secondResponse.json()).json.message === message,
"Body should be parsed from response",
"Body should be parsed from response"
);
return {
result: {
@@ -843,6 +844,7 @@ export const action = {
failed = true;
}
assert(failed, "Should not be able to remove file that doesn't exist");
return {
result: {
@@ -858,9 +860,9 @@ export const action = {
* https://github.com/Start9Labs/start-os/issues/1737
* which that we couldn't create a dir that was deeply nested, and the parents where
* not created yet. Found this out during the migrations, where the parent would die.
* @param {*} effects
* @param {*} _input
* @returns
* @param {*} effects
* @param {*} _input
* @returns
*/
async "test-deep-dir"(effects, _input) {
await effects
@@ -933,9 +935,9 @@ export const action = {
* Created this test because of issue
* https://github.com/Start9Labs/start-os/issues/2121
* That the empty in the create dies
* @param {*} effects
* @param {*} _input
* @returns
* @param {*} effects
* @param {*} _input
* @returns
*/
async "test-zero-dir"(effects, _input) {
await effects.createDir({
@@ -953,9 +955,9 @@ export const action = {
},
/**
* Found case where we could escape with the new deeper dir fix.
* @param {*} effects
* @param {*} _input
* @returns
* @param {*} effects
* @param {*} _input
* @returns
*/
async "test-deep-dir-escape"(effects, _input) {
await effects
@@ -967,9 +969,7 @@ export const action = {
await effects.createDir({
volumeId: "main",
path: "test-deep-dir/../../test",
}).then((_) => {
throw new Error("Should not be able to create sub");
}, (_) => {});
}).then(_ => {throw new Error("Should not be able to create sub")}, _ => {});
return {
result: {
@@ -981,11 +981,12 @@ export const action = {
};
},
/**
* Want to test that rsync works
* @param {*} effects
* @param {*} _input
* @returns
* @param {*} effects
* @param {*} _input
* @returns
*/
async "test-rsync"(effects, _input) {
try {
@@ -1004,22 +1005,17 @@ export const action = {
delete: true,
force: true,
ignoreExisting: false,
},
}
});
assert(await runningRsync.id() >= 1, "Expect that we have an id");
const progress = await runningRsync.progress();
assert(
progress >= 0 && progress <= 1,
`Expect progress to be 0 <= progress(${progress}) <= 1`,
);
const progress = await runningRsync.progress()
assert(progress >= 0 && progress <= 1, `Expect progress to be 0 <= progress(${progress}) <= 1`);
await runningRsync.wait();
assert(
(await effects.readFile({
volumeId: "main",
path: "test-rsync-out/testing-rsync/someFile.txt",
})).length > 0,
'Asserting that we read in the file "test_rsync/test-package/0.3.0.3/embassy.js"',
);
assert((await effects.readFile({
volumeId: "main",
path: "test-rsync-out/testing-rsync/someFile.txt",
})).length > 0, 'Asserting that we read in the file "test_rsync/test-package/0.3.0.3/embassy.js"');
return {
result: {
@@ -1029,9 +1025,11 @@ export const action = {
qr: false,
},
};
} catch (e) {
}
catch (e) {
throw e;
} finally {
}
finally {
await effects
.removeDir({
volumeId: "main",
@@ -1040,108 +1038,6 @@ export const action = {
.catch(() => {});
}
},
/**
* Testing callbacks?
* @param {*} effects
* @param {*} _input
* @returns
*/
async "test-callback"(effects, _input) {
await Promise.race([
new Promise((done) =>
effects.getServiceConfig({
serviceId: "something",
configPath: "string",
onChange: done,
})
),
new Promise(async () => {
await effects.sleep(100);
throw new Error("Currently in sleeping");
}),
]);
return {
result: {
copyable: false,
message: "Done",
version: "0",
qr: false,
},
};
},
/**
* We wanted to change the permissions and the ownership during the
* backing up, there where cases where the ownership is weird and
* broke for non root users.
* Note: Test for the chmod is broken and turned off because it only works when ran by root
* @param {*} effects
* @param {*} _input
* @returns
*/
async "test-permission-chown"(effects, _input) {
await effects
.removeDir({
volumeId: "main",
path: "pem-chown",
})
.catch(() => {});
await effects.createDir({
volumeId: "main",
path: "pem-chown/deep/123",
});
await effects.writeFile({
volumeId: "main",
path: "pem-chown/deep/123/test.txt",
toWrite: "Hello World",
});
const firstMetaData = await effects.metadata({
volumeId: "main",
path: "pem-chown/deep/123/test.txt",
});
assert(
firstMetaData.readonly === false,
`The readonly (${firstMetaData.readonly}) is wrong`,
);
const previousUid = firstMetaData.uid;
const expected = 1234;
await effects.chmod({
volumeId: "main",
path: "pem-chown/deep/123/test.txt",
mode: 0o444,
});
const chownError = await effects.chown({
volumeId: "main",
path: "pem-chown/deep",
uid: expected,
}).then(() => true, () => false);
let metaData = await effects.metadata({
volumeId: "main",
path: "pem-chown/deep/123/test.txt",
});
if (chownError) {
assert(
metaData.mode === 0o444,
`The mode (${metaData.mode}) is wrong compared to ${0o444}}`,
);
assert(
metaData.uid === expected,
`The uuid (${metaData.uid}) is wrong, should be more than ${previousUid}`,
);
}
return {
result: {
copyable: false,
message: "Done",
version: "0",
qr: false,
},
};
},
async "test-disk-usage"(effects, _input) {
const usage = await effects.diskUsage()