aurora-spock-spring-boot-starter

Starter for spock testing on Aurora Openshift

License

License

Categories

Categories

Spring Boot Container Microservices Spock Application Testing & Monitoring
GroupId

GroupId

no.skatteetaten.aurora.springboot
ArtifactId

ArtifactId

aurora-spock-spring-boot-starter
Last Version

Last Version

2.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

aurora-spock-spring-boot-starter
Starter for spock testing on Aurora Openshift
Project Organization

Project Organization

Pivotal Software, Inc.

Download aurora-spock-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/no.skatteetaten.aurora.springboot/aurora-spock-spring-boot-starter/ -->
<dependency>
    <groupId>no.skatteetaten.aurora.springboot</groupId>
    <artifactId>aurora-spock-spring-boot-starter</artifactId>
    <version>2.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/no.skatteetaten.aurora.springboot/aurora-spock-spring-boot-starter/
implementation 'no.skatteetaten.aurora.springboot:aurora-spock-spring-boot-starter:2.1.0'
// https://jarcasting.com/artifacts/no.skatteetaten.aurora.springboot/aurora-spock-spring-boot-starter/
implementation ("no.skatteetaten.aurora.springboot:aurora-spock-spring-boot-starter:2.1.0")
'no.skatteetaten.aurora.springboot:aurora-spock-spring-boot-starter:jar:2.1.0'
<dependency org="no.skatteetaten.aurora.springboot" name="aurora-spock-spring-boot-starter" rev="2.1.0">
  <artifact name="aurora-spock-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='no.skatteetaten.aurora.springboot', module='aurora-spock-spring-boot-starter', version='2.1.0')
)
libraryDependencies += "no.skatteetaten.aurora.springboot" % "aurora-spock-spring-boot-starter" % "2.1.0"
[no.skatteetaten.aurora.springboot/aurora-spock-spring-boot-starter "2.1.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.springframework.restdocs : spring-restdocs-mockmvc jar 1.1.3.RELEASE
org.spockframework : spock-core jar 1.0-groovy-2.4
org.spockframework : spock-spring jar 1.0-groovy-2.4
org.codehaus.groovy : groovy-all jar 2.4.12
cglib : cglib-nodep jar 3.1
org.objenesis : objenesis jar 2.1
org.springframework.boot : spring-boot-starter-test jar 1.5.6.RELEASE

Project Modules

There are no modules declared in this project.

Aurora Spring Boot Starter

A starter for including common configuration in Spring Boot for running an application on Aurora OpenShift. The starter is part of the Aurora Reference Architecture and an example can be found at in the repository for the reference application.

The starter will add some of the standard Spring Boot starters; Spring Boot Actuator, Spring HATEOAS, Spring Boot Developer Tools and Micrometer Prometheus in addition to pulling in the proprietary aurora-header-mdc-filter. Please reference the documentation for these individual components for details.

In addition to adding the mentioned dependencies, the starter also provides a couple of utilities on its own, descripted next.

How to use

Include the starter as a dependency

<dependency>
  <groupId>no.skatteetaten.aurora.springboot</groupId>
  <artifactId>aurora-spring-boot-starter</artifactId>
  <version>${aurora.starters.version}</version>
</dependency>

Features

Register the Aurora Header MDC Filter

The starter will register the Aurora Header MDC Filter. The registration can be disabled with the property

aurora.starter.headerfilter.enabled = false

Create property sources for Aurora config files

During startup a PropertySource for the configuration in the Aurora Secret properties file (auroraConfig[secret]) and the Aurora Env properties file (auroraConfig[env]) will be created. These properties files are automatically mounted when deploying on OpenShift based on your AuroraConfig. It will also create a property source from the environment variables set by by the platform during deploy.

Graceful Shutdown Handler for Tomcat

The starter will add a graceful shutdown handler for Tomcat (without it Tomcat may terminate ongoing requests on SIGTERM)

The Aurora Management Interface

The starter will help you implement the requirements for the Aurora Management Interface by setting some common configuration values. For more information see Management interface og helseovervåkning.

Note that the management.port will be set to the value of the MANAGEMENT_HTTP_PORT environment variable provided by the platform. The default is to put all actuator endpoints on a different port than the main application/api endpoints.

info.serviceLinks.metrics={metricsHostname}/dashboard/db/openshift-project-spring-actuator-view?var-ds=openshift-{cluster}-ose&var-namespace={namespace}&var-app={name}

info.podLinks.metrics={metricsHostname}/dashboard/db/openshift-project-spring-actuator-view-instance?var-ds=openshift-{cluster}-ose&var-namespace={namespace}&var-app={name}&var-instance={podName}

management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, OBSERVE, UP
management.port=${MANAGEMENT_HTTP_PORT:8081}

Metrics

The starter will automatically add Micrometer (the upcoming spring boot default) as the default metrics registry and also add micrometer-registry-prometheus for providing the /prometheus actuator endpoint that will be (optionally) read by Prometheus automatically for all applications deployed on Aurora OpenShift.

Additionally a number of Micrometer metrics collectors will be automatically registered;

  • JvmThreadMetrics

  • ProcessorMetrics

  • JvmGcMetrics

  • JvmMemoryMetrics

  • LogbackMetrics

  • UptimeMetrics

  • FileDescriptorMetrics

  • DataSourceMetrics

  • RestTemplateMetrics

  • TomcatMetrics

To get an overview of how Micrometer works we encourage you to read the Micrometer docs: https://micrometer.io/docs. Relevant sections are http://micrometer.io/docs/concepts, http://micrometer.io/docs/registry/prometheus and http://micrometer.io/docs/ref/spring/1.5

Outgoing and incomming HTTP metrics have by default percentiles turned on and has buckets between 100ms and 5s.

management.metrics.distribution.percentiles-histogram.http=true

There are default min/max buckets set to 100ms to 5secounds for http and operations metrics

If you would like to change these use the following bean in your code

 @Bean
    MeterFilter minExpectedHttp() {
        return MeterFilter.minExpected("http", Duration.ofMillis(200));
    }

Auto registration of DataSource

If a database is provided on OpenShift there will automatically be a DataSource created from the properties files provided by the platform. If you want to override to use a specific database you can set the aurora.db property if you have more than one db in your application.

Connection count metrics will also be collected from the DataSource.

Configuration of the Actuator Endpoints

Most actuator endpoints will be disabled by default;

  • auditevents

  • heapdump

  • metrics

  • logfile

  • autoconfig

  • configprops

  • mappings

  • beans

  • dump

  • jolokia

Actuator will also be configured to use the port specified by the MANAGEMENT_HTTP_PORT environment variable. The value of this variable will be set by the Aurora platform when deploying. Security on the actuator endpoints and the metrics filter will be disabled.

Setting of Spring Boot Properties

The spring boot application name will be set from the environment variables APP_NAME and POD_NAMESPACE provided by the platform when deploying to Aurora OpenShift.

The flyway.out-of-order mode will also be activated to allow migrations to be developed in different feature branches at the same time. See the Flyway documentation for more information.

The AURORA_VERSION and IMAGE_BUILD_TIME variables are included in spring boots actuator output since we use them in a central management overview dashboard.

spring.application.name=${APP_NAME:my}-${POD_NAMESPACE:app}
spring.jackson.date-format=com.fasterxml.jackson.databind.util.ISO8601DateFormat
flyway.out-of-order=true
info.auroraVersion= ${AURORA_VERSION:local-dev}
info.imageBuildTime=${IMAGE_BUILD_TIME:}
no.skatteetaten.aurora.springboot

Skatteetaten

Versions

Version
2.1.0
2.0.3
2.0.2
2.0.1
1.1.0