John Cowen f111d6b3e3
ui: Dev/Test environment configurable metrics (#9345)
In order to test certain setups for our metrics visualizations we need to be able to setup several different `ui_config` settings during development/testing. Generally in the UI, we use the Web Inspector to set various cookie values to configure the UI how we need to see it whilst developing, so this PR:

1. Routes `ui_config` through a dev time only `CONSUL_UI_CONFIG` env variable so we can change it via cookies vars.
2. Adds `CONSUL_METRICS_PROXY_ENABLE`, `CONSUL_METRICS_PROVIDER` and `CONSUL_SERVICE_DASHBOARD_URL` so it's easy to set/unset these only values during development.
3. Adds an acceptance testing step so we can setup `ui_config` to whatever we want during testing.
4. Adds an async 'repository-like' method to the `UiConfig` Service so it feels like a repository - incase we ever need to get this via an HTTP API+blocking query.
5. Vaguely unrelated: we allow cookie values to be set via the location.hash whilst in development only e.g. `/ui/services#CONSUL_METRICS_PROXY_ENABLE=1` so we can link to different setups if we ever need to.

All values added here are empty/falsey by default, so in order to see how it was previously you'll need to set the appropriate cookies values, but you can now also easily preview/test the the metrics viz in different/disabled states (with differing `ui_config`)
2020-12-15 15:34:54 +00:00

122 lines
3.2 KiB
Gherkin

@setupApplicationTest
Feature: dc / services / show: Show Service
Scenario: Given a service with an external source, the logo is displayed
Given 1 datacenter model with the value "dc1"
And 1 node models
And 1 service model from yaml
---
- Service:
Kind: ~
Tags: ['Tag1', 'Tag2']
Meta:
external-source: consul
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
Then I see externalSource like "consul"
And the title should be "service-0 - Consul"
Scenario: Given a service with an 'unsupported' external source, there is no logo
Given 1 datacenter model with the value "dc1"
And 1 node models
And 1 service model from yaml
---
- Service:
Kind: ~
Tags: ['Tag1', 'Tag2']
Meta:
external-source: 'not-supported'
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
Then I don't see externalSource
Scenario: Given various services with various tags, all tags are displayed
Given 1 datacenter model with the value "dc1"
And 3 node models
And 1 service model from yaml
---
- Service:
Kind: ~
Tags: ['Tag1', 'Tag2']
- Service:
Kind: ~
Tags: ['Tag3', 'Tag1']
- Service:
Kind: ~
Tags: ['Tag2', 'Tag3']
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
And I click tags on the tabs
Then I see the text "Tag1" in "[data-test-tags] span:nth-child(1)"
Then I see the text "Tag2" in "[data-test-tags] span:nth-child(2)"
Then I see the text "Tag3" in "[data-test-tags] span:nth-child(3)"
Scenario: Given various services the various nodes on their instances are displayed
Given 1 datacenter model with the value "dc1"
And 3 node models
And 1 service model from yaml
---
- Checks:
- Status: critical
Service:
Kind: ~
ID: passing-service-8080
Port: 8080
Address: 1.1.1.1
Node:
Address: 1.2.2.2
- Checks:
- Status: warning
Service:
Kind: ~
ID: service-8000
Port: 8000
Address: 2.2.2.2
Node:
Address: 2.3.3.3
- Checks:
- Status: passing
Service:
Kind: ~
ID: service-8888
Port: 8888
Address: 3.3.3.3
Node:
Address: 3.4.4.4
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
And I click instances on the tabs
Then I see address on the instances like yaml
---
- "1.1.1.1:8080"
- "2.2.2.2:8000"
- "3.3.3.3:8888"
---
Scenario: Given a dashboard template has been set
Given 1 datacenter model with the value "dc1"
And ui_config from yaml
---
dashboard_url_templates:
service: https://something.com?{{Service.Name}}&{{Datacenter}}
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
# The Metrics dashboard should use the Service.Name not the ID
And I see href on the metricsAnchor like "https://something.com?service-0&dc1"