Welcome to mirror list, hosted at ThFree Co, Russian Federation.

testFormHostFromStandalone.php « hosts « selenium « tests « ui - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 83b0f1728a24194b20fe3037e0a5f4012b91ef3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/


require_once dirname(__FILE__).'/../common/testFormHost.php';

/**
 * @dataSource DiscoveredHosts, Proxies
 *
 * @backup hosts
 *
 * @onBefore prepareUpdateData
 */
class testFormHostFromStandalone extends testFormHost {

	public $standalone = true;
	public $link = 'zabbix.php?action=host.edit&hostid=';

	public function testFormHostFromStandalone_Layout() {
		$this->checkHostLayout();
	}

	/**
	 * @dataProvider getCreateData
	 */
	public function testFormHostFromStandalone_Create($data) {
		$this->link = 'zabbix.php?action=host.edit';
		$this->checkHostCreate($data);
	}

	/**
	 * @dataProvider getValidationUpdateData
	 */
	public function testFormHostFromStandalone_ValidationUpdate($data) {
		$this->checkHostUpdate($data);
	}

	/**
	 * @backup hosts
	 *
	 * @dataProvider getUpdateData
	 */
	public function testFormHostFromStandalone_Update($data) {
		$this->checkHostUpdate($data);
	}

	/**
	 * Update the host without any changes and check host and interfaces hashes.
	 */
	public function testFormHostFromStandalone_SimpleUpdate() {
		$this->checkHostSimpleUpdate();
	}

	/**
	 * @dataProvider getCloneData
	 */
	public function testFormHostFromStandalone_Clone($data) {
		$this->cloneHost($data, 'Clone');

		// Check that items aren't cloned from original host.
		$this->assertItemsDBCount($data['fields']['Host name'], 0);
	}

	/**
	 * @dataProvider getCloneData
	 */
	public function testFormHostFromStandalone_FullClone($data) {
		$this->cloneHost($data, 'Full clone');

		// Check that items cloned from original host.
		$this->assertItemsDBCount($data['fields']['Host name'], $data['items']);
	}

	/**
	 * @dataProvider getCancelData
	 */
	public function testFormHostFromStandalone_Cancel($data) {
		$this->link = 'zabbix.php?action=host.edit';
		$this->checkCancel($data);
	}

	/**
	 * @dataProvider getDeleteData
	 */
	public function testFormHostFromStandalone_Delete($data) {
		$this->checkDelete($data);
	}

	public function testFormHostFromStandalone_DiscoveredHostLayout() {
		$this->checkDiscoveredHostLayout();
	}

	/**
	 * Test for checking templated objects that are linked to a discovered host and for checking their unlinkage.
	 * This test is implemented only for Standalone scenario.
	 */
	public function testFormHostFromStandalone_DiscoveredHostLinkedTemplates() {
		$filtered_results = [
			[
				'type' => 'items',
				'form' => 'items',
				'objects' => [
					'before_unlink' => [
						'Test of discovered host 1 template for unlink: Template1 item1',
						'Test of discovered host 1 template for unlink: Template1 item2',
						'Test of discovered host 2 template for clear: Template2 item1',
						'Test of discovered host 2 template for clear: Template2 item2',
						'Test of discovered host Template: Template item',
						'Test of discovered host Template: Template item with tag'
					],
					'after_unlink' =>  [
						// This template was unlinked but not cleared.
						'Template1 item1',
						'Template1 item2',
						// This template was not unlinked.
						'Test of discovered host Template: Template item',
						'Test of discovered host Template: Template item with tag'
					]
				]
			],
			[
				'type' => 'triggers',
				'form' => 'triggersForm',
				'objects' => [
					'before_unlink' => [
						'Test of discovered host 1 template for unlink: Template1 trigger',
						'Test of discovered host 2 template for clear: Template2 trigger',
						'Test of discovered host Template: Template trigger'
					],
					'after_unlink' =>  [
						// This template was unlinked but not cleared.
						'Template1 trigger',
						// This template was not unlinked.
						'Test of discovered host Template: Template trigger'
					]
				]
			],
			[
				'type' => 'graphs',
				'form' => 'graphForm',
				'objects' => [
					'before_unlink' => [
						'Test of discovered host 1 template for unlink: Template1 graph',
						'Test of discovered host 2 template for clear: Template2 graph',
						'Test of discovered host Template: Template graph'
					],
					'after_unlink' =>  [
						// This template was unlinked but not cleared.
						'Template1 graph',
						// This template was not unlinked.
						'Test of discovered host Template: Template graph'
					]
				]
			],
			[
				'type' => 'host_discovery',
				'form' => 'discovery',
				'objects' => [
					'before_unlink' => [
						'Test of discovered host 1 template for unlink: Template1 discovery rule',
						'Test of discovered host 2 template for clear: Template2 discovery rule',
						'Test of discovered host Template: Template discovery rule'
					],
					'after_unlink' =>  [
						// This template was unlinked but not cleared.
						'Template1 discovery rule',
						// This template was not unlinked.
						'Test of discovered host Template: Template discovery rule'
					]
				]
			],
			[
				'type' => 'httpconf',
				'form' => 'scenarios',
				'objects' => [
					'before_unlink' => [
						'Test of discovered host Template: Template web scenario',
						'Test of discovered host 1 template for unlink: Template web scenario 1',
						'Test of discovered host 2 template for clear: Template web scenario 2'
					],
					'after_unlink' =>  [
						// This template was not unlinked.
						'Test of discovered host Template: Template web scenario',
						// This template was unlinked but not cleared.
						'Template web scenario 1'
					]
				]
			]
		];

		$discovered_hostid = CDataHelper::get('DiscoveredHosts.discovered_hostid');
		$this->page->login();

		foreach ($filtered_results as $result) {
			$this->page->open($result['type'].'.php?filter_set=1&filter_hostids%5B0%5D='.
					$discovered_hostid.'&context=host')->waitUntilReady();

			// Check objects on Discovered host before unlinking templates.
			$this->assertTableDataColumn($result['objects']['before_unlink'], 'Name', 'xpath://form[@name='.
					CXPathHelper::escapeQuotes($result['form']).']/table'
			);
		}

		// Open Discovered host form and unlink templates from it.
		$this->page->open($this->link.$discovered_hostid)->waitUntilReady();
		$form = $this->query('id:host-form')->waitUntilReady()->asForm()->one();
		$templates_table = $form->query('id:linked-templates')->asTable()->one()->waitUntilVisible();

		$template_actions = [
			'Test of discovered host 1 template for unlink' => 'Unlink',
			'Test of discovered host 2 template for clear' => 'Unlink and clear'
		];

		foreach ($template_actions as $name => $action) {
			$templates_table->findRow('Name', $name)->query('button', $action)->one()->waitUntilClickable()->click();
		}

		$form->submit();
		$this->page->waitUntilReady();

		// TODO: Update the message details after ZBX-21366 is merged.
		$message_details = [
			'Templates "Test of discovered host 2 template for clear" unlinked from hosts "Discovered host from prototype 1".',
			'Templates "Test of discovered host 1 template for unlink" unlinked from hosts "Discovered host from prototype 1".'
		];

		$this->assertMessage(TEST_GOOD, 'Host updated', $message_details);

		foreach ($filtered_results as $result) {
			// Open hosts objects and check objects on Discovered host after unlinking some templates.
			$this->page->open($result['type'].'.php?filter_set=1&filter_hostids%5B0%5D='.
					$discovered_hostid.'&context=host')->waitUntilReady();
			$this->assertTableDataColumn($result['objects']['after_unlink'], 'Name', 'xpath://form[@name='.
					CXPathHelper::escapeQuotes($result['form']).']/table'
			);
		}
	}
}