Skip to content

Commit 5cfd983

Browse files
authored
AzureMonitor - E2E tests drone update (grafana#57100)
* Update e2e command with video flag * Add Cloud Plugins E2E tests to drone * Update env variable names * Add vault Azure secrets * Update e2e steps * Update secrets path * Update image and rebuild drone file * Readd drone changes * Rebuild drone * Remake drone * Correct reference to secret * Remake drone file * Remove unneeded step * Clear values in Arg query
1 parent e4c394d commit 5cfd983

File tree

8 files changed

+124
-3
lines changed

8 files changed

+124
-3
lines changed

.drone.yml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,31 @@ steps:
507507
HOST: grafana-server
508508
image: cypress/included:9.5.1-node16.14.0-slim-chrome99-ff97
509509
name: end-to-end-tests-various-suite
510+
- commands:
511+
- cd /
512+
- ./cpp-e2e/scripts/ci-run.sh azure ${DRONE_SOURCE_BRANCH}
513+
depends_on:
514+
- grafana-server
515+
environment:
516+
AZURE_SP_APP_ID:
517+
from_secret: azure_sp_app_id
518+
AZURE_SP_PASSWORD:
519+
from_secret: azure_sp_app_pw
520+
AZURE_TENANT:
521+
from_secret: azure_tenant
522+
CYPRESS_CI: "true"
523+
GITHUB_TOKEN:
524+
from_secret: github_token_pr
525+
HOST: grafana-server
526+
image: us-docker.pkg.dev/grafanalabs-dev/cloud-data-sources/e2e:latest
527+
name: end-to-end-tests-cloud-plugins-suite-azure
528+
when:
529+
paths:
530+
include:
531+
- pkg/tsdb/azuremonitor/**
532+
- public/app/plugins/datasource/grafana-azure-monitor-datasource/**
533+
repo:
534+
- grafana/grafana
510535
- commands:
511536
- apt-get update
512537
- apt-get install -yq zip
@@ -1321,6 +1346,31 @@ steps:
13211346
HOST: grafana-server
13221347
image: cypress/included:9.5.1-node16.14.0-slim-chrome99-ff97
13231348
name: end-to-end-tests-various-suite
1349+
- commands:
1350+
- cd /
1351+
- ./cpp-e2e/scripts/ci-run.sh azure ${DRONE_SOURCE_BRANCH}
1352+
depends_on:
1353+
- grafana-server
1354+
environment:
1355+
AZURE_SP_APP_ID:
1356+
from_secret: azure_sp_app_id
1357+
AZURE_SP_PASSWORD:
1358+
from_secret: azure_sp_app_pw
1359+
AZURE_TENANT:
1360+
from_secret: azure_tenant
1361+
CYPRESS_CI: "true"
1362+
GITHUB_TOKEN:
1363+
from_secret: github_token_pr
1364+
HOST: grafana-server
1365+
image: us-docker.pkg.dev/grafanalabs-dev/cloud-data-sources/e2e:latest
1366+
name: end-to-end-tests-cloud-plugins-suite-azure
1367+
when:
1368+
paths:
1369+
include:
1370+
- pkg/tsdb/azuremonitor/**
1371+
- public/app/plugins/datasource/grafana-azure-monitor-datasource/**
1372+
repo:
1373+
- grafana/grafana
13241374
- commands:
13251375
- apt-get update
13261376
- apt-get install -yq zip
@@ -5409,6 +5459,24 @@ get:
54095459
kind: secret
54105460
name: gcp_upload_artifacts_key
54115461
---
5462+
get:
5463+
name: application_id
5464+
path: infra/data/ci/datasources/cpp-azure-resourcemanager-credentials
5465+
kind: secret
5466+
name: azure_sp_app_id
5467+
---
5468+
get:
5469+
name: application_secret
5470+
path: infra/data/ci/datasources/cpp-azure-resourcemanager-credentials
5471+
kind: secret
5472+
name: azure_sp_app_pw
5473+
---
5474+
get:
5475+
name: tenant_id
5476+
path: infra/data/ci/datasources/cpp-azure-resourcemanager-credentials
5477+
kind: secret
5478+
name: azure_tenant
5479+
---
54125480
get:
54135481
name: public-key
54145482
path: infra/data/ci/packages-publish/gpg
@@ -5446,6 +5514,6 @@ kind: secret
54465514
name: packages_secret_access_key
54475515
---
54485516
kind: signature
5449-
hmac: 7a173a96edd8b0495105d526b95121599fe2f7fba715bdf2a96073a2af5eca7d
5517+
hmac: d703e0a1b27d8396587f430f4175ec924dd51baf4e5b89ff49c94560b9452631
54505518

54515519
...

e2e/cloud-plugins-suite/azure-monitor.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ e2e.scenario({
183183
queriesForm: () => {
184184
e2eSelectors.queryEditor.header.select().find('input').type('Azure Resource Graph{enter}');
185185
e2e().wait(1000); // Need to wait for code editor to completely load
186-
e2e().get('[aria-label="Remove Primary Subscription"]').click();
186+
e2eSelectors.queryEditor.argsQueryEditor.subscriptions
187+
.input()
188+
.find('[aria-label="select-clear-value"]')
189+
.click();
187190
e2eSelectors.queryEditor.argsQueryEditor.subscriptions.input().find('input').type('datasources{enter}');
188191
e2e.components.CodeEditor.container().type(
189192
"Resources | where resourceGroup == 'cloud-plugins-e2e-test' | project name, resourceGroup"

e2e/run-suite

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ case "$1" in
6868
*)
6969
cypressConfig[integrationFolder]=../../e2e/"${args[0]}"
7070
cypressConfig[testFiles]=$testFilesForSingleSuite
71+
cypressConfig[video]=${args[1]}
7172
;;
7273
esac
7374

pkg/build/cmd/e2etests.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func EndToEndTests(c *cli.Context) error {
1515
tries = c.Int("tries")
1616
suite = c.String("suite")
1717
host = c.String("host")
18+
video = c.String("video")
1819
)
1920

2021
log.Printf("Running Grafana e2e tests")
@@ -30,7 +31,7 @@ func EndToEndTests(c *cli.Context) error {
3031
for i := 0; i < tries; i++ {
3132
log.Printf("Running e2e test suite attempt #%d", i+1)
3233
//nolint:gosec
33-
cmd := exec.Command("./e2e/run-suite", suite)
34+
cmd := exec.Command("./e2e/run-suite", suite, video)
3435
cmd.Env = env
3536
cmd.Stdout = os.Stdout
3637
cmd.Stderr = os.Stderr

pkg/build/cmd/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func main() {
5656
Value: "grafana-server",
5757
Usage: "Specify the server host",
5858
},
59+
&cli.StringFlag{
60+
Name: "video",
61+
Value: "true",
62+
Usage: "Specify if videos should be recorded",
63+
},
5964
},
6065
},
6166
{

scripts/drone/pipelines/build.star

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ load(
3636
'betterer_frontend_step',
3737
'trigger_test_release',
3838
'compile_build_cmd',
39+
'cloud_plugins_e2e_tests_step',
3940
)
4041

4142
load(
@@ -75,6 +76,7 @@ def build_e2e(trigger, ver_mode, edition):
7576
e2e_tests_step('smoke-tests-suite', edition=edition),
7677
e2e_tests_step('panels-suite', edition=edition),
7778
e2e_tests_step('various-suite', edition=edition),
79+
cloud_plugins_e2e_tests_step('cloud-plugins-suite', edition=edition, cloud='azure', trigger=trigger_oss),
7880
e2e_tests_artifacts(edition=edition),
7981
build_storybook_step(edition=edition, ver_mode=ver_mode),
8082
copy_packages_for_docker_step(),

scripts/drone/steps/lib.star

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,41 @@ def e2e_tests_step(suite, edition, port=3001, tries=None):
731731
],
732732
}
733733

734+
def cloud_plugins_e2e_tests_step(suite, edition, cloud, port=3001, video="false", trigger=None):
735+
environment = {}
736+
when = {}
737+
if trigger:
738+
when = trigger
739+
if cloud == 'azure':
740+
environment = {
741+
'CYPRESS_CI': 'true',
742+
'HOST': 'grafana-server' + enterprise2_suffix(edition),
743+
'GITHUB_TOKEN': from_secret('github_token_pr'),
744+
'AZURE_SP_APP_ID': from_secret('azure_sp_app_id'),
745+
'AZURE_SP_PASSWORD': from_secret('azure_sp_app_pw'),
746+
'AZURE_TENANT': from_secret('azure_tenant')
747+
}
748+
when= dict(when, paths={
749+
'include' : [
750+
'pkg/tsdb/azuremonitor/**',
751+
'public/app/plugins/datasource/grafana-azure-monitor-datasource/**'
752+
]
753+
})
754+
branch = "${DRONE_SOURCE_BRANCH}".replace("/", "-")
755+
step = {
756+
'name': 'end-to-end-tests-{}-{}'.format(suite, cloud) + enterprise2_suffix(edition),
757+
'image': 'us-docker.pkg.dev/grafanalabs-dev/cloud-data-sources/e2e:latest',
758+
'depends_on': [
759+
'grafana-server',
760+
],
761+
'environment': environment,
762+
'commands': [
763+
'cd /',
764+
'./cpp-e2e/scripts/ci-run.sh {} {}'.format(cloud, branch)
765+
],
766+
}
767+
step = dict(step, when=when)
768+
return step
734769

735770
def build_docs_website_step():
736771
return {

scripts/drone/vault.star

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ github_token = 'github_token'
33
drone_token = 'drone_token'
44
prerelease_bucket = 'prerelease_bucket'
55
gcp_upload_artifacts_key = 'gcp_upload_artifacts_key'
6+
azure_sp_app_id = 'azure_sp_app_id'
7+
azure_sp_app_pw = 'azure_sp_app_pw'
8+
azure_tenant = 'azure_tenant'
69

710
def from_secret(secret):
811
return {
@@ -26,6 +29,9 @@ def secrets():
2629
vault_secret(drone_token, 'infra/data/ci/drone', 'machine-user-token'),
2730
vault_secret(prerelease_bucket, 'infra/data/ci/grafana/prerelease', 'bucket'),
2831
vault_secret(gcp_upload_artifacts_key, 'infra/data/ci/grafana/releng/artifacts-uploader-service-account', 'credentials.json'),
32+
vault_secret(azure_sp_app_id, 'infra/data/ci/datasources/cpp-azure-resourcemanager-credentials', 'application_id'),
33+
vault_secret(azure_sp_app_pw, 'infra/data/ci/datasources/cpp-azure-resourcemanager-credentials', 'application_secret'),
34+
vault_secret(azure_tenant, 'infra/data/ci/datasources/cpp-azure-resourcemanager-credentials', 'tenant_id'),
2935

3036
# Package publishing
3137
vault_secret('packages_gpg_public_key', 'infra/data/ci/packages-publish/gpg', 'public-key'),

0 commit comments

Comments
 (0)