How to get Spring Actuator build information locally? - spring-boot

When accessing my Spring Actuator /info endpoint I receive the following information:
{
"git": {
"branch": "8743b52063cd84097a65d1633f5c74f5",
"commit": {
"id": "b3j2924",
"time": "05.07.2021 # 10:00:00 UTC"
}
},
"build": {
"encoding": {
"source": "UTF-8"
},
"version": "1.0",
"artifact": "my-artifact",
"name": "my-app",
"time": 0451570333.122000000,
"group": "my.group"
}
}
My project does not maintain a META-INF/build-info.properties file.
I now wanted to write a unit-test for that exact output but get the following error:
java.lang.AssertionError:
Expecting actual:
"{"git":{"branch":"8743b52063cd84097a65d1633f5c74f5","commit":{"id":"b3j2924","time":"05.07.2021 # 10:00:00 UTC"}}}"
to contain:
"build"
The whole build block is missing in the output.
My questions are the following:
What needs to be done to access the build information during a local unit-test run without providing a META-INF/build-info.properties.
From where does Spring Actuator retrieve the actual build information when my project does not has a META-INF/build-info.properties file so it gives me the output from above?

The build-info.properties file is typically generated at build time by Spring Boot's Maven or Gradle plugins.

Related

Externalise - spring cloud config server multiple git repo configuration

I am trying to set up a spring-cloud-config-server for production.
I want to read multiple git repos so I am providing following configuration in application.yml of config-server placed in src/main/resources
spring:
application:
name: config-server
profiles:
active: git
cloud:
config:
server:
git:
uri: https://somedomain.com/project1/project1.git
username: project1user
password: project1password
repos:
project2:
pattern: project2/*
uri: https://somedomain.com/project2/project2.git
username: project2user
password: project2password
searchPaths:
- 'src/main/resources'
Now, I want to externalize this configuration of the config server.
I could provide main git repo (https://somedomain.com/project1/project1.git) properties by environment variables like following
spring.cloud.config.server.git.uri=https://somedomain.com/project1/project1.git
spring.cloud.config.server.git.username=project1user
spring.cloud.config.server.git.password=project1password
But what about other git repo properties. Passing complex map-like structure would be pretty tedious if passed via environment variables.
What is the best possible way to pass this configuration of other repos?
Passing some configuration as an environment variable has other disadvantages like those properties could not be refreshed on runtime.
Is there any possibility that additional repo configuration is picked by from some configuration file in main git (https://somedomain.com/project1/project1.git) itself?
The Spring Cloud Config Server provides a configuration with multiples repositories and they can be accessed by url like we do for one git repo. The config server will fetch each configuration by a pattern, so your label {application} in the path will be the key to find the correct repository. Like in mine I did:
spring:
cloud:
config:
server:
git:
uri: https://github.com/solivaf/config-properties-foo
Now we should add our additional repositories as you can see below:
spring:
cloud:
config:
server:
git:
uri: https://github.com/solivaf/config-properties-foo
repos:
appFoo:
pattern: app-foo
uri: https://github.com/solivaf/config-properties-bar
Restart the config server and perform the requests below.
$ curl localhost:8080/fooapp/prod
{
"name": "fooapp",
"profiles": [
"prod"
],
"label": null,
"version": "8686fb74f9af0aead98bd20d6e20e84a37028781",
"state": null,
"propertySources": [
{
"name": "https://github.com/solivaf/config-properties-foo/application-prod.yml",
"source": {
"bar.foo": "testProdPropertiesYml"
}
},
{
"name": "https://github.com/solivaf/config-properties-foo/application.yml",
"source": {
"bar.foo": "testPropertiesYml"
}
}
]
}
Now we can see the repository used to application fooapp, as we don’t have any pattern mapped to this application, the config server will use the default app, now if we specify the pattern app-foo which is mapped in our config-server property file we should get another repository as response.
$ curl localhost:8080/app-foo/prod
{
"name": "app-foo",
"profiles": [
"prod"
],
"label": null,
"version": "f34ced0565042be4cf87c937c1dab2703e0b8ed2",
"state": null,
"propertySources": [
{
"name": "https://github.com/solivaf/config-properties-bar/app-foo-prod.yml",
"source": {
"foo.bar": "testProdPropertiesYml"
}
},
{
"name": "https://github.com/solivaf/config-properties-bar/application-prod.yml",
"source": {
"foo.bar": "testProdPropertiesYml"
}
},
{
"name": "https://github.com/solivaf/config-properties-bar/application.yml",
"source": {
"foo.bar": "testPropertiesYml"
}
}
]
}
Now, we have the correct repository which was mapped in our property file and all files which represents our app-foo application. The response order represents the hierarchy of the file being the most priority the first file in the list.

How to fetch properties from config-server consisting of more than one repo

I wanted to fetch properties from two git repos. one is https://username#bitbucket.my.domain.com/share.git - which will have a property file contains some common key value pair and the other one is https://username#bitbucket.my.domain.com/service.git - it will have property files of all the micro services.
While I am deploying the service only one yml file (which is in https://username#bitbucket.my.domain.com/share.git repo) is read by the config server. What I am missing? How to read the property file from another repo i.e. https://username#bitbucket.my.domain.com/service.git too?
I wanted to deploy the service in PCF. So I configured the config-server in PCF with the following json.
{
"count": 1,
"git": {
"label": "feature",
"uri": "https://username#bitbucket.my.domain.com/share.git",
"username": "username",
"password": "password",
"repos": {
"configserver": {
"password": "password",
"label": "feature",
"uri": "https://username#bitbucket.my.domain.com/service.git"
"username": "username"
}
}
}
}
Name of my service is LogDemo and spring profile is active. I have created two yml files and placed in the corresponding repo. (I have given same name two both the files like LogDemo-active.yml). While I am deploying the service only one yml file (which is in https://username#bitbucket.my.domain.com/share.git repo) is read by the config server. /env is giving me the following:
{
"profiles": [
"active",
"cloud"
],
"server.ports": {
"local.server.port": 8080
},
"configService:configClient": {
"config.client.version": "234e59d4a9f80f035f00fdf07e6f9f16e5560a55"
},
"configService:https://username#bitbucket.my.domain.com/share.git/LogDemo-active.yml": {
"key1": "value1",
"key2": "value2"
},
...................
...................
What I am missing? How to read the property file from other repo i.e. https://username#bitbucket.my.domain.com/service.git too?
Below is my bootstrap.yml
spring:
application:
name: LogDemo
mvc:
view:
prefix: /
suffix: .jsp
Here is my manifest file
---
inherit: baseManifest.yml
applications:
- name: LogDemo
host: LogDemo
env:
LOG_LEVEL: INFO
spring.profiles.active: active
TZ: America/New_York
memory: 1024M
domain: my.domain.com
services:
- config-server-comp
When using multiple repos, the repos that will be applied depend on the pattern's defined for those repos. The default pattern is <repo-name>/*. Thus changing the repo name to LogDemo will activate the repo for your app, because the app name, spring.application.name, is LogDemo.
If one or more patterns match, then the repo for the matched patterns will be used. If no pattern matches then the default is used.
Full details are described in the docs here.
https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#_pattern_matching_and_multiple_repositories
If you don't need or want the pattern matching feature, you can use the [composite backend](
https://docs.pivotal.io/spring-cloud-services/2-0/common/config-server/composite-backends.html). The composite backend allows you to define multiple Git repositories. See the first config example here.
https://docs.pivotal.io/spring-cloud-services/2-0/common/config-server/composite-backends.html#general-configuration

new composer-wallet - jszip error

I am making a new composer-wallet with composer 0.19.0
All test passed fine - test based on composer-wallet-filesystem
I can successfully import business network cards to the new wallet and use them for transactions.
I am only one issue
$ composer card list
Error: Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html
Command failed
I tryed to update jszip to the lastest version in composer-cli, but same problem
Here is the environment variable to configure the connection
export NODE_CONFIG='{
"composer": {
"wallet": {
"type": "composer-wallet-mongodb",
"desc": "Uses a local mongodb instance",
"options": {
"uri": "mongodb://localhost:27017/yourCollection",
"collectionName": "myWallet",
"options": {
}
}
}
}
}'
Any help is welcomed

Configuration in Allure to Cucumber in Ruby

I need to configure the following params:
environment, trend, history, executors, retries,
etc. I need these params for cucumber to work with ruby. I searched in a lot of places and I did not find much. I would appreciate if you can provide these params.
History
Allure stores history information to allure-report/history folder during report generation. So you need to copy such folder from previous launch into your allure-results before you generate the report.
History features are handled out of the box by Allure CI plugins
Executor info
To add an information about your test executor create a file executor.json in your allure-results:
{
"name": "Jenkins",
"type": "jenkins",
"url": "http://example.org",
"buildOrder": 13,
"buildName": "allure-report_deploy#13",
"buildUrl": "http://example.org/build#13",
"reportUrl": "http://example.org/build#13/AllureReport",
"reportName": "Demo allure report"
}
In the report such information will be displayed like this:
Allure CI plugins will add executor information for you
Categories
You can also add custom problem categories in the report. Create file categories.json and place it into your results folder:
[
{
"name": "Ignored tests",
"messageRegex": ".*ignored.*",
"matchedStatuses": [
"skipped"
]
},
{
"name": "Infrastructure problems",
"messageRegex": ".*RuntimeException.*",
"matchedStatuses": [
"broken"
]
},
{
"name": "Outdated tests",
"messageRegex": ".*FileNotFound.*",
"matchedStatuses": [
"broken"
]
},
{
"name": "Regression",
"messageRegex": ".*\\sException:.*",
"matchedStatuses": [
"broken"
]
}
]
Retries
Retries are handled by default. For each test Allure generates historyId (usually it is md5(fullName + parameterValues)). If report contains few results with the same historyId Allure only displays latest, other are marked as retries and available from Retries section on test result page.
For example, if you run your test 3 times (first 2 are broken, latest is passed, Allure will display such test as passed)

Multiple Service Definition in Config File Not Working Consul

I have been trying to add multiple service through configuration in consul.
But Consul UI is throwing error at startup of the agent itself.
The error is:-
$consul.exe agent --dev
Starting Consul agent...
panic: runtime error: invalid memory address or nil pointer dereference
github.com/hashicorp/consul/agent.(*Agent).loadServices(0xc0421268c0,
0xc04223aa80, 0xc042254a00, 0x0)
/gopath/src/github.com/hashicorp/consul/agent/agent.go:2097
github.com/hashicorp/consul/agent.(*Agent).Start()
/gopath/src/github.com/hashicorp/consul/agent/agent.go:326
github.com/hashicorp/consul/command.(*AgentCommand).run()
/gopath/src/github.com/hashicorp/consul/command/agent.go:704
github.com/hashicorp/consul/command.(*AgentCommand).Run()
/gopath/src/github.com/hashicorp/consul/command/agent.go:653
Config file is:-
{
"Services": [{
"id": "somename",
"name": "nameofthissevice",
"service": "myservice",
"address": "127.0.0.1",
"port": 62133,
"enableTagOverride": false,
"tags" : ["service1"]
},
{
"id": "somename1",
"name": "nameofthissevice",
"service": "myservice2",
"address": "127.0.0.1",
"port": 64921,
"enableTagOverride": false,
"tags" : ["service2"]
}]
}
I am using Win 7 platform.
Could any one suggest some ideas in it.
Thx
The configuration file is not loaded, so the problem is not in the file, in order to load the configuration file you should add another flag for loading the configuration, otherwise consul will start with default configuration.
Looks like a faulty binary or incompatible version.
Your windows7 is a 32 bit arch or 64?
And which exec version of consul have you downloaded ?

Resources