forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestRpmDashboardsDistValidation.groovy
108 lines (102 loc) · 6.27 KB
/
TestRpmDashboardsDistValidation.groovy
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
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test
class TestRpmDashboardsDistValidation extends BuildPipelineTest {
@Before
void setUp() {
def bundleManifest = "tests/jenkins/data/opensearch-dashboards-1.3.0-x64-rpm.yml"
def rpmDistribution = "$workspace/opensearch-dashboards-1.3.0-linux-x64.rpm"
this.registerLibTester(new RpmDashboardsDistValidationLibTester(rpmDistribution, bundleManifest))
super.setUp()
def out = "Name : opensearch-dashboards\n" +
"Version : 1.3.0\n" +
"Release : 1\n" +
"Architecture: x86_64\n" +
"Install Date: (not installed)\n" +
"Group : Application/Internet\n" +
"Size : 698202962\n" +
"License : Apache-2.0\n" +
"Signature : (none)\n" +
"Source RPM : opensearch-dashboards-1.3.0-1.src.rpm\n" +
"Build Date : Wed 30 Mar 2022 01:09:33 AM UTC\n" +
"Build Host : dummy_desktop\n" +
"Relocations : (not relocatable)\n" +
"URL : https://opensearch.org/\n" +
"Summary : Open source visualization dashboards for OpenSearch\n" +
"Description :\n" +
"OpenSearch Dashboards is the visualization tool for data in OpenSearch\n" +
"For more information, see: https://opensearch.org/"
helper.addShMock("rpm -qip $workspace/opensearch-dashboards-1.3.0-linux-x64.rpm") { script ->
return [stdout: out, exitValue: 0]
}
def sigOut = "/tmp/workspace/opensearch-dashboards-1.3.0-linux-x64.rpm:\n" + "Header V4 RSA/SHA512 Signature, key ID 9310d3fc: OK\n" +
"Header SHA256 digest: OK\n" + "Header SHA1 digest: OK\n" + "Payload SHA256 digest: OK\n" +
"V4 RSA/SHA512 Signature, key ID 9310d3fc: OK\n" + "MD5 digest: OK"
helper.addShMock("rpm -K -v $rpmDistribution") { script ->
return [stdout: sigOut, exitValue: 0]
}
def status_message = "opensearch-dashboards.service - \"OpenSearch Dashboards\"\n" +
" Loaded: loaded (/usr/lib/systemd/system/opensearch-dashboards.service; disabled; vendor preset: disabled)\n" +
" Active: active (running) since Mon 2022-04-04 21:38:58 UTC; 3 days ago\n" +
" Main PID: 30297 (node)\n" +
" CGroup: /system.slice/opensearch-dashboards.service\n" +
" └─30297 /usr/share/opensearch-dashboards/bin/../node/bin/node /usr/share/opensearch-dashboards/bin/../src/cli/dist\n" +
"\n" +
"Apr 04 21:41:10 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"log\",\"@timestamp\":\"2022-04-04T21:41:10Z\",\"tags\"...00\"}\n" +
"Apr 04 21:41:12 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"log\",\"@timestamp\":\"2022-04-04T21:41:12Z\",\"tags\"...00\"}\n" +
"Apr 04 21:41:15 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"log\",\"@timestamp\":\"2022-04-04T21:41:15Z\",\"tags\"...00\"}\n" +
"Apr 04 21:41:17 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"log\",\"@timestamp\":\"2022-04-04T21:41:17Z\",\"tags\"...00\"}\n" +
"Apr 04 21:41:20 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"log\",\"@timestamp\":\"2022-04-04T21:41:20Z\",\"tags\"...00\"}\n" +
"Apr 04 21:41:22 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"log\",\"@timestamp\":\"2022-04-04T21:41:22Z\",\"tags\"...00\"}\n" +
"Apr 04 21:41:28 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"response\",\"@timestamp\":\"2022-04-04T21:41:28Z\",\"tags...\n" +
"Apr 05 00:35:41 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"response\",\"@timestamp\":\"2022-04-05T00:35:41Z\",\"tags...\n" +
"Apr 05 18:45:25 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"response\",\"@timestamp\":\"2022-04-05T18:45:25Z\",\"tags...\n" +
"Apr 05 18:45:32 dummy_desktop opensearch-dashboards[30297]: {\"type\":\"response\",\"@timestamp\":\"2022-04-05T18:45:32Z\",\"tags...\n" +
"Hint: Some lines were ellipsized, use -l to show in full."
helper.addShMock("systemctl status opensearch-dashboards") { script ->
return [stdout: status_message, exitValue: 0]
}
def cluster_status = [
"name": "dummy_desktop",
"uuid": "c4677c7a-d76f-45eb-a124-7e30d2b10e4b",
"version": [
"number": "1.3.0",
"build_hash": "00e06934211e9819f99aabbf139885682f33e95e",
"build_number": 1,
"build_snapshot": false
],
"status": [
"overall": [
"since": "2022-04-07T21:54:39.960Z",
"state": "green",
"title": "Green",
"nickname": "Looking good",
"icon": "success",
"uiColor": "secondary"
]
]
]
helper.addShMock("curl -s \"http://localhost:5601/api/status\" -u admin:admin") { script ->
return [stdout: cluster_status.inspect(), exitValue: 0]
}
helper.registerAllowedMethod("readJSON", [Map.class], {c -> cluster_status})
def cluster_plugin = "[email protected]\n" +
"[email protected]\n" +
"[email protected]\n" +
helper.addShMock("/usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin list --allow-root") { script ->
return [stdout: cluster_plugin, exitValue: 0]
}
}
@Test
void testRpmDashboardsDistValidation() {
super.testPipeline("tests/jenkins/jobs/RpmDashboardsDistValidation_Jenkinsfile")
}
}