Skip to content

Commit

Permalink
test: add test for configuration only add-on
Browse files Browse the repository at this point in the history
  • Loading branch information
artemrys authored and Artem Rys committed Aug 9, 2021
1 parent a5c3c3e commit e9e75c0
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/data/package_no_global_config/package/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Just a readme
51 changes: 51 additions & 0 deletions tests/data/package_no_global_config/package/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"schemaVersion": "2.0.0",
"info": {
"title": "Splunk Add-on for UCC Example",
"id": {
"group": null,
"name": "Splunk_TA_UCCExample",
"version": "7.0.1"
},
"author": [
{
"name": "Splunk",
"email": null,
"company": null
}
],
"releaseDate": null,
"description": "Splunk Add-on for UCC Example",
"classification": {
"intendedAudience": null,
"categories": [],
"developmentStatus": null
},
"commonInformationModels": null,
"license": {
"name": null,
"text": "LICENSES/Apache-2.0.txt",
"uri": null
},
"privacyPolicy": {
"name": null,
"text": null,
"uri": null
},
"releaseNotes": {
"name": null,
"text": "./README.txt",
"uri": null
}
},
"dependencies": null,
"tasks": null,
"inputGroups": null,
"incompatibleApps": null,
"platformRequirements": null,
"supportedDeployments": [
"_standalone",
"_distributed"
],
"targetWorkloads": null
}
23 changes: 23 additions & 0 deletions tests/data/package_no_global_config/package/default/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
######################################################
#
# ${package.name}
#
# ${copyright}
#
######################################################

[install]
build = 0

[launcher]
author = Splunk Inc.
version = 0.1.0
description = Splunk_TA_UCCExample

[ui]
is_visible = true
label = Splunk_TA_UCCExample
docs_section_override=AddOns:released

[package]
id = Splunk_TA_UCCExample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[new_eventtype]
search = sourcetype=new_sourcetype
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# props.conf

[new_sourcetype]
EVAL-new_field = if(field2 = "hello", "world")
2 changes: 2 additions & 0 deletions tests/data/package_no_global_config/package/default/tags.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[eventtype=new_eventtype]
new_tag = enabled
38 changes: 38 additions & 0 deletions tests/data/test_ucc_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,44 @@ def test_ucc_generate_with_configuration(self):
msg=f"Expected file {expected_file_path} is different from {actual_file_path}",
)

def test_ucc_generate_with_configuration_files_only(self):
with tempfile.TemporaryDirectory() as temp_dir:
package_folder = path.join(
path.dirname(path.realpath(__file__)),
"package_no_global_config",
"package",
)
ucc.generate(source=package_folder, outputdir=temp_dir)

expected_folder = path.join(
path.dirname(__file__),
"..",
"expected_output_no_global_config",
"Splunk_TA_UCCExample",
)
actual_folder = path.join(temp_dir, "Splunk_TA_UCCExample")

# app.manifest and appserver/static/js/build/globalConfig.json
# should be included too, but they may introduce flaky tests as
# their content depends on the git commit.
# Expected add-on package folder does not have "lib" in it.
files_to_be_equal = [
("README.txt",),
("default", "eventtypes.conf"),
("default", "props.conf"),
("default", "tags.conf"),
]
for f in files_to_be_equal:
expected_file_path = path.join(expected_folder, *f)
actual_file_path = path.join(actual_folder, *f)
self.assertTrue(
assert_identical_files(
expected_file_path,
actual_file_path,
),
msg=f"Expected file {expected_file_path} is different from {actual_file_path}",
)


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Just a readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.0.0
1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"dependencies": null,
"incompatibleApps": null,
"info": {
"author": [
{
"company": null,
"email": null,
"name": "Splunk"
}
],
"classification": {
"categories": [],
"developmentStatus": null,
"intendedAudience": null
},
"commonInformationModels": null,
"description": "Splunk Add-on for UCC Example",
"id": {
"group": null,
"name": "Splunk_TA_UCCExample",
"version": "1.0.0"
},
"license": {
"name": null,
"text": "LICENSES/Apache-2.0.txt",
"uri": null
},
"privacyPolicy": {
"name": null,
"text": null,
"uri": null
},
"releaseDate": null,
"releaseNotes": {
"name": null,
"text": "./README.txt",
"uri": null
},
"title": "Splunk Add-on for UCC Example"
},
"inputGroups": null,
"platformRequirements": null,
"schemaVersion": "2.0.0",
"supportedDeployments": [
"_standalone",
"_distributed"
],
"targetWorkloads": null,
"tasks": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
######################################################
#
# ${package.name}
#
# ${copyright}
#
######################################################

[install]
build = 1628341075

[launcher]
author = Splunk Inc.
version = 1.0.0
description = Splunk Add-on for UCC Example

[ui]
is_visible = true
label = Splunk Add-on for UCC Example
docs_section_override = AddOns:released

[package]
id = Splunk_TA_UCCExample

[id]
version = 1.0.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[new_eventtype]
search = sourcetype=new_sourcetype
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# props.conf

[new_sourcetype]
EVAL-new_field = if(field2 = "hello", "world")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[eventtype=new_eventtype]
new_tag = enabled

0 comments on commit e9e75c0

Please sign in to comment.