foreman_acd 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +75 -0
- data/app/controllers/foreman_acd/app_instances_controller.rb +19 -2
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
- data/app/lib/actions/foreman_acd/run_configurator.rb +10 -7
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +2 -2
- data/app/models/foreman_acd/acd_provider.rb +7 -1
- data/app/models/foreman_acd/ansible_playbook.rb +2 -1
- data/app/models/foreman_acd/app_instance.rb +1 -1
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +59 -15
- data/app/services/foreman_acd/app_deployer.rb +8 -2
- data/app/services/foreman_acd/inventory_creator.rb +14 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
- data/app/views/foreman_acd/app_definitions/_form.html.erb +1 -1
- data/app/views/foreman_acd/app_instances/_form.html.erb +1 -1
- data/app/views/foreman_acd/app_instances/index.html.erb +5 -3
- data/app/views/foreman_acd/app_instances/report.html.erb +1 -1
- data/app/views/templates/job/run_acd_ansible_playbook.erb +1 -1
- data/config/routes.rb +3 -0
- data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
- data/db/seeds.d/75-job_templates.rb +1 -1
- data/lib/foreman_acd.rb +12 -0
- data/lib/foreman_acd/engine.rb +26 -4
- data/lib/foreman_acd/plugin.rb +0 -9
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/tasks/foreman_acd_tasks.rake +0 -12
- data/package.json +8 -8
- data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
- data/test/controllers/app_instances_controller_test.rb +8 -3
- data/test/controllers/ui_acd_controller_test.rb +22 -6
- data/test/factories/foreman_acd_factories.rb +18 -4
- data/test/models/acd_provider_test.rb +37 -0
- data/test/models/ansible_playbook_test.rb +11 -0
- data/test/models/app_definition_test.rb +1 -1
- data/test/models/app_instance_test.rb +2 -0
- data/test/models/concerns/host_extensions_test.rb +26 -0
- data/test/models/foreman_host_test.rb +12 -0
- data/webpack/__mocks__/foremanReact/API.js +2 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
- data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
- data/webpack/__snapshots__/helper.test.js.snap +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +1 -1
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +1 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +3 -5
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
- data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +2 -21
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/ExtTextInput.js +43 -0
- data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
- data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
- data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
- data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
- data/webpack/helper.js +15 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +2 -0
- data/webpack/reducer.js +4 -0
- metadata +92 -11
- data/webpack/components/common/EasyHeaderFormatter.js +0 -18
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -15,10 +15,10 @@ import ParameterSelection from '../ParameterSelection';
|
|
15
15
|
import AddTableEntry from '../common/AddTableEntry';
|
16
16
|
import DeleteTableEntry from '../common/DeleteTableEntry';
|
17
17
|
import RailsData from '../common/RailsData';
|
18
|
-
import EasyHeaderFormatter from '../common/EasyHeaderFormatter';
|
19
18
|
import AppDefinitionSelector from './components/AppDefinitionSelector';
|
20
19
|
import ServiceCounter from './components/ServiceCounter';
|
21
20
|
import { arrayToObject } from '../../helper';
|
21
|
+
import { EasyHeaderFormatter } from '../../helper';
|
22
22
|
|
23
23
|
import {
|
24
24
|
Table,
|
@@ -63,8 +63,6 @@ class ApplicationInstance extends React.Component {
|
|
63
63
|
const invalidMinServices = this.props.services.filter(s => (Number(s.minCount) != 0) && (s.currentCount < s.minCount));
|
64
64
|
const invalidMaxServices = this.props.services.filter(s => (Number(s.maxCount) != 0) && (s.currentCount > s.maxCount));
|
65
65
|
|
66
|
-
console.log(invalidMinServices);
|
67
|
-
|
68
66
|
if (invalidMinServices.length > 0 || invalidMaxServices.length > 0) {
|
69
67
|
result = false;
|
70
68
|
|
@@ -217,8 +215,8 @@ class ApplicationInstance extends React.Component {
|
|
217
215
|
prettyValue = serviceList[value];
|
218
216
|
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
219
217
|
}
|
220
|
-
|
221
|
-
|
218
|
+
if (additionalData.property == 'hostname') {
|
219
|
+
if (additionalData.rowData.newEntry === true) {
|
222
220
|
return inlineEditFormatterImpl.renderEditText(value, additionalData);
|
223
221
|
}
|
224
222
|
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
export const applicationInstanceConfData_1 = {
|
2
|
+
name: false,
|
3
|
+
error: {
|
4
|
+
errorMsg: '',
|
5
|
+
status: '',
|
6
|
+
statusText: ''
|
7
|
+
},
|
8
|
+
loading: false,
|
9
|
+
columns: [
|
10
|
+
{
|
11
|
+
property: 'hostname',
|
12
|
+
header: {
|
13
|
+
label: 'Hostname',
|
14
|
+
formatters: [
|
15
|
+
null
|
16
|
+
],
|
17
|
+
props: {
|
18
|
+
index: 0,
|
19
|
+
style: {
|
20
|
+
width: '30%'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
},
|
24
|
+
cell: {
|
25
|
+
formatters: [
|
26
|
+
null
|
27
|
+
]
|
28
|
+
}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
property: 'description',
|
32
|
+
header: {
|
33
|
+
label: 'Description',
|
34
|
+
formatters: [
|
35
|
+
null
|
36
|
+
],
|
37
|
+
props: {
|
38
|
+
index: 1,
|
39
|
+
style: {
|
40
|
+
width: '30%'
|
41
|
+
}
|
42
|
+
}
|
43
|
+
},
|
44
|
+
cell: {
|
45
|
+
formatters: [
|
46
|
+
null
|
47
|
+
]
|
48
|
+
}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
property: 'service',
|
52
|
+
header: {
|
53
|
+
label: 'Service',
|
54
|
+
formatters: [
|
55
|
+
null
|
56
|
+
],
|
57
|
+
props: {
|
58
|
+
index: 2,
|
59
|
+
style: {
|
60
|
+
width: '20%'
|
61
|
+
}
|
62
|
+
}
|
63
|
+
},
|
64
|
+
cell: {
|
65
|
+
formatters: [
|
66
|
+
null
|
67
|
+
]
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
property: 'actions',
|
72
|
+
header: {
|
73
|
+
label: 'Actions',
|
74
|
+
formatters: [
|
75
|
+
null
|
76
|
+
],
|
77
|
+
props: {
|
78
|
+
index: 4,
|
79
|
+
style: {
|
80
|
+
width: '20%'
|
81
|
+
}
|
82
|
+
}
|
83
|
+
},
|
84
|
+
cell: {
|
85
|
+
formatters: [
|
86
|
+
null
|
87
|
+
]
|
88
|
+
}
|
89
|
+
}
|
90
|
+
],
|
91
|
+
appDefinition: {
|
92
|
+
id: 1,
|
93
|
+
name: 'LAMP',
|
94
|
+
description: '',
|
95
|
+
services: '[{"id":1,"name":"web","description":"","hostgroup":"1","ansibleGroup":"webservers","minCount":"2","maxCount":"","foremanParameters":[{"id":1,"locked":false,"name":"CP","description":"","type":"computeprofile","value":"1"},{"id":2,"locked":true,"name":"LE","description":"","type":"lifecycleenv","value":"1"}],"ansibleParameters":[{"id":0,"name":"dummy_var","value":"0"}]},{"id":2,"name":"db","description":"","hostgroup":"1","ansibleGroup":"dbservers","minCount":"1","maxCount":"","foremanParameters":[],"ansibleParameters":[{"id":0,"name":"mysqlservice","value":"mysqld"},{"id":1,"name":"mysql_port","value":"3306","locked":true},{"id":2,"name":"dbuser","value":"webapp"},{"id":3,"name":"dbname","value":"ANSAP01"},{"id":4,"name":"upassword","value":"Bond@007"},{"id":5,"name":"masterpassword","value":"MySQL@007"}]}]',
|
96
|
+
ansible_vars_all: '[{"id":0,"name":"repository","value":"https://github.com/bennojoy/mywebapp.git"}]',
|
97
|
+
location_ids: [
|
98
|
+
2
|
99
|
+
],
|
100
|
+
organization_ids: [
|
101
|
+
1
|
102
|
+
],
|
103
|
+
created_at: '2021-03-11 12:51:34 +0100',
|
104
|
+
updated_at: '2021-03-13 00:06:12 +0100'
|
105
|
+
},
|
106
|
+
hosts: [
|
107
|
+
{
|
108
|
+
id: 4,
|
109
|
+
hostname: 'great-web-app-db-1',
|
110
|
+
service: '2',
|
111
|
+
description: '',
|
112
|
+
foremanParameters: [],
|
113
|
+
ansibleParameters: [
|
114
|
+
{
|
115
|
+
id: 0,
|
116
|
+
name: 'mysqlservice',
|
117
|
+
value: 'mysqld'
|
118
|
+
},
|
119
|
+
{
|
120
|
+
id: 1,
|
121
|
+
name: 'mysql_port',
|
122
|
+
value: '3306'
|
123
|
+
},
|
124
|
+
{
|
125
|
+
id: 2,
|
126
|
+
name: 'dbuser',
|
127
|
+
value: 'webapp'
|
128
|
+
},
|
129
|
+
{
|
130
|
+
id: 3,
|
131
|
+
name: 'dbname',
|
132
|
+
value: 'ANSAP01'
|
133
|
+
},
|
134
|
+
{
|
135
|
+
id: 4,
|
136
|
+
name: 'upassword',
|
137
|
+
value: 'Bond@007'
|
138
|
+
},
|
139
|
+
{
|
140
|
+
id: 5,
|
141
|
+
name: 'masterpassword',
|
142
|
+
value: 'MySQL@007'
|
143
|
+
}
|
144
|
+
]
|
145
|
+
},
|
146
|
+
{
|
147
|
+
id: 1,
|
148
|
+
hostname: 'great-web-app-web-1',
|
149
|
+
service: '1',
|
150
|
+
description: '',
|
151
|
+
foremanParameters: [],
|
152
|
+
ansibleParameters: [
|
153
|
+
{
|
154
|
+
id: 0,
|
155
|
+
name: 'dummy_var',
|
156
|
+
value: '0'
|
157
|
+
}
|
158
|
+
]
|
159
|
+
},
|
160
|
+
{
|
161
|
+
id: 2,
|
162
|
+
hostname: 'great-web-app-web-2',
|
163
|
+
service: '1',
|
164
|
+
description: '',
|
165
|
+
foremanParameters: [],
|
166
|
+
ansibleParameters: [
|
167
|
+
{
|
168
|
+
id: 0,
|
169
|
+
name: 'dummy_var',
|
170
|
+
value: '0'
|
171
|
+
}
|
172
|
+
]
|
173
|
+
}
|
174
|
+
],
|
175
|
+
ansibleVarsAll: [
|
176
|
+
{
|
177
|
+
id: 0,
|
178
|
+
name: 'repository',
|
179
|
+
value: 'https://github.com/bennojoy/mywebapp.git'
|
180
|
+
}
|
181
|
+
],
|
182
|
+
services: [
|
183
|
+
{
|
184
|
+
id: 1,
|
185
|
+
name: 'web',
|
186
|
+
description: '',
|
187
|
+
hostgroup: '1',
|
188
|
+
ansibleGroup: 'webservers',
|
189
|
+
minCount: '2',
|
190
|
+
maxCount: '',
|
191
|
+
foremanParameters: [
|
192
|
+
{
|
193
|
+
id: 1,
|
194
|
+
locked: false,
|
195
|
+
name: 'CP',
|
196
|
+
description: '',
|
197
|
+
type: 'computeprofile',
|
198
|
+
value: '1'
|
199
|
+
},
|
200
|
+
{
|
201
|
+
id: 2,
|
202
|
+
locked: true,
|
203
|
+
name: 'LE',
|
204
|
+
description: '',
|
205
|
+
type: 'lifecycleenv',
|
206
|
+
value: '1'
|
207
|
+
}
|
208
|
+
],
|
209
|
+
ansibleParameters: [
|
210
|
+
{
|
211
|
+
id: 0,
|
212
|
+
name: 'dummy_var',
|
213
|
+
value: '0'
|
214
|
+
}
|
215
|
+
],
|
216
|
+
currentCount: 2
|
217
|
+
},
|
218
|
+
{
|
219
|
+
id: 2,
|
220
|
+
name: 'db',
|
221
|
+
description: '',
|
222
|
+
hostgroup: '1',
|
223
|
+
ansibleGroup: 'dbservers',
|
224
|
+
minCount: '1',
|
225
|
+
maxCount: '',
|
226
|
+
foremanParameters: [],
|
227
|
+
ansibleParameters: [
|
228
|
+
{
|
229
|
+
id: 0,
|
230
|
+
name: 'mysqlservice',
|
231
|
+
value: 'mysqld'
|
232
|
+
},
|
233
|
+
{
|
234
|
+
id: 1,
|
235
|
+
name: 'mysql_port',
|
236
|
+
value: '3306',
|
237
|
+
locked: true
|
238
|
+
},
|
239
|
+
{
|
240
|
+
id: 2,
|
241
|
+
name: 'dbuser',
|
242
|
+
value: 'webapp'
|
243
|
+
},
|
244
|
+
{
|
245
|
+
id: 3,
|
246
|
+
name: 'dbname',
|
247
|
+
value: 'ANSAP01'
|
248
|
+
},
|
249
|
+
{
|
250
|
+
id: 4,
|
251
|
+
name: 'upassword',
|
252
|
+
value: 'Bond@007'
|
253
|
+
},
|
254
|
+
{
|
255
|
+
id: 5,
|
256
|
+
name: 'masterpassword',
|
257
|
+
value: 'MySQL@007'
|
258
|
+
}
|
259
|
+
],
|
260
|
+
currentCount: 1
|
261
|
+
}
|
262
|
+
]
|
263
|
+
}
|
data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
cloneDeep,
|
4
|
+
findIndex,
|
5
|
+
findLastIndex,
|
6
|
+
} from 'lodash';
|
7
|
+
|
8
|
+
import {
|
9
|
+
applicationInstanceConfData_1,
|
10
|
+
} from '../__fixtures__/applicationInstanceConfData_1.fixtures';
|
11
|
+
|
12
|
+
export const successState = Immutable(applicationInstanceConfData_1);
|
13
|
+
|
14
|
+
const EDIT_ROW_ID = 2;
|
15
|
+
|
16
|
+
const editClone = applicationInstanceConfData_1;
|
17
|
+
const editIndex = findIndex(editClone.hosts, { id: EDIT_ROW_ID })
|
18
|
+
editClone["hosts"][editIndex].backup = cloneDeep(editClone["hosts"][editIndex]);
|
19
|
+
export const editState = Immutable(editClone);
|
20
|
+
|
21
|
+
// Payload Data
|
22
|
+
export const initApplicationInstancePayload = applicationInstanceConfData_1;
|
23
|
+
export const addHostPayload = { };
|
24
|
+
export const deleteHostPayload = {
|
25
|
+
rowData: {
|
26
|
+
id: EDIT_ROW_ID,
|
27
|
+
},
|
28
|
+
};
|
29
|
+
export const activateEditHostPayload = {
|
30
|
+
rowData: {
|
31
|
+
id: EDIT_ROW_ID,
|
32
|
+
},
|
33
|
+
};
|
34
|
+
export const confirmEditHostPayload = {
|
35
|
+
rowData: {
|
36
|
+
id: EDIT_ROW_ID,
|
37
|
+
},
|
38
|
+
};
|
39
|
+
export const cancelEditHostPayload = {
|
40
|
+
rowData: {
|
41
|
+
id: EDIT_ROW_ID,
|
42
|
+
},
|
43
|
+
};
|
44
|
+
export const changeEditHostPayload = {
|
45
|
+
value: "helloworld",
|
46
|
+
property: "name",
|
47
|
+
rowData: {
|
48
|
+
id: EDIT_ROW_ID,
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
export const loadApplicationDefinitionRequestPayload = {
|
53
|
+
clearRows: false,
|
54
|
+
};
|
55
|
+
|
56
|
+
export const loadApplicationDefinitionSuccessPayload = {
|
57
|
+
app_definition: {
|
58
|
+
id: 1,
|
59
|
+
name: "LAMP",
|
60
|
+
description: "",
|
61
|
+
services: "[{\"id\":1,\"name\":\"web\",\"description\":\"\",\"hostgroup\":\"1\",\"ansibleGroup\":\"webservers\",\"minCount\":\"2\",\"maxCount\":\"\",\"foremanParameters\":[{\"id\":1,\"locked\":false,\"name\":\"CP\",\"description\":\"\",\"type\":\"computeprofile\",\"value\":\"1\"},{\"id\":2,\"locked\":true,\"name\":\"LE\",\"description\":\"\",\"type\":\"lifecycleenv\",\"value\":\"1\"}],\"ansibleParameters\":[{\"id\":0,\"name\":\"dummy_var\",\"value\":\"0\"}]},{\"id\":2,\"name\":\"db\",\"description\":\"\",\"hostgroup\":\"1\",\"ansibleGroup\":\"dbservers\",\"minCount\":\"1\",\"maxCount\":\"\",\"foremanParameters\":[],\"ansibleParameters\":[{\"id\":0,\"name\":\"mysqlservice\",\"value\":\"mysqld\"},{\"id\":1,\"name\":\"mysql_port\",\"value\":\"3306\",\"locked\":true},{\"id\":2,\"name\":\"dbuser\",\"value\":\"webapp\"},{\"id\":3,\"name\":\"dbname\",\"value\":\"ANSAP01\"},{\"id\":4,\"name\":\"upassword\",\"value\":\"Bond@007\"},{\"id\":5,\"name\":\"masterpassword\",\"value\":\"MySQL@007\"}]}]",
|
62
|
+
"ansible_vars_all": "[{\"id\":0,\"name\":\"repository\",\"value\":\"https://github.com/bennojoy/mywebapp.git\"}]",
|
63
|
+
location_ids: [
|
64
|
+
2
|
65
|
+
],
|
66
|
+
organization_ids: [
|
67
|
+
1
|
68
|
+
],
|
69
|
+
created_at: "2021-03-11 12:51:34 +0100",
|
70
|
+
updated_at: "2021-03-13 00:06:12 +0100"
|
71
|
+
},
|
72
|
+
foreman_data: null,
|
73
|
+
ansible_data: null
|
74
|
+
};
|
75
|
+
|
76
|
+
export const loadApplicationDefinitionFailurePayload = {
|
77
|
+
error: "Something really bad happend",
|
78
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import ApplicationInstance from '../ApplicationInstance';
|
4
|
+
|
5
|
+
const noop = () => {};
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render application instance': {
|
9
|
+
data: {
|
10
|
+
location: "Default Location",
|
11
|
+
organization: "Default Organization",
|
12
|
+
appDefinition: {},
|
13
|
+
hosts: [],
|
14
|
+
ansibleVarsAll: [],
|
15
|
+
},
|
16
|
+
loadApplicationDefinition: noop,
|
17
|
+
initApplicationInstance: noop,
|
18
|
+
addApplicationInstanceHost: noop,
|
19
|
+
},
|
20
|
+
};
|
21
|
+
|
22
|
+
describe('ApplicationInstance', () =>
|
23
|
+
testComponentSnapshotsWithFixtures(ApplicationInstance, fixtures));
|
@@ -0,0 +1,119 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import reducer, { initialState } from '../ApplicationInstanceReducer';
|
3
|
+
|
4
|
+
import {
|
5
|
+
successState,
|
6
|
+
editState,
|
7
|
+
initApplicationInstancePayload,
|
8
|
+
addHostPayload,
|
9
|
+
deleteHostPayload,
|
10
|
+
activateEditHostPayload,
|
11
|
+
confirmEditHostPayload,
|
12
|
+
cancelEditHostPayload,
|
13
|
+
changeEditHostPayload,
|
14
|
+
loadApplicationDefinitionRequestPayload,
|
15
|
+
loadApplicationDefinitionSuccessPayload,
|
16
|
+
loadApplicationDefinitionFailurePayload,
|
17
|
+
} from '../__fixtures__/applicationInstanceReducer.fixtures';
|
18
|
+
|
19
|
+
import {
|
20
|
+
APPLICATION_INSTANCE_INIT,
|
21
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
|
22
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
23
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
|
24
|
+
APPLICATION_INSTANCE_HOST_DELETE,
|
25
|
+
APPLICATION_INSTANCE_HOST_ADD,
|
26
|
+
APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
|
27
|
+
APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
28
|
+
APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
29
|
+
APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
30
|
+
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
|
31
|
+
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
|
32
|
+
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
|
33
|
+
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
|
34
|
+
APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
|
35
|
+
} from '../ApplicationInstanceConstants';
|
36
|
+
|
37
|
+
const fixtures = {
|
38
|
+
'should return initial state': {
|
39
|
+
state: initialState,
|
40
|
+
action: {
|
41
|
+
type: undefined,
|
42
|
+
payload: {},
|
43
|
+
},
|
44
|
+
},
|
45
|
+
|
46
|
+
'should initialize component': {
|
47
|
+
state: initialState,
|
48
|
+
action: {
|
49
|
+
type: APPLICATION_INSTANCE_INIT,
|
50
|
+
payload: initApplicationInstancePayload,
|
51
|
+
},
|
52
|
+
},
|
53
|
+
'should add a host': {
|
54
|
+
state: successState,
|
55
|
+
action: {
|
56
|
+
type: APPLICATION_INSTANCE_HOST_ADD,
|
57
|
+
payload: addHostPayload,
|
58
|
+
},
|
59
|
+
},
|
60
|
+
'should delete a host': {
|
61
|
+
state: successState,
|
62
|
+
action: {
|
63
|
+
type: APPLICATION_INSTANCE_HOST_DELETE,
|
64
|
+
payload: deleteHostPayload,
|
65
|
+
},
|
66
|
+
},
|
67
|
+
'should activate edit host': {
|
68
|
+
state: successState,
|
69
|
+
action: {
|
70
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
|
71
|
+
payload: activateEditHostPayload,
|
72
|
+
},
|
73
|
+
},
|
74
|
+
'should change edit host': {
|
75
|
+
state: editState,
|
76
|
+
action: {
|
77
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
78
|
+
payload: changeEditHostPayload,
|
79
|
+
},
|
80
|
+
},
|
81
|
+
'should confirm edit host': {
|
82
|
+
state: editState,
|
83
|
+
action: {
|
84
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
85
|
+
payload: confirmEditHostPayload,
|
86
|
+
},
|
87
|
+
},
|
88
|
+
'should cancel edit host': {
|
89
|
+
state: editState,
|
90
|
+
action: {
|
91
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
92
|
+
payload: cancelEditHostPayload,
|
93
|
+
},
|
94
|
+
},
|
95
|
+
'should request load param data': {
|
96
|
+
state: successState,
|
97
|
+
action: {
|
98
|
+
type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
|
99
|
+
payload: loadApplicationDefinitionRequestPayload,
|
100
|
+
},
|
101
|
+
},
|
102
|
+
'should load param data be successful': {
|
103
|
+
state: successState,
|
104
|
+
action: {
|
105
|
+
type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
106
|
+
payload: loadApplicationDefinitionSuccessPayload,
|
107
|
+
},
|
108
|
+
},
|
109
|
+
'should load param data be erroneous': {
|
110
|
+
state: successState,
|
111
|
+
action: {
|
112
|
+
type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
|
113
|
+
payload: loadApplicationDefinitionFailurePayload,
|
114
|
+
},
|
115
|
+
},
|
116
|
+
};
|
117
|
+
|
118
|
+
describe('ApplicationInstanceReducer', () =>
|
119
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|