Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion tests/algorithm_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ describe('Algorithm Tests', () => {
expect(algVersion.body.length).to.be.equal(1);
}).timeout(1000 * 60 * 5);

it('check save current version algorithem after update and no delete versions after delete algorithm', async () => {
it('check save current version algorithm after update and no delete versions after delete algorithm', async () => {
await applyAlg(algorithmV1, dev_token);

const resAlgorithmV1 = await runAlgorithm(
Expand Down Expand Up @@ -1403,4 +1403,49 @@ describe('Algorithm Tests', () => {
await deleteAlgorithmJobs(stayUpSkeleton.name, dev_token);
}).timeout(1000 * 60 * 5);
});

describe('applyCpuLimits feature tests', () => {
const algorithmImage = 'hkube/algorithm-example-python'; // output is first element of the array which given as input.

it('should apply limits when applyCpuLimits is true', async () => {
const algName = `applycpulimits-true-${pipelineRandomName(4).toLowerCase()}`;
const alg = algJson(algName, algorithmImage);
alg.applyCpuLimits = true;

await applyAlg(alg, dev_token);
await runAlgGetResult(alg.name, [6], dev_token);
const expectedPod = await filterPodsByName(alg.name);
const containerSpec = await getPodSpecByContainer(expectedPod[0].metadata.name, 'algorunner');

expect(containerSpec.resources.limits).to.be.an('object');
expect(containerSpec.resources.limits).to.have.property('cpu');
}).timeout(1000 * 60 * 5);

it('should apply limits when applyCpuLimits is not defined', async () => {
const algName = `applycpulimits-undefined-${pipelineRandomName(4).toLowerCase()}`;
const alg = algJson(algName, algorithmImage);

await applyAlg(alg, dev_token);
await runAlgGetResult(alg.name, [6], dev_token);
const expectedPod = await filterPodsByName(alg.name);
const containerSpec = await getPodSpecByContainer(expectedPod[0].metadata.name, 'algorunner');

expect(containerSpec.resources.limits).to.be.an('object');
expect(containerSpec.resources.limits).to.have.property('cpu');
}).timeout(1000 * 60 * 5);

it('should not apply limits when applyCpuLimits is false', async () => {
const algName = `applycpulimits-undefined-${pipelineRandomName(4).toLowerCase()}`;
const alg = algJson(algName, algorithmImage);
alg.applyCpuLimits = false;

await applyAlg(alg, dev_token);
await runAlgGetResult(alg.name, [6], dev_token);
const expectedPod = await filterPodsByName(alg.name);
const containerSpec = await getPodSpecByContainer(expectedPod[0].metadata.name, 'algorunner');

expect(containerSpec.resources.limits).to.be.an('object');
expect(containerSpec.resources.limits).to.not.have.property('cpu');
}).timeout(1000 * 60 * 5);
});
});