Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 6fdf39f

Browse files
committed
Remove default implicit configuration that sets the concurrency to 1 #183
- added unit tests
1 parent f407598 commit 6fdf39f

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

compile/functions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class OpenWhiskCompileFunctions {
8282
action: {
8383
exec: params.Exec,
8484
limits: {
85-
timeout: params.Timeout * 1000,
85+
timeout: params.Timeout ? (params.Timeout * 1000) : undefined,
8686
memory: params.MemorySize,
8787
concurrency: params.Concurrency,
8888
},

compile/functions/tests/index.js

+64
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,70 @@ describe('OpenWhiskCompileFunctions', () => {
139139
});
140140

141141
describe('#compileFunctions()', () => {
142+
it('should create action function with parsed parameters', () => {
143+
let functionObject = {
144+
handler: "foo.js",
145+
name: "name",
146+
namespace: "namespace",
147+
overwrite: "overwrite",
148+
memory: 123,
149+
concurrency: 456,
150+
timeout: 789,
151+
parameters: {
152+
hello: "world",
153+
foo: "bar"
154+
},
155+
annotations: {
156+
hello: "world",
157+
foo: "bar"
158+
}
159+
};
160+
161+
openwhiskCompileFunctions.serverless.service.getAllFunctions = () => ['service_name'];
162+
openwhiskCompileFunctions.serverless.service.getFunction = () => functionObject;
163+
sandbox.stub(openwhiskCompileFunctions, 'runtimes', {
164+
exec: () => Promise.resolve()
165+
});
166+
167+
return openwhiskCompileFunctions.compileFunctions().then(functionActions => {
168+
let functionAction = functionActions[0];
169+
expect(functionAction.actionName).to.be.equal(functionObject.name);
170+
expect(functionAction.namespace).to.be.equal(functionObject.namespace);
171+
expect(functionAction.overwrite).to.be.equal(functionObject.overwrite);
172+
expect(functionAction.action.limits.memory).to.be.equal(functionObject.memory);
173+
expect(functionAction.action.limits.concurrency).to.be.equal(functionObject.concurrency);
174+
expect(functionAction.action.limits.timeout).to.be.equal(functionObject.timeout * 1000);
175+
176+
let paramsAndAnnotations = [
177+
{ key: 'hello', value: 'world' },
178+
{ key: 'foo', value: 'bar' }
179+
];
180+
expect(functionAction.action.parameters).to.deep.equal(paramsAndAnnotations);
181+
expect(functionAction.action.annotations).to.deep.equal(paramsAndAnnotations);
182+
});
183+
});
184+
185+
it('should not add implicit limits parameters', () => {
186+
let functionObject = {
187+
handler: "foo.js",
188+
name: "name"
189+
};
190+
191+
openwhiskCompileFunctions.serverless.service.getAllFunctions = () => ['service_name'];
192+
openwhiskCompileFunctions.serverless.service.getFunction = () => functionObject;
193+
sandbox.stub(openwhiskCompileFunctions, 'runtimes', {
194+
exec: () => Promise.resolve()
195+
});
196+
197+
return openwhiskCompileFunctions.compileFunctions().then(functionActions => {
198+
let functionAction = functionActions[0];
199+
expect(functionAction.actionName).to.be.equal(functionObject.name);
200+
expect(functionAction.action.limits.memory).to.be.undefined;
201+
expect(functionAction.action.limits.concurrency).to.be.undefined;
202+
expect(functionAction.action.limits.timeout).to.be.undefined;
203+
});
204+
});
205+
142206
it('should throw an error if the resource section is not available', () => {
143207
openwhiskCompileFunctions.serverless.service.actions = null;
144208
expect(() => openwhiskCompileFunctions.compileFunctions())

0 commit comments

Comments
 (0)