Skip to content

Commit bfeb9b1

Browse files
authored
CSPL-4386: Extract inline YAMLs to fixtures (#1801)
* Embed values * Embed values * Move fixtures * Fix copyrights
1 parent 1450ec4 commit bfeb9b1

36 files changed

Lines changed: 2228 additions & 381 deletions

pkg/splunk/client/enterprise_test.go

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2018-2026 Splunk Inc. All rights reserved.
2+
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
package client
17+
18+
import (
19+
"bytes"
20+
"encoding/json"
21+
"os"
22+
"path/filepath"
23+
"testing"
24+
)
25+
26+
func loadFixture(t *testing.T, filename string) string {
27+
t.Helper()
28+
path := filepath.Join("testdata", "fixtures", filename)
29+
data, err := os.ReadFile(path)
30+
if err != nil {
31+
t.Fatalf("Failed to load fixture %s: %v", filename, err)
32+
}
33+
34+
var compactJSON bytes.Buffer
35+
if err := json.Compact(&compactJSON, data); err != nil {
36+
t.Fatalf("Failed to compact JSON from fixture %s: %v", filename, err)
37+
}
38+
return compactJSON.String()
39+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"links": {},
3+
"origin": "https://localhost:8089/services/server/info",
4+
"updated": "2020-09-24T06:38:53+00:00",
5+
"generator": {
6+
"build": "a1a6394cc5ae",
7+
"version": "8.0.5"
8+
},
9+
"entry": [
10+
{
11+
"name": "server-info",
12+
"id": "https://localhost:8089/services/server/info/server-info",
13+
"updated": "1970-01-01T00:00:00+00:00",
14+
"links": {
15+
"alternate": "/services/server/info/server-info",
16+
"list": "/services/server/info/server-info"
17+
},
18+
"author": "system",
19+
"acl": {
20+
"app": "",
21+
"can_list": true,
22+
"can_write": true,
23+
"modifiable": false,
24+
"owner": "system",
25+
"perms": {
26+
"read": [
27+
"*"
28+
],
29+
"write": []
30+
},
31+
"removable": false,
32+
"sharing": "system"
33+
},
34+
"fields": {
35+
"required": [],
36+
"optional": [],
37+
"wildcard": []
38+
},
39+
"content": {
40+
"activeLicenseGroup": "Trial",
41+
"activeLicenseSubgroup": "Production",
42+
"build": "a1a6394cc5ae",
43+
"cluster_label": [
44+
"idxc_label"
45+
],
46+
"cpu_arch": "x86_64",
47+
"eai:acl": null,
48+
"fips_mode": false,
49+
"guid": "0F93F33C-4BDA-4A74-AD9F-3FCE26C6AFF0",
50+
"health_info": "green",
51+
"health_version": 1,
52+
"host": "splunk-default-monitoring-console-86bc9b7c8c-d96x2",
53+
"host_fqdn": "splunk-default-monitoring-console-86bc9b7c8c-d96x2",
54+
"host_resolved": "splunk-default-monitoring-console-86bc9b7c8c-d96x2",
55+
"isForwarding": true,
56+
"isFree": false,
57+
"isTrial": true,
58+
"kvStoreStatus": "ready",
59+
"licenseKeys": [
60+
"5C52DA5145AD67B8188604C49962D12F2C3B2CF1B82A6878E46F68CA2812807B"
61+
],
62+
"licenseSignature": "139bf73ec92c84121c79a9b8307a6724",
63+
"licenseState": "OK",
64+
"license_labels": [
65+
"Splunk Enterprise Splunk Analytics for Hadoop Download Trial"
66+
],
67+
"master_guid": "0F93F33C-4BDA-4A74-AD9F-3FCE26C6AFF0",
68+
"master_uri": "self",
69+
"max_users": 4294967295,
70+
"mode": "normal",
71+
"numberOfCores": 1,
72+
"numberOfVirtualCores": 2,
73+
"os_build": "#1 SMP Thu Sep 3 19:04:44 UTC 2020",
74+
"os_name": "Linux",
75+
"os_name_extended": "Linux",
76+
"os_version": "4.14.193-149.317.amzn2.x86_64",
77+
"physicalMemoryMB": 7764,
78+
"product_type": "enterprise",
79+
"rtsearch_enabled": true,
80+
"serverName": "splunk-default-monitoring-console-86bc9b7c8c-d96x2",
81+
"server_roles": [
82+
"license_master",
83+
"cluster_search_head",
84+
"search_head"
85+
],
86+
"startup_time": 1600928786,
87+
"staticAssetId": "CFE3D41EE2CCD1465E8C8453F83E4ECFFF540780B4490E84458DD4A3694CE4D1",
88+
"version": "8.0.5"
89+
}
90+
}
91+
],
92+
"paging": {
93+
"total": 1,
94+
"perPage": 30,
95+
"offset": 0
96+
},
97+
"messages": []
98+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"links": {},
3+
"origin": "https://localhost:8089/services/cluster/master/info",
4+
"updated": "2020-03-18T01:04:53+00:00",
5+
"generator": {
6+
"build": "a7f645ddaf91",
7+
"version": "8.0.2"
8+
},
9+
"entry": [],
10+
"paging": {
11+
"total": 1,
12+
"perPage": 30,
13+
"offset": 0
14+
},
15+
"messages": []
16+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"links": {
3+
"create": "/services/cluster/master/peers/_new"
4+
},
5+
"origin": "https://localhost:8089/services/cluster/master/peers",
6+
"updated": "2020-03-18T01:08:53+00:00",
7+
"generator": {
8+
"build": "a7f645ddaf91",
9+
"version": "8.0.2"
10+
},
11+
"entry": [
12+
{
13+
"name": "D39B1729-E2C5-4273-B9B2-534DA7C2F866",
14+
"id": "https://localhost:8089/services/cluster/master/peers/D39B1729-E2C5-4273-B9B2-534DA7C2F866",
15+
"updated": "1970-01-01T00:00:00+00:00",
16+
"links": {
17+
"alternate": "/services/cluster/master/peers/D39B1729-E2C5-4273-B9B2-534DA7C2F866",
18+
"list": "/services/cluster/master/peers/D39B1729-E2C5-4273-B9B2-534DA7C2F866",
19+
"edit": "/services/cluster/master/peers/D39B1729-E2C5-4273-B9B2-534DA7C2F866"
20+
},
21+
"author": "system",
22+
"acl": {
23+
"app": "",
24+
"can_list": true,
25+
"can_write": true,
26+
"modifiable": false,
27+
"owner": "system",
28+
"perms": {
29+
"read": [
30+
"admin",
31+
"splunk-system-role"
32+
],
33+
"write": [
34+
"admin",
35+
"splunk-system-role"
36+
]
37+
},
38+
"removable": false,
39+
"sharing": "system"
40+
},
41+
"content": {
42+
"active_bundle_id": "14310A4AABD23E85BBD4559C4A3B59F8",
43+
"apply_bundle_status": {
44+
"invalid_bundle": {
45+
"bundle_validation_errors": [],
46+
"invalid_bundle_id": ""
47+
},
48+
"reasons_for_restart": [],
49+
"restart_required_for_apply_bundle": false,
50+
"status": "None"
51+
},
52+
"base_generation_id": 26,
53+
"bucket_count": 73,
54+
"bucket_count_by_index": {
55+
"_audit": 24,
56+
"_internal": 45,
57+
"_telemetry": 4
58+
},
59+
"buckets_rf_by_origin_site": {
60+
"default": 73
61+
},
62+
"buckets_sf_by_origin_site": {
63+
"default": 73
64+
},
65+
"delayed_buckets_to_discard": [],
66+
"eai:acl": null,
67+
"fixup_set": [],
68+
"heartbeat_started": true,
69+
"host_port_pair": "10.36.0.6:8089",
70+
"indexing_disk_space": 210707374080,
71+
"is_searchable": true,
72+
"is_valid_bundle": true,
73+
"label": "splunk-s1-indexer-0",
74+
"last_dry_run_bundle": "",
75+
"last_heartbeat": 1584493732,
76+
"last_validated_bundle": "14310A4AABD23E85BBD4559C4A3B59F8",
77+
"latest_bundle_id": "14310A4AABD23E85BBD4559C4A3B59F8",
78+
"peer_registered_summaries": true,
79+
"pending_builds": [],
80+
"pending_job_count": 0,
81+
"primary_count": 73,
82+
"primary_count_remote": 0,
83+
"register_search_address": "10.36.0.6:8089",
84+
"replication_count": 0,
85+
"replication_port": 9887,
86+
"replication_use_ssl": false,
87+
"restart_required_for_applying_dry_run_bundle": false,
88+
"search_state_counter": {
89+
"PendingSearchable": 0,
90+
"Searchable": 73,
91+
"SearchablePendingMask": 0,
92+
"Unsearchable": 0
93+
},
94+
"site": "default",
95+
"splunk_version": "8.0.2",
96+
"status": "Up",
97+
"status_counter": {
98+
"Complete": 69,
99+
"NonStreamingTarget": 0,
100+
"StreamingSource": 4,
101+
"StreamingTarget": 0
102+
},
103+
"summary_replication_count": 0
104+
}
105+
}
106+
],
107+
"paging": {
108+
"total": 1,
109+
"perPage": 30,
110+
"offset": 0
111+
},
112+
"messages": []
113+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"links": {},
3+
"origin": "https://localhost:8089/services/cluster/slave/info",
4+
"updated": "2020-03-18T01:28:18+00:00",
5+
"generator": {
6+
"build": "a7f645ddaf91",
7+
"version": "8.0.2"
8+
},
9+
"entry": [
10+
{
11+
"name": "slave",
12+
"id": "https://localhost:8089/services/cluster/slave/info/slave",
13+
"updated": "1970-01-01T00:00:00+00:00",
14+
"links": {
15+
"alternate": "/services/cluster/slave/info/slave",
16+
"list": "/services/cluster/slave/info/slave"
17+
},
18+
"author": "system",
19+
"acl": {
20+
"app": "",
21+
"can_list": true,
22+
"can_write": true,
23+
"modifiable": false,
24+
"owner": "system",
25+
"perms": {
26+
"read": [
27+
"admin",
28+
"splunk-system-role"
29+
],
30+
"write": [
31+
"admin",
32+
"splunk-system-role"
33+
]
34+
},
35+
"removable": false,
36+
"sharing": "system"
37+
},
38+
"content": {
39+
"active_bundle": {
40+
"bundle_path": "/opt/splunk/var/run/splunk/cluster/remote-bundle/87c8c24e7fabc3ff9683c26652cb5890-1583870244.bundle",
41+
"checksum": "14310A4AABD23E85BBD4559C4A3B59F8",
42+
"timestamp": 1583870244
43+
},
44+
"base_generation_id": 26,
45+
"eai:acl": null,
46+
"is_registered": true,
47+
"last_dry_run_bundle": {
48+
"bundle_path": "",
49+
"checksum": "",
50+
"timestamp": 0
51+
},
52+
"last_heartbeat_attempt": 0,
53+
"latest_bundle": {
54+
"bundle_path": "/opt/splunk/var/run/splunk/cluster/remote-bundle/87c8c24e7fabc3ff9683c26652cb5890-1583870244.bundle",
55+
"checksum": "14310A4AABD23E85BBD4559C4A3B59F8",
56+
"timestamp": 1583870244
57+
},
58+
"maintenance_mode": false,
59+
"registered_summary_state": 3,
60+
"restart_state": "NoRestart",
61+
"site": "default",
62+
"status": "Up"
63+
}
64+
}
65+
],
66+
"paging": {
67+
"total": 1,
68+
"perPage": 30,
69+
"offset": 0
70+
},
71+
"messages": []
72+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"links": {},
3+
"origin": "https://localhost:8089/services/cluster/slave/info",
4+
"updated": "2020-03-18T01:28:18+00:00",
5+
"generator": {
6+
"build": "a7f645ddaf91",
7+
"version": "8.0.2"
8+
},
9+
"entry": [],
10+
"paging": {
11+
"total": 1,
12+
"perPage": 30,
13+
"offset": 0
14+
},
15+
"messages": []
16+
}

0 commit comments

Comments
 (0)