foreman_acd 0.2.1 → 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/README.md +107 -56
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +199 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +19 -10
- data/app/controllers/foreman_acd/app_instances_controller.rb +111 -137
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +62 -0
- data/app/controllers/ui_acd_controller.rb +20 -3
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +44 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +68 -0
- data/app/models/foreman_acd/app_definition.rb +25 -0
- data/app/models/foreman_acd/app_instance.rb +42 -0
- data/app/models/foreman_acd/foreman_host.rb +23 -0
- data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +98 -0
- data/app/services/foreman_acd/app_deployer.rb +157 -0
- data/app/services/foreman_acd/inventory_creator.rb +68 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +64 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -12
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/_form.html.erb +11 -9
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +89 -10
- data/app/views/foreman_acd/app_instances/report.html.erb +6 -3
- data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
- data/app/views/ui_acd/ansible_data.json.rabl +6 -0
- data/app/views/ui_acd/app.json.rabl +6 -2
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
- data/config/routes.rb +32 -2
- data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
- data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
- data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
- data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
- data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
- data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
- data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
- data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -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/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +13 -0
- data/lib/foreman_acd.rb +12 -0
- data/lib/foreman_acd/engine.rb +43 -3
- data/lib/foreman_acd/plugin.rb +88 -22
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/tasks/foreman_acd_tasks.rake +0 -12
- data/locale/en/foreman_acd.edit.po +326 -0
- data/locale/en/foreman_acd.po +232 -2
- data/locale/en/foreman_acd.po.time_stamp +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +9 -9
- data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
- 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 +159 -29
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +106 -14
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +8 -2
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +143 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
- 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 +50 -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/ApplicationDefinition/index.js +6 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +151 -44
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +47 -10
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -2
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -28
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -1
- 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/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/index.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
- 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/ReportViewer.js +1 -1
- 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/ApplicationInstanceReport/index.js +0 -2
- data/webpack/components/ParameterSelection/ParameterSelection.js +85 -50
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +68 -62
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +6 -3
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +47 -35
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
- 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/ParameterSelection/index.js +4 -4
- 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/DeleteTableEntry.js +3 -3
- data/webpack/components/common/EditTableEntry.js +50 -0
- data/webpack/components/common/ExtTextInput.js +43 -0
- data/webpack/components/common/LockTableEntry.js +60 -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 +18 -11
- metadata +184 -10
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
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));
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import {
|
4
|
+
selectEditMode,
|
5
|
+
selectAppDefinition,
|
6
|
+
selectHosts,
|
7
|
+
selectColumns,
|
8
|
+
selectServices,
|
9
|
+
selectParametersData,
|
10
|
+
selectAnsibleVarsAll,
|
11
|
+
selectParamEditMode,
|
12
|
+
} from '../ApplicationInstanceSelectors';
|
13
|
+
|
14
|
+
import {
|
15
|
+
applicationInstanceConfData_1,
|
16
|
+
} from '../__fixtures__/applicationInstanceConfData_1.fixtures';
|
17
|
+
|
18
|
+
const stateFactory = obj => ({
|
19
|
+
foremanAcd: {
|
20
|
+
applicationInstanceConf: obj,
|
21
|
+
},
|
22
|
+
});
|
23
|
+
|
24
|
+
const fixtures = {
|
25
|
+
'should return editMode from applicationInstanceConfData_1 fixtures': () =>
|
26
|
+
selectEditMode(stateFactory(applicationInstanceConfData_1)),
|
27
|
+
'should return appDefinition from applicationInstanceConfData_1 fixtures': () =>
|
28
|
+
selectAppDefinition(stateFactory(applicationInstanceConfData_1)),
|
29
|
+
'should return hosts from applicationInstanceConfData_1 fixtures': () =>
|
30
|
+
selectHosts(stateFactory(applicationInstanceConfData_1)),
|
31
|
+
'should return columns from applicationInstanceConfData_1 fixtures': () =>
|
32
|
+
selectColumns(stateFactory(applicationInstanceConfData_1)),
|
33
|
+
'should return services from applicationInstanceConfData_1 fixtures': () =>
|
34
|
+
selectServices(stateFactory(applicationInstanceConfData_1)),
|
35
|
+
'should return parametersData from applicationInstanceConfData_1 fixtures': () =>
|
36
|
+
selectParametersData(stateFactory(applicationInstanceConfData_1)),
|
37
|
+
'should return ansibleVarsAll from applicationInstanceConfData_1 fixtures': () =>
|
38
|
+
selectAnsibleVarsAll(stateFactory(applicationInstanceConfData_1)),
|
39
|
+
'should return ParamEditMode from applicationInstanceConfData_1 fixtures': () =>
|
40
|
+
selectParamEditMode(stateFactory(applicationInstanceConfData_1)),
|
41
|
+
};
|
42
|
+
|
43
|
+
describe('ApplicationInstanceSelectors', () =>
|
44
|
+
testSelectorsSnapshotWithFixtures(fixtures));
|
data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ApplicationInstance should render application instance 1`] = `
|
4
|
+
<span>
|
5
|
+
<div
|
6
|
+
class="service-counter"
|
7
|
+
>
|
8
|
+
<ServiceCounter
|
9
|
+
hostList={Array []}
|
10
|
+
serviceList={Array []}
|
11
|
+
title="Service counts"
|
12
|
+
/>
|
13
|
+
</div>
|
14
|
+
<div>
|
15
|
+
<AppDefinitionSelector
|
16
|
+
additionalData={
|
17
|
+
Object {
|
18
|
+
"url": undefined,
|
19
|
+
}
|
20
|
+
}
|
21
|
+
editable={false}
|
22
|
+
label="Application Definition"
|
23
|
+
onChange={[Function]}
|
24
|
+
selectValue=""
|
25
|
+
viewText=""
|
26
|
+
/>
|
27
|
+
<p
|
28
|
+
style={
|
29
|
+
Object {
|
30
|
+
"paddingTop": 25,
|
31
|
+
}
|
32
|
+
}
|
33
|
+
>
|
34
|
+
<pre>
|
35
|
+
App Definition can't be blank
|
36
|
+
</pre>
|
37
|
+
</p>
|
38
|
+
</div>
|
39
|
+
<div
|
40
|
+
className="form-group"
|
41
|
+
>
|
42
|
+
<TablePfProvider
|
43
|
+
bordered={true}
|
44
|
+
className=""
|
45
|
+
columns={Array []}
|
46
|
+
components={
|
47
|
+
Object {
|
48
|
+
"body": Object {
|
49
|
+
"cell": [Function],
|
50
|
+
"row": [Function],
|
51
|
+
},
|
52
|
+
}
|
53
|
+
}
|
54
|
+
condensed={false}
|
55
|
+
dataTable={true}
|
56
|
+
hover={true}
|
57
|
+
inlineEdit={true}
|
58
|
+
striped={true}
|
59
|
+
>
|
60
|
+
<Header
|
61
|
+
headerRows={
|
62
|
+
Array [
|
63
|
+
Array [],
|
64
|
+
]
|
65
|
+
}
|
66
|
+
/>
|
67
|
+
<Body
|
68
|
+
onRow={[Function]}
|
69
|
+
rowKey="id"
|
70
|
+
rows={Array []}
|
71
|
+
/>
|
72
|
+
</TablePfProvider>
|
73
|
+
<AddTableEntry
|
74
|
+
disabled={true}
|
75
|
+
hidden={false}
|
76
|
+
onAddTableEntry={[Function]}
|
77
|
+
/>
|
78
|
+
<span
|
79
|
+
style={
|
80
|
+
Object {
|
81
|
+
"marginLeft": 30,
|
82
|
+
}
|
83
|
+
}
|
84
|
+
>
|
85
|
+
Ansible group vars 'all':
|
86
|
+
<Button
|
87
|
+
active={false}
|
88
|
+
block={false}
|
89
|
+
bsClass="btn"
|
90
|
+
bsStyle="default"
|
91
|
+
disabled={false}
|
92
|
+
onClick={[Function]}
|
93
|
+
style={
|
94
|
+
Object {
|
95
|
+
"marginLeft": 10,
|
96
|
+
}
|
97
|
+
}
|
98
|
+
>
|
99
|
+
<span
|
100
|
+
title="change ansible variables for 'all'"
|
101
|
+
>
|
102
|
+
A
|
103
|
+
</span>
|
104
|
+
</Button>
|
105
|
+
</span>
|
106
|
+
</div>
|
107
|
+
<div>
|
108
|
+
<ForemanModal
|
109
|
+
dialogClassName="param_selection_modal"
|
110
|
+
id="AppInstanceForemanParamSelection"
|
111
|
+
title="Foreman Parameter specification for Application Instance"
|
112
|
+
>
|
113
|
+
<Header
|
114
|
+
closeButton={false}
|
115
|
+
>
|
116
|
+
Parameter specification
|
117
|
+
</Header>
|
118
|
+
<Connect(ParameterSelection)
|
119
|
+
data={Object {}}
|
120
|
+
editModeCallback={[Function]}
|
121
|
+
location="Default Location"
|
122
|
+
organization="Default Organization"
|
123
|
+
paramType="PARAMETER_SELECTION_PARAM_TYPE_FOREMAN"
|
124
|
+
/>
|
125
|
+
<Footer>
|
126
|
+
<div>
|
127
|
+
<Button
|
128
|
+
active={false}
|
129
|
+
block={false}
|
130
|
+
bsClass="btn"
|
131
|
+
bsStyle="primary"
|
132
|
+
disabled={false}
|
133
|
+
onClick={[Function]}
|
134
|
+
>
|
135
|
+
Save
|
136
|
+
</Button>
|
137
|
+
<Button
|
138
|
+
active={false}
|
139
|
+
block={false}
|
140
|
+
bsClass="btn"
|
141
|
+
bsStyle="default"
|
142
|
+
disabled={false}
|
143
|
+
onClick={[Function]}
|
144
|
+
>
|
145
|
+
Cancel
|
146
|
+
</Button>
|
147
|
+
</div>
|
148
|
+
</Footer>
|
149
|
+
</ForemanModal>
|
150
|
+
</div>
|
151
|
+
<div>
|
152
|
+
<ForemanModal
|
153
|
+
dialogClassName="param_selection_modal"
|
154
|
+
id="AppInstanceAnsibleParamSelection"
|
155
|
+
title="Ansible group variables for Application Instance"
|
156
|
+
>
|
157
|
+
<Header
|
158
|
+
closeButton={false}
|
159
|
+
>
|
160
|
+
Parameter specification
|
161
|
+
</Header>
|
162
|
+
<Connect(ParameterSelection)
|
163
|
+
data={Object {}}
|
164
|
+
editModeCallback={[Function]}
|
165
|
+
location="Default Location"
|
166
|
+
organization="Default Organization"
|
167
|
+
paramType="PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE"
|
168
|
+
/>
|
169
|
+
<Footer>
|
170
|
+
<div>
|
171
|
+
<Button
|
172
|
+
active={false}
|
173
|
+
block={false}
|
174
|
+
bsClass="btn"
|
175
|
+
bsStyle="primary"
|
176
|
+
disabled={false}
|
177
|
+
onClick={[Function]}
|
178
|
+
>
|
179
|
+
Save
|
180
|
+
</Button>
|
181
|
+
<Button
|
182
|
+
active={false}
|
183
|
+
block={false}
|
184
|
+
bsClass="btn"
|
185
|
+
bsStyle="default"
|
186
|
+
disabled={false}
|
187
|
+
onClick={[Function]}
|
188
|
+
>
|
189
|
+
Cancel
|
190
|
+
</Button>
|
191
|
+
</div>
|
192
|
+
</Footer>
|
193
|
+
</ForemanModal>
|
194
|
+
</div>
|
195
|
+
<div />
|
196
|
+
<RailsData
|
197
|
+
key="applications_instance"
|
198
|
+
parameter="hosts"
|
199
|
+
value="[]"
|
200
|
+
view="app_instance"
|
201
|
+
/>
|
202
|
+
<RailsData
|
203
|
+
key="applications_instance"
|
204
|
+
parameter="ansible_vars_all"
|
205
|
+
value="[]"
|
206
|
+
view="app_instance"
|
207
|
+
/>
|
208
|
+
</span>
|
209
|
+
`;
|