mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
switch to fuzzing pod table tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
2d0609ed24
commit
6f4dfd7fb5
@ -19,6 +19,7 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { random } from "lodash";
|
||||||
import { Pod } from "../endpoints";
|
import { Pod } from "../endpoints";
|
||||||
|
|
||||||
interface GetDummyPodOptions {
|
interface GetDummyPodOptions {
|
||||||
@ -28,16 +29,7 @@ interface GetDummyPodOptions {
|
|||||||
initDead?: number;
|
initDead?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDummyPodDefaultOptions(): Required<GetDummyPodOptions> {
|
function getDummyPod({ running = 0, dead = 0, initDead = 0, initRunning = 0 }: GetDummyPodOptions = {}): Pod {
|
||||||
return {
|
|
||||||
running: 0,
|
|
||||||
dead: 0,
|
|
||||||
initDead: 0,
|
|
||||||
initRunning: 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Pod {
|
|
||||||
const pod = new Pod({
|
const pod = new Pod({
|
||||||
apiVersion: "v1",
|
apiVersion: "v1",
|
||||||
kind: "Pod",
|
kind: "Pod",
|
||||||
@ -66,7 +58,7 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
|||||||
initContainerStatuses: [],
|
initContainerStatuses: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < opts.running; i += 1) {
|
for (let i = 0; i < running; i += 1) {
|
||||||
const name = `container_r_${i}`;
|
const name = `container_r_${i}`;
|
||||||
|
|
||||||
pod.spec.containers.push({
|
pod.spec.containers.push({
|
||||||
@ -88,7 +80,7 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < opts.dead; i += 1) {
|
for (let i = 0; i < dead; i += 1) {
|
||||||
const name = `container_d_${i}`;
|
const name = `container_d_${i}`;
|
||||||
|
|
||||||
pod.spec.containers.push({
|
pod.spec.containers.push({
|
||||||
@ -113,7 +105,7 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < opts.initRunning; i += 1) {
|
for (let i = 0; i < initRunning; i += 1) {
|
||||||
const name = `container_ir_${i}`;
|
const name = `container_ir_${i}`;
|
||||||
|
|
||||||
pod.spec.initContainers.push({
|
pod.spec.initContainers.push({
|
||||||
@ -135,7 +127,7 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < opts.initDead; i += 1) {
|
for (let i = 0; i < initDead; i += 1) {
|
||||||
const name = `container_id_${i}`;
|
const name = `container_id_${i}`;
|
||||||
|
|
||||||
pod.spec.initContainers.push({
|
pod.spec.initContainers.push({
|
||||||
@ -166,14 +158,13 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
|||||||
describe("Pods", () => {
|
describe("Pods", () => {
|
||||||
const podTests = [];
|
const podTests = [];
|
||||||
|
|
||||||
for (let r = 0; r < 3; r += 1) {
|
for (let r = 0; r < 100; r += 1) {
|
||||||
for (let d = 0; d < 3; d += 1) {
|
podTests.push([
|
||||||
for (let ir = 0; ir < 3; ir += 1) {
|
random(0, 50),
|
||||||
for (let id = 0; id < 3; id += 1) {
|
random(0, 50),
|
||||||
podTests.push([r, d, ir, id]);
|
random(0, 50),
|
||||||
}
|
random(0, 50),
|
||||||
}
|
]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe.each(podTests)("for [%d running, %d dead] & initial [%d running, %d dead]", (running, dead, initRunning, initDead) => {
|
describe.each(podTests)("for [%d running, %d dead] & initial [%d running, %d dead]", (running, dead, initRunning, initDead) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user