Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions src/test/groovy/GetGitMatchingGroupStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import static org.junit.Assert.assertTrue
class GetGitMatchingGroupStepTests extends ApmBasePipelineTest {
String scriptName = 'vars/getGitMatchingGroup.groovy'

def beatsPattern = '.*\\/module\\/([^\\/]+)\\/.*'
def beatsPattern = '^[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*'
def beatsXpackPattern = '^x-pack\\/[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*'

def beatsExcludePattern = '^(((?!\\/module\\/).)*$|.*\\.asciidoc|.*\\.png)'

Expand Down Expand Up @@ -277,11 +278,31 @@ x-pack/metricbeat/module/googlecloud/loadbalancing/_meta/fields.yml
x-pack/metricbeat/module/googlecloud/stackdriver/metrics_requester.go
x-pack/metricbeat/module/googlecloud/stackdriver/metricset.go'''.stripMargin().stripIndent()
helper.registerAllowedMethod('readFile', [String.class], { return realData })
def module = script.call(pattern: beatsPattern, exclude: beatsExcludePattern)
def module = script.call(pattern: beatsXpackPattern, exclude: beatsExcludePattern)
assertEquals('googlecloud', module)
assertJobStatusSuccess()
}

@Test
void test_unmatch_in_beats_pr18369() throws Exception {
def script = loadScript(scriptName)
def realData = '''metricbeat/docs/fields.asciidoc
metricbeat/docs/images/metricbeat-googlecloud-load-balancing-https-overview.png
metricbeat/docs/images/metricbeat-googlecloud-load-balancing-l3-overview.png
metricbeat/docs/modules/googlecloud.asciidoc
x-pack/metricbeat/module/googlecloud/_meta/docs.asciidoc
x-pack/metricbeat/module/googlecloud/_meta/kibana/7/dashboard/Metricbeat-googlecloud-load-balancing-https-overview.json
x-pack/metricbeat/module/googlecloud/_meta/kibana/7/dashboard/Metricbeat-googlecloud-loadbalancing-l3-overview.json
x-pack/metricbeat/module/googlecloud/fields.go
x-pack/metricbeat/module/googlecloud/loadbalancing/_meta/fields.yml
x-pack/metricbeat/module/googlecloud/stackdriver/metrics_requester.go
x-pack/metricbeat/module/googlecloud/stackdriver/metricset.go'''.stripMargin().stripIndent()
helper.registerAllowedMethod('readFile', [String.class], { return realData })
def module = script.call(pattern: beatsPattern, exclude: beatsExcludePattern)
assertEquals('', module)
assertJobStatusSuccess()
}

@Test
void test_match_in_beats_pr18609() throws Exception {
def script = loadScript(scriptName)
Expand Down Expand Up @@ -394,4 +415,37 @@ metricbeat/module/zookeeper/connection/connection.go'''.stripMargin().stripInden
assertEquals('', module)
assertJobStatusSuccess()
}

@Test
void test_match_in_beats_with_multiple_files_to_be_excluded_and_xpack() throws Exception {
def script = loadScript(scriptName)
def realData = '''CHANGELOG.next.asciidoc
libbeat/esleg/eslegclient/bulkapi.go
metricbeat/docs/modules/zookeeper.png
metricbeat/module/zookeeper/connection/_meta/docs.asciidoc
x-pack/auditbeat/module/system/system.go
x-pack/auditbeat/module/system/fields.go'''.stripMargin().stripIndent()
helper.registerAllowedMethod('readFile', [String.class], { return realData })
def module = script.call(pattern: beatsXpackPattern, exclude: beatsExcludePattern)
assertEquals('system', module)
assertJobStatusSuccess()
}

@Test
void test_unmatch_in_beats_with_multiple_files_to_be_excluded_and_xpack() throws Exception {
def script = loadScript(scriptName)
def realData = '''CHANGELOG.next.asciidoc
libbeat/esleg/eslegclient/bulkapi.go
metricbeat/docs/modules/zookeeper.png
metricbeat/module/zookeeper/connection/_meta/docs.asciidoc
metricbeat/module/logstash/connection/connection.go
metricbeat/module/zookeeper/connection/connection.go
x-pack/auditbeat/module/system/system.go
x-pack/auditbeat/module/system/fields.go'''.stripMargin().stripIndent()
helper.registerAllowedMethod('readFile', [String.class], { return realData })
def module = script.call(pattern: beatsPattern, exclude: beatsExcludePattern)
assertEquals('', module)
assertJobStatusSuccess()
}

}