Skip to content

Commit

Permalink
Merge branch 'master' into choropleth_wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 24, 2020
2 parents e85fb90 + a104e5a commit c99ccb2
Show file tree
Hide file tree
Showing 717 changed files with 13,730 additions and 6,816 deletions.
1 change: 1 addition & 0 deletions .ci/pipeline-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
implementation 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.19@jar'
testImplementation 'com.lesfurets:jenkins-pipeline-unit:1.4'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.+'
testImplementation 'org.assertj:assertj-core:3.15+' // Temporary https://github.com/jenkinsci/JenkinsPipelineUnit/issues/209
}

Expand Down
7 changes: 5 additions & 2 deletions .ci/pipeline-library/src/test/KibanaBasePipelineTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class KibanaBasePipelineTest extends BasePipelineTest {
env.BUILD_DISPLAY_NAME = "#${env.BUILD_ID}"

env.JENKINS_URL = 'http://jenkins.localhost:8080'
env.BUILD_URL = "${env.JENKINS_URL}/job/elastic+kibana+${env.BRANCH_NAME}/${env.BUILD_ID}/"
env.BUILD_URL = "${env.JENKINS_URL}/job/elastic+kibana+${env.BRANCH_NAME}/${env.BUILD_ID}/".toString()

env.JOB_BASE_NAME = "elastic / kibana # ${env.BRANCH_NAME}"
env.JOB_BASE_NAME = "elastic / kibana # ${env.BRANCH_NAME}".toString()
env.JOB_NAME = env.JOB_BASE_NAME

env.WORKSPACE = 'WS'
Expand All @@ -31,6 +31,9 @@ class KibanaBasePipelineTest extends BasePipelineTest {
getBuildStatus: { 'SUCCESS' },
printStacktrace: { ex -> print ex },
],
githubPr: [
isPr: { false },
],
jenkinsApi: [ getFailedSteps: { [] } ],
testUtils: [ getFailures: { [] } ],
])
Expand Down
48 changes: 48 additions & 0 deletions .ci/pipeline-library/src/test/buildState.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import org.junit.*
import static groovy.test.GroovyAssert.*

class BuildStateTest extends KibanaBasePipelineTest {
def buildState

@Before
void setUp() {
super.setUp()

buildState = loadScript("vars/buildState.groovy")
}

@Test
void 'get() returns existing data'() {
buildState.add('test', 1)
def actual = buildState.get('test')
assertEquals(1, actual)
}

@Test
void 'get() returns null for missing data'() {
def actual = buildState.get('missing_key')
assertEquals(null, actual)
}

@Test
void 'add() does not overwrite existing keys'() {
assertTrue(buildState.add('test', 1))
assertFalse(buildState.add('test', 2))

def actual = buildState.get('test')

assertEquals(1, actual)
}

@Test
void 'set() overwrites existing keys'() {
assertFalse(buildState.has('test'))
buildState.set('test', 1)
assertTrue(buildState.has('test'))
buildState.set('test', 2)

def actual = buildState.get('test')

assertEquals(2, actual)
}
}
85 changes: 85 additions & 0 deletions .ci/pipeline-library/src/test/githubCommitStatus.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import org.junit.*
import static org.mockito.Mockito.*;

class GithubCommitStatusTest extends KibanaBasePipelineTest {
def githubCommitStatus
def githubApiMock
def buildStateMock

def EXPECTED_STATUS_URL = 'repos/elastic/kibana/statuses/COMMIT_HASH'
def EXPECTED_CONTEXT = 'kibana-ci'
def EXPECTED_BUILD_URL = 'http://jenkins.localhost:8080/job/elastic+kibana+master/1/'

interface BuildState {
Object get(String key)
}

interface GithubApi {
Object post(String url, Map data)
}

@Before
void setUp() {
super.setUp()

buildStateMock = mock(BuildState)
githubApiMock = mock(GithubApi)

when(buildStateMock.get('checkoutInfo')).thenReturn([ commit: 'COMMIT_HASH', ])
when(githubApiMock.post(any(), any())).thenReturn(null)

props([
buildState: buildStateMock,
githubApi: githubApiMock,
])

githubCommitStatus = loadScript("vars/githubCommitStatus.groovy")
}

void verifyStatusCreate(String state, String description) {
verify(githubApiMock).post(
EXPECTED_STATUS_URL,
[
'state': state,
'description': description,
'context': EXPECTED_CONTEXT,
'target_url': EXPECTED_BUILD_URL,
]
)
}

@Test
void 'onStart() should create a pending status'() {
githubCommitStatus.onStart()
verifyStatusCreate('pending', 'Build started.')
}

@Test
void 'onFinish() should create a success status'() {
githubCommitStatus.onFinish()
verifyStatusCreate('success', 'Build completed successfully.')
}

@Test
void 'onFinish() should create an error status for failed builds'() {
mockFailureBuild()
githubCommitStatus.onFinish()
verifyStatusCreate('error', 'Build failed.')
}

@Test
void 'onStart() should exit early for PRs'() {
prop('githubPr', [ isPr: { true } ])

githubCommitStatus.onStart()
verifyZeroInteractions(githubApiMock)
}

@Test
void 'onFinish() should exit early for PRs'() {
prop('githubPr', [ isPr: { true } ])

githubCommitStatus.onFinish()
verifyZeroInteractions(githubApiMock)
}
}
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
library 'kibana-pipeline-library'
kibanaLibrary.load()

kibanaPipeline(timeoutMinutes: 155, checkPrChanges: true) {
kibanaPipeline(timeoutMinutes: 155, checkPrChanges: true, setCommitStatus: true) {
githubPr.withDefaultPrComments {
ciStats.trackBuild {
catchError {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export interface CoreSetup<TPluginsStart extends object = object, TStart = unkno
| --- | --- | --- |
| [application](./kibana-plugin-core-public.coresetup.application.md) | <code>ApplicationSetup</code> | [ApplicationSetup](./kibana-plugin-core-public.applicationsetup.md) |
| [context](./kibana-plugin-core-public.coresetup.context.md) | <code>ContextSetup</code> | [ContextSetup](./kibana-plugin-core-public.contextsetup.md) |
| [docLinks](./kibana-plugin-core-public.coresetup.doclinks.md) | <code>DocLinksSetup</code> | [DocLinksSetup](./kibana-plugin-core-public.doclinkssetup.md) |
| [fatalErrors](./kibana-plugin-core-public.coresetup.fatalerrors.md) | <code>FatalErrorsSetup</code> | [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) |
| [getStartServices](./kibana-plugin-core-public.coresetup.getstartservices.md) | <code>StartServicesAccessor&lt;TPluginsStart, TStart&gt;</code> | [StartServicesAccessor](./kibana-plugin-core-public.startservicesaccessor.md) |
| [http](./kibana-plugin-core-public.coresetup.http.md) | <code>HttpSetup</code> | [HttpSetup](./kibana-plugin-core-public.httpsetup.md) |
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) &gt; [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md)

## DocLinksStart.DOC\_LINK\_VERSION property

<b>Signature:</b>

```typescript
readonly DOC_LINK_VERSION: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) &gt; [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md)

## DocLinksStart.ELASTIC\_WEBSITE\_URL property

<b>Signature:</b>

```typescript
readonly ELASTIC_WEBSITE_URL: string;
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [DocLinksSetup](./kibana-plugin-core-public.doclinkssetup.md) &gt; [links](./kibana-plugin-core-public.doclinkssetup.links.md)
[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) &gt; [links](./kibana-plugin-core-public.doclinksstart.links.md)

## DocLinksSetup.links property
## DocLinksStart.links property

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md)

## DocLinksStart type
## DocLinksStart interface


<b>Signature:</b>

```typescript
export declare type DocLinksStart = DocLinksSetup;
export interface DocLinksStart
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md) | <code>string</code> | |
| [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md) | <code>string</code> | |
| [links](./kibana-plugin-core-public.doclinksstart.links.md) | <code>{</code><br/><code> readonly dashboard: {</code><br/><code> readonly drilldowns: string;</code><br/><code> };</code><br/><code> readonly filebeat: {</code><br/><code> readonly base: string;</code><br/><code> readonly installation: string;</code><br/><code> readonly configuration: string;</code><br/><code> readonly elasticsearchOutput: string;</code><br/><code> readonly startup: string;</code><br/><code> readonly exportedFields: string;</code><br/><code> };</code><br/><code> readonly auditbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly metricbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly heartbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly logstash: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly functionbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly winlogbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly aggs: {</code><br/><code> readonly date_histogram: string;</code><br/><code> readonly date_range: string;</code><br/><code> readonly filter: string;</code><br/><code> readonly filters: string;</code><br/><code> readonly geohash_grid: string;</code><br/><code> readonly histogram: string;</code><br/><code> readonly ip_range: string;</code><br/><code> readonly range: string;</code><br/><code> readonly significant_terms: string;</code><br/><code> readonly terms: string;</code><br/><code> readonly avg: string;</code><br/><code> readonly avg_bucket: string;</code><br/><code> readonly max_bucket: string;</code><br/><code> readonly min_bucket: string;</code><br/><code> readonly sum_bucket: string;</code><br/><code> readonly cardinality: string;</code><br/><code> readonly count: string;</code><br/><code> readonly cumulative_sum: string;</code><br/><code> readonly derivative: string;</code><br/><code> readonly geo_bounds: string;</code><br/><code> readonly geo_centroid: string;</code><br/><code> readonly max: string;</code><br/><code> readonly median: string;</code><br/><code> readonly min: string;</code><br/><code> readonly moving_avg: string;</code><br/><code> readonly percentile_ranks: string;</code><br/><code> readonly serial_diff: string;</code><br/><code> readonly std_dev: string;</code><br/><code> readonly sum: string;</code><br/><code> readonly top_hits: string;</code><br/><code> };</code><br/><code> readonly scriptedFields: {</code><br/><code> readonly scriptFields: string;</code><br/><code> readonly scriptAggs: string;</code><br/><code> readonly painless: string;</code><br/><code> readonly painlessApi: string;</code><br/><code> readonly painlessSyntax: string;</code><br/><code> readonly luceneExpressions: string;</code><br/><code> };</code><br/><code> readonly indexPatterns: {</code><br/><code> readonly loadingData: string;</code><br/><code> readonly introduction: string;</code><br/><code> };</code><br/><code> readonly kibana: string;</code><br/><code> readonly siem: {</code><br/><code> readonly guide: string;</code><br/><code> readonly gettingStarted: string;</code><br/><code> };</code><br/><code> readonly query: {</code><br/><code> readonly luceneQuerySyntax: string;</code><br/><code> readonly queryDsl: string;</code><br/><code> readonly kueryQuerySyntax: string;</code><br/><code> };</code><br/><code> readonly date: {</code><br/><code> readonly dateMath: string;</code><br/><code> };</code><br/><code> readonly management: Record&lt;string, string&gt;;</code><br/><code> }</code> | |

Loading

0 comments on commit c99ccb2

Please sign in to comment.