Skip to content

Commit

Permalink
Add test case names to CI spec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog committed Sep 30, 2024
1 parent 70ac474 commit d0c45a8
Show file tree
Hide file tree
Showing 13 changed files with 555 additions and 314 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,52 @@ class CISpecExtractor {

static extract(String ciProviderName) {
if ("unknown" == ciProviderName) {
return Arrays.asList(new CISpec(Collections.EMPTY_MAP, Collections.EMPTY_MAP))
return Arrays.asList(new CISpec(ciProviderName, 0, Collections.EMPTY_MAP, Collections.EMPTY_MAP))
}

List<List<Map<String, String>>> spec = JSON_SLURPER.parse(CISpecExtractor.getClassLoader().getResourceAsStream(String.format("ci/%s.json", ciProviderName)))
List<List<Map<String, String>>> specs = JSON_SLURPER.parse(CISpecExtractor.getClassLoader().getResourceAsStream(String.format("ci/%s.json", ciProviderName)))

def ciSpecs = new ArrayList<CISpec>()
spec.each {
ciSpecs.add(new CISpec(it.get(0), it.get(1)))
for (i in 0..<specs.size()) {
def spec = specs.get(i)
ciSpecs.add(new CISpec(ciProviderName, i, spec.get(0), spec.get(1)))
}

return ciSpecs
}

static class CISpec {

private final String providerName
private final int idx
private final String testCaseName
private final Map<String, String> env
private final Map<String, String> tags

CISpec(env, tags) {
CISpec(providerName, idx, env, tags) {
this.providerName = providerName
this.idx = idx
if (env['DD_TEST_CASE_NAME']) {
this.testCaseName = ' - ' + env['DD_TEST_CASE_NAME']
} else {
this.testCaseName = ''
}
this.env = env
this.tags = tags
}

String getProviderName() {
return providerName
}

int getIdx() {
return idx
}

String getTestCaseName() {
return testCaseName
}

Collection<String> getTagMismatches(Map<String, String> ciTags) {
Collection<String> mismatches = new ArrayList<>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class CITagsProviderTest extends Specification {
environmentVariables.clear(System.getenv().keySet() as String[])
}

def "test ci provider info is set properly"() {
def "test ci provider info is set properly: #ciSpec.providerName #ciSpec.idx #ciSpec.testCaseName"() {
setup:
ciSpec.env.each {
environmentVariables.set(it.key, it.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,64 @@
"git.tag": "0.0.2"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "https://dev.azure.com/fabrikamfiber/repo",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
"DD_TEST_CASE_NAME": "http-repository-url-no-git-suffix",
"SYSTEM_JOBID": "azure-pipelines-job-id",
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
"TF_BUILD": "True"
},
{
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
"ci.pipeline.id": "azure-pipelines-build-id",
"ci.pipeline.name": "azure-pipelines-name",
"ci.pipeline.number": "azure-pipelines-build-id",
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
"ci.provider.name": "azurepipelines",
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "https://dev.azure.com/fabrikamfiber/repo"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://host.xz:54321/path/to/repo/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
"DD_TEST_CASE_NAME": "ssh-repository-url-no-git-suffix",
"SYSTEM_JOBID": "azure-pipelines-job-id",
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
"TF_BUILD": "True"
},
{
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
"ci.pipeline.id": "azure-pipelines-build-id",
"ci.pipeline.name": "azure-pipelines-name",
"ci.pipeline.number": "azure-pipelines-build-id",
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
"ci.provider.name": "azurepipelines",
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://host.xz:54321/path/to/repo/"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
Expand Down Expand Up @@ -794,7 +852,7 @@
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://[email protected]:port/path/to/repo.git/",
"BUILD_REPOSITORY_URI": "ssh://[email protected]:54321/path/to/repo.git/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
Expand All @@ -815,14 +873,14 @@
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:port/path/to/repo.git/",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:54321/path/to/repo.git/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
Expand All @@ -843,14 +901,14 @@
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:port/path/to/repo.git/",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:54321/path/to/repo.git/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
Expand All @@ -871,7 +929,7 @@
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://1.1.1.1:port/path/to/repo.git/"
"git.repository_url": "ssh://1.1.1.1:54321/path/to/repo.git/"
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,46 @@
"git.tag": "0.0.2"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "https://bitbucket.org/DataDog/dogweb",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo",
"DD_TEST_CASE_NAME": "http-repository-url-no-git-suffix"
},
{
"ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.pipeline.id": "bitbucket-uuid",
"ci.pipeline.name": "bitbucket-repo",
"ci.pipeline.number": "bitbucket-build-num",
"ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.provider.name": "bitbucket",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "https://bitbucket.org/DataDog/dogweb"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://host.xz:54321/path/to/repo/",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo",
"DD_TEST_CASE_NAME": "ssh-repository-url-no-git-suffix"
},
{
"ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.pipeline.id": "bitbucket-uuid",
"ci.pipeline.name": "bitbucket-repo",
"ci.pipeline.number": "bitbucket-build-num",
"ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.provider.name": "bitbucket",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:54321/path/to/repo/"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
Expand Down Expand Up @@ -518,7 +558,7 @@
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://[email protected]:port/path/to/repo.git/",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://[email protected]:54321/path/to/repo.git/",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo"
},
Expand All @@ -530,14 +570,14 @@
"ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.provider.name": "bitbucket",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://user:[email protected]:port/path/to/repo.git/",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://user:[email protected]:54321/path/to/repo.git/",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo"
},
Expand All @@ -549,7 +589,7 @@
"ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.provider.name": "bitbucket",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,50 @@
"git.tag": "0.0.2"
}
],
[
{
"BITRISE_BUILD_NUMBER": "bitrise-pipeline-number",
"BITRISE_BUILD_SLUG": "bitrise-pipeline-id",
"BITRISE_BUILD_URL": "https://bitrise-build-url.com//",
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"DD_TEST_CASE_NAME": "http-repository-url-no-git-suffix",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "https://github.com/DataDog/dogweb"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
"ci.pipeline.name": "bitrise-pipeline-name",
"ci.pipeline.number": "bitrise-pipeline-number",
"ci.pipeline.url": "https://bitrise-build-url.com//",
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "https://github.com/DataDog/dogweb"
}
],
[
{
"BITRISE_BUILD_NUMBER": "bitrise-pipeline-number",
"BITRISE_BUILD_SLUG": "bitrise-pipeline-id",
"BITRISE_BUILD_URL": "https://bitrise-build-url.com//",
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"DD_TEST_CASE_NAME": "ssh-repository-url-no-git-suffix",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "ssh://host.xz:54321/path/to/repo/"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
"ci.pipeline.name": "bitrise-pipeline-name",
"ci.pipeline.number": "bitrise-pipeline-number",
"ci.pipeline.url": "https://bitrise-build-url.com//",
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:54321/path/to/repo/"
}
],
[
{
"BITRISE_BUILD_NUMBER": "bitrise-pipeline-number",
Expand Down Expand Up @@ -613,7 +657,7 @@
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "ssh://[email protected]:port/path/to/repo.git/"
"GIT_REPOSITORY_URL": "ssh://[email protected]:54321/path/to/repo.git/"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
Expand All @@ -623,7 +667,7 @@
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
Expand All @@ -634,7 +678,7 @@
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "ssh://user:[email protected]:port/path/to/repo.git/"
"GIT_REPOSITORY_URL": "ssh://user:[email protected]:54321/path/to/repo.git/"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
Expand All @@ -644,7 +688,7 @@
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
]
]
Loading

0 comments on commit d0c45a8

Please sign in to comment.