Skip to content

Commit

Permalink
Migration VI
Browse files Browse the repository at this point in the history
* Updated DEVELOPMENT.md
* Fixed typos and whitespaces
  • Loading branch information
lpetrora committed Sep 9, 2024
1 parent d18089c commit 32a2099
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 95 deletions.
91 changes: 61 additions & 30 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ you are looking to use the plugin please head over to [README.md](README.md).
1. Install dependencies

```BASH
yarn install --immutable
npm ci
```

2. Build plugin in development mode or run in watch mode

```BASH
yarn dev
npm run dev
```

3. Build plugin in production mode

```BASH
yarn build
npm run build
```

## Maintenance

Code formatting

```BASH
yarn pretty
npm run pretty
```

Update dependencies
Expand All @@ -37,11 +37,9 @@ https://grafana.com/developers/plugin-tools/migration-guides/update-create-plugi

```BASH
npx @grafana/create-plugin@latest update
yarn install
yarn upgrade
yarn pretty
cd tests
yarn upgrade
npm install
npx npm-check-updates -i --format group
npm run pretty
```

## Release
Expand All @@ -57,52 +55,85 @@ yarn upgrade
## E2E Tests

There are serval ways to run the e2e tests.
Make sure to have an up to date `dist/` folder using `yarn build`.
Make sure to have an up to date `dist/` folder using `npm run build`.

### No Interactivity use case (e.g. CI)

```BASH
cd tests/
docker compose up --exit-code-from=playwright
```

This will run all tests without any further interaction necessary.


### Local development use case

Please, note that you need to set serval environment variables as described for [No docker use case](#No-docker-use-case)

```BASH
cd tests/
docker compose up -d checkmk grafana
yarn run cypress open
cd ..
npm run e2e
```

This will show you a nice interactive GUI to run and debug your E2E tests.
See the official [docs](https://docs.cypress.io/guides/overview/why-cypress) for more information.
You can run the tests on the console by runing

### No Interactivity use case (e.g. CI)
```BASH
npm run e2e

# Or you can run it in debug mode
npm run e2e:debug
```

Or you can launch a nice interactive GUI to run and debug your E2E tests
by running

```BASH
cd tests/
docker compose up --exit-code-from=cypress
npm run e2e:gui
```

This will run all tests without any further interaction necessary.
See the official [docs](https://playwright.dev/docs/intro) for more information.

### No docker use case

If you don't want to or can't use docker at all, make sure you have a Grafana and a CheckMK instance running somewhere.
The Plugin you want to test needs to be installed in you Grafana instance.

You also need to set serval environment variables.
First you need to install the Playwright dependencies:
```BASH
npx playwright install --with-deps
```

You also need to set serval environment variables. You can export them or define them in a .env file

| Variable | Description | Example |
| --------------------------- | ----------------------------------------------- | ---------------------------- |
| CMK_SITE | Checkmk site name | cmk |
| CMK_ADMIN | Administrator user name for Checkmk | cmkadmin |
| CMK_AUTOMATION | Automation user name for Checkmk | automation |
| CMK_PASSWORD | Password CMK_ADMIN and CMK_AUTOMATION | my_secret |
| PLAYWRIGHT_TO_CHECKMK_URL | URL for connecting Playwright to Checkmk | http://127.0.0.1:12345/cmk/ |
| PLAYWRIGHT_TO_GRAFANA_URL | URL for connecting Playwright to Grafana | http://127.0.0.1:3003/ |
| GRAFANA_USER | User name for connecting to Grafana's Rest API | grafana_user |
| GRAFANA_PASSWORD | Password for GRAFANA_USERNAME | my_other_secret |
| GRAFANA_TO_CHECKMK_URL | URL for connecting Grafana to Checkmk | http://checkmk:5000/cmk/ |
| GRAFANA_TO_CHECKMK_USER | Checkmk user name to access the Rest API | automation |
| GRAFANA_TO_CHECKMK_PASSWORD | Password for GRAFANA_TO_CHECKMK_USER | my_secret |

| Variable | Description |
| --------------------------- | -------------------------------------------- |
| CYPRESS_baseUrl | The URL to your Grafana instance |
| CYPRESS_grafanaUsername | The username used to log into Grafana |
| CYPRESS_grafanaPassword | the password used to log into Grafana |
| CYPRESS_grafanaToCheckmkUrl | The url from which grafana can reach CheckMK |
| CYPRESS_cypressToCheckmkUrl | The url from which cypress can reach CheckMK |
| CYPRESS_cmkUsername | The username of a CheckMK admin |
| CYPRESS_cmkPassword | The password of that CheckMK admin |

If everything is set up, just start cypress the usual way.

```BASH
yarn run cypress open
# Automatic run
npm run e2e

# or if you want to run it on debug mode
npm run e2e:debug

# or if you just want to see the results
yarn run cypress run
# or if you want to run it with the fancy web interface
npm run e2e:gui
```

Please note that the test have side effects on your Grafana and CheckMK instance,
Expand Down
88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test:ci": "jest --passWithNoTests --maxWorkers 4",
"typecheck": "tsc --noEmit",
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
"lint:fix": "yarn run lint --fix",
"lint:fix": "npm run lint --fix",
"pretty": "prettier -w '{**/*,*}.{js,ts,jsx,tsx,json,yml}'",
"pretty:check": "prettier -c '{**/*,*}.{js,ts,jsx,tsx,json,yml}'",
"server": "docker-compose up --build",
Expand All @@ -19,7 +19,7 @@
"e2e": "playwright test",
"e2e:ci": "playwright test",
"e2e:debug": "playwright test --debug",
"e2e:ui": "playwright test --ui"
"e2e:gui": "playwright test --ui"
},
"author": "Checkmk",
"license": "Apache-2.0",
Expand All @@ -29,7 +29,7 @@
"@grafana/plugin-e2e": "^1.7.2",
"@grafana/tsconfig": "^2.0.0",
"@playwright/test": "^1.47.0",
"@swc/core": "^1.7.23",
"@swc/core": "^1.7.24",
"@swc/helpers": "^0.5.13",
"@swc/jest": "^0.2.36",
"@testing-library/jest-dom": "6.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def on_closed(self, event):
def _process (self, event):
filename = event.src_path
if filename in self.seen_filenames:
return
return
self.seen_filenames.add(filename)
print(f"[GRRD] {filename}")
modify_in_place(filename)
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ services:
CMK_AUTOMATION: automation
CMK_PASSWORD: abskjfdalkdhjbld
PLAYWRIGHT_TO_CHECKMK_URL: http://checkmk:5000/cmk/
PLAYWRIGHT_TO_GRAFANA_URL: http://grafana:3000/
GRAFANA_USER: admin
GRAFANA_PASSWORD: password
GRAFANA_URL: http://grafana:3000/
GRAFANA_TO_CHECKMK_USER: automation
GRAFANA_TO_CHECKMK_PASSWORD: abskjfdalkdhjbld
GRAFANA_TO_CHECKMK_URL: http://checkmk:5000/cmk/
Expand Down
Loading

0 comments on commit 32a2099

Please sign in to comment.