@spinnaker/core 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spinnaker/core",
3
3
  "license": "Apache-2.0",
4
- "version": "0.16.1",
4
+ "version": "0.17.0",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
@@ -120,5 +120,5 @@
120
120
  "shx": "0.3.3",
121
121
  "typescript": "4.3.5"
122
122
  },
123
- "gitHead": "17b98201c6de43729a39f6d205656d0c4be1db16"
123
+ "gitHead": "fd69b27a052ccb2a170efdbe0b971a8636c96447"
124
124
  }
@@ -16,6 +16,7 @@ export interface IPipeline {
16
16
  locked?: IPipelineLock;
17
17
  limitConcurrent: boolean;
18
18
  manualStartAlert?: IPipelineManualStartAlert;
19
+ maxConcurrentExecutions?: number;
19
20
  migrationStatus?: string;
20
21
  name: string;
21
22
  notifications?: INotification[];
@@ -364,6 +364,8 @@ const helpContents: { [key: string]: string } = {
364
364
  'pipeline.config.dependsOn': 'Declares which stages must be run <em>before</em> this stage begins.',
365
365
  'pipeline.config.parallel.cancel.queue':
366
366
  '<p>If concurrent pipeline execution is disabled, then the pipelines that are in the waiting queue will get canceled when the next execution starts. <br><br>Check this box if you want to keep them in the queue.</p>',
367
+ 'pipeline.config.parallel.max.concurrent':
368
+ '<p>If concurrent pipeline execution is enabled, this variable sets the maximum number of concurrent pipelines executing. <br><br>If set to 0, then max is unlimited.</p>',
367
369
  'pipeline.config.timeout': `
368
370
  <p>Allows you to force the stage to fail if its running time exceeds a specific length.</p>
369
371
  <p><b>Note:</b> By default, Spinnaker will use sensible timeouts that depend on the stage type and the operations the stage needs to perform at runtime. These defaults can vary based on chosen configuration and other external factors.
@@ -21,4 +21,12 @@ describe('Help contents registry', () => {
21
21
  expect(HelpContentsRegistry.getHelpField('a')).toBe('b');
22
22
  });
23
23
  });
24
+
25
+ describe('max concurrent definition', () => {
26
+ it('provides the expected definition for max concurrent', () => {
27
+ const definition =
28
+ '<p>If concurrent pipeline execution is enabled, this variable sets the maximum number of concurrent pipelines executing. <br><br>If set to 0, then max is unlimited.</p>';
29
+ expect(HelpContentsRegistry.getHelpField('pipeline.config.parallel.max.concurrent')).toEqual(definition);
30
+ });
31
+ });
24
32
  });
@@ -0,0 +1,90 @@
1
+ import { mount } from 'enzyme';
2
+ import React from 'react';
3
+
4
+ import { ExecutionOptionsPageContent } from './ExecutionOptionsPageContent';
5
+ import type { IPipeline } from '../../../domain';
6
+
7
+ describe('Execution Options Page Content', () => {
8
+ describe('Max Concurrent Options', () => {
9
+ let pipeline: IPipeline;
10
+ const setPipeline = (overrides: any = {}) => {
11
+ pipeline = {
12
+ application: 'test',
13
+ id: 'test1',
14
+ keepWaitingPipelines: false,
15
+ limitConcurrent: false,
16
+ maxConcurrentExecutions: 0,
17
+ name: 'test p 1', // @ts-ignore
18
+ parameterConfig: [], // @ts-ignore
19
+ stages: [], // @ts-ignore
20
+ triggers: [],
21
+ ...overrides,
22
+ };
23
+ };
24
+ const update = (changes: any = {}) => {
25
+ pipeline = {
26
+ ...pipeline,
27
+ ...changes,
28
+ };
29
+ };
30
+ describe('enabling max concurrent', () => {
31
+ it('sets keepWaitingPipelines to true if limitConcurrent and keepWaitingPipelines are both not truthy', () => {
32
+ setPipeline();
33
+ const wrapper = mount(<ExecutionOptionsPageContent pipeline={pipeline} updatePipelineConfig={update} />);
34
+ expect(pipeline.keepWaitingPipelines).toBeFalsy();
35
+ const checkbox = wrapper.find('input').at(0);
36
+ checkbox.simulate('change', { target: { checked: true } });
37
+ expect(pipeline.keepWaitingPipelines).toBeTruthy();
38
+ });
39
+
40
+ it('does not alter pipeline if limitConcurrent is true', () => {
41
+ setPipeline({ limitConcurrent: true });
42
+ const wrapper = mount(<ExecutionOptionsPageContent pipeline={pipeline} updatePipelineConfig={update} />);
43
+ expect(pipeline.keepWaitingPipelines).toBeFalsy();
44
+ const checkbox = wrapper.find('input').at(0);
45
+ checkbox.simulate('change', { target: { checked: true } });
46
+ expect(pipeline.keepWaitingPipelines).toBeFalsy();
47
+ });
48
+
49
+ it('does not alter pipeline if keepWaitingPipelines is true', () => {
50
+ setPipeline({ keepWaitingPipelines: true });
51
+ const wrapper = mount(<ExecutionOptionsPageContent pipeline={pipeline} updatePipelineConfig={update} />);
52
+ expect(pipeline.keepWaitingPipelines).toBeTruthy();
53
+ const checkbox = wrapper.find('input').at(0);
54
+ checkbox.simulate('change', { target: { checked: true } });
55
+ expect(pipeline.keepWaitingPipelines).toBeTruthy();
56
+ });
57
+
58
+ it('defaults the max concurrent value to 0', () => {
59
+ setPipeline();
60
+ const wrapper = mount(<ExecutionOptionsPageContent pipeline={pipeline} updatePipelineConfig={update} />);
61
+ const checkbox = wrapper.find('input').at(0);
62
+ checkbox.simulate('change', { target: { checked: true } });
63
+ const concurrentInput = wrapper.find('input[type="number"]').at(0);
64
+ expect(concurrentInput.prop('value')).toEqual(0);
65
+ });
66
+ });
67
+
68
+ it('updates the max concurrent config value when the input is changed', () => {
69
+ setPipeline();
70
+ const value = 22;
71
+ const wrapper = mount(<ExecutionOptionsPageContent pipeline={pipeline} updatePipelineConfig={update} />);
72
+ const checkbox = wrapper.find('input').at(0);
73
+ checkbox.simulate('change', { target: { checked: true } });
74
+ const concurrentInput = wrapper.find('input[type="number"]').at(0);
75
+ concurrentInput.simulate('change', { target: { value } });
76
+ expect(pipeline.maxConcurrentExecutions).toEqual(value);
77
+ });
78
+
79
+ it('sets the max concurrent value to a whole number if a float is entered', () => {
80
+ setPipeline();
81
+ const value = 3.3;
82
+ const wrapper = mount(<ExecutionOptionsPageContent pipeline={pipeline} updatePipelineConfig={update} />);
83
+ const checkbox = wrapper.find('input').at(0);
84
+ checkbox.simulate('change', { target: { checked: true } });
85
+ const concurrentInput = wrapper.find('input[type="number"]').at(0);
86
+ concurrentInput.simulate('change', { target: { value } });
87
+ expect(pipeline.maxConcurrentExecutions).toEqual(3);
88
+ });
89
+ });
90
+ });
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
 
3
3
  import type { IPipeline } from '../../../domain';
4
4
  import { HelpField } from '../../../help';
5
- import { CheckboxInput, FormField } from '../../../presentation';
5
+ import { CheckboxInput, FormField, NumberInput } from '../../../presentation';
6
6
 
7
7
  export interface IExecutionOptionsPageContentProps {
8
8
  pipeline: IPipeline;
@@ -11,6 +11,13 @@ export interface IExecutionOptionsPageContentProps {
11
11
 
12
12
  export function ExecutionOptionsPageContent(props: IExecutionOptionsPageContentProps) {
13
13
  const { pipeline, updatePipelineConfig } = props;
14
+ const [currentMaxConcurrent, setCurrentMaxConcurrent] = useState(pipeline.maxConcurrentExecutions || 0);
15
+ const handleMaxConcurrentChange = (changeEvent: any) => {
16
+ const value = Number.parseInt(changeEvent.target.value);
17
+ setCurrentMaxConcurrent(value);
18
+ updatePipelineConfig({ maxConcurrentExecutions: value });
19
+ };
20
+
14
21
  return (
15
22
  <div className="row">
16
23
  <div className="col-md-11 col-md-offset-1">
@@ -23,6 +30,10 @@ export function ExecutionOptionsPageContent(props: IExecutionOptionsPageContentP
23
30
  )}
24
31
  onChange={() => {
25
32
  updatePipelineConfig({ limitConcurrent: !pipeline.limitConcurrent });
33
+ if (!pipeline.limitConcurrent && !pipeline.keepWaitingPipelines) {
34
+ pipeline.keepWaitingPipelines = true;
35
+ updatePipelineConfig({ keepWaitingPipelines: true });
36
+ }
26
37
  }}
27
38
  value={pipeline.limitConcurrent}
28
39
  />
@@ -45,6 +56,20 @@ export function ExecutionOptionsPageContent(props: IExecutionOptionsPageContentP
45
56
  value={pipeline.keepWaitingPipelines}
46
57
  />
47
58
  )}
59
+ {!pipeline.limitConcurrent && (
60
+ <div>
61
+ <label className="col-md-3 sm-label-right">
62
+ Maximum concurrent pipeline executions <HelpField id={'pipeline.config.parallel.max.concurrent'} />
63
+ </label>
64
+ <div className="col-md-8">
65
+ <FormField
66
+ input={(inputProps) => <NumberInput {...inputProps} min={0} max={65534} />}
67
+ onChange={handleMaxConcurrentChange}
68
+ value={currentMaxConcurrent}
69
+ />
70
+ </div>
71
+ </div>
72
+ )}
48
73
  </div>
49
74
  </div>
50
75
  );