Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .config/jest-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Object.assign(global, { TextDecoder, TextEncoder });
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
Object.defineProperty(global, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
value: (query) => ({
matches: false,
media: query,
onchange: null,
Expand All @@ -22,7 +22,7 @@ Object.defineProperty(global, 'matchMedia', {
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
}),
});

HTMLCanvasElement.prototype.getContext = () => {};
6 changes: 6 additions & 0 deletions .config/jest/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNam
const grafanaESModules = [
'.pnpm', // Support using pnpm symlinked packages
'@grafana/schema',
'@wojtekmaj/date-utils',
'd3',
'd3-color',
'd3-force',
'd3-interpolate',
'd3-scale-chromatic',
'get-user-locale',
'marked',
'memoize',
'mimic-function',
'ol',
'react-calendar',
'react-colorful',
'rxjs',
'uuid',
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ process.env.TZ = 'UTC';
module.exports = {
// Jest configuration provided by Grafana scaffolding
...require('./.config/jest.config'),
//testMatch: ['<rootDir>/test/unit/**/*.{spec,test,jest}.{js,jsx,ts,tsx}'],
testMatch: ['**/tests/unit/**/*.{spec,test,jest}.{js,jsx,ts,tsx}'],
};
2,224 changes: 855 additions & 1,369 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"devDependencies": {
"@babel/core": "^7.28.5",
"@grafana/eslint-config": "^7.0.0",
"@grafana/plugin-e2e": "^1.19.4",
"@grafana/plugin-e2e": "^2.2.0",
"@grafana/tsconfig": "^2.0.1",
"@playwright/test": "^1.56.1",
"@swc/core": "^1.13.5",
"@swc/core": "^1.13.20",
"@swc/helpers": "^0.5.17",
"@swc/jest": "^0.2.39",
"@testing-library/jest-dom": "6.9.1",
Expand All @@ -45,7 +45,7 @@
"css-loader": "^7.1.2",
"dotenv": "^17.2.3",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-webpack-plugin": "^4.2.0",
"eslint-webpack-plugin": "^5.0.0",
"fork-ts-checker-webpack-plugin": "^9.1.0",
"glob": "^11.0.3",
"identity-obj-proxy": "3.0.0",
Expand Down Expand Up @@ -73,9 +73,10 @@
"dependencies": {
"@emotion/css": "^11.13.5",
"@grafana/data": "^12.0.2",
"@grafana/runtime": "^11.6.2",
"@grafana/schema": "^11.6.2",
"@grafana/ui": "^11.6.2",
"@grafana/i18n": "^12.2.0",
"@grafana/runtime": "^12.2.0",
"@grafana/schema": "^12.2.0",
"@grafana/ui": "^12.2.0",
"process": "^0.11.10",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"updated": "%TODAY%"
},
"dependencies": {
"grafanaDependency": ">=10.4.18",
"grafanaDependency": ">=11.6.7",
"plugins": []
},
"routes": [
Expand Down
1 change: 1 addition & 0 deletions src/ui/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ export const OnlyActiveChildren = (props: OnlyActiveChildrenProps): React.JSX.El
icon="minus"
data-test-id={'cmk-oac-minus-button-' + getLabel(elem)}
variant="secondary"
aria-label={getLabel(elem)}
onClick={() =>
setActiveComponents((c) => {
if (!React.isValidElement(elem)) {
Expand Down
43 changes: 29 additions & 14 deletions tests/checkmk-docker-hooks/post-start/post-configure-checkmk.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ def parse() -> tuple[argparse.ArgumentParser, argparse.Namespace]:
default=[0],
help="more verbose",
)

parser.add_argument ("--skip-initial-setup", action="store_true")
parser.add_argument ("--skip-automation-user-creation", action="store_true")

subparsers = parser.add_subparsers()

args = parser.parse_args()
Expand Down Expand Up @@ -499,23 +503,34 @@ def main() -> None:
site = Site(CMK_SITE, True)
api = API(site)

create_config = CreateConfig(
folder_name="grafana",
folder_title="grafana",
rule_name="datasource_programs",
rule_value="'cat ~/var/check_mk/agent_output/$HOSTNAME$'",
source_folder="agent_output",
host_attributes={
"tag_agent": "cmk-agent",
},
source_destination="~/var/check_mk/agent_output/{host_name}",
)
if args.skip_initial_setup:
printer.info ("Skipping creating folder, hosts, rules and discovering services")

else:
create_config = CreateConfig(
folder_name="grafana",
folder_title="grafana",
rule_name="datasource_programs",
rule_value="'cat ~/var/check_mk/agent_output/$HOSTNAME$'",
source_folder="agent_output",
host_attributes={
"tag_agent": "cmk-agent",
},
source_destination="~/var/check_mk/agent_output/{host_name}",
)

api.delete_folder(create_config.folder_name)

create_from(create_config, source_files, api, site, printer)

api.delete_folder(create_config.folder_name)
if args.skip_automation_user_creation:
api.activate_changes(printer)

create_from(create_config, source_files, api, site, printer)
if args.skip_automation_user_creation:
printer.info ("Skipping automation user creation")

create_automation_user(CMK_AUITOMATION_USER, CMK_PASS, api, printer)
else:
create_automation_user(CMK_AUITOMATION_USER, CMK_PASS, api, printer)


if __name__ == "__main__":
Expand Down
16 changes: 13 additions & 3 deletions tests/checkmk-docker-hooks/post-start/post-configure-checkmk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
su - cmk -c "/usr/bin/env bash" << __EOF__

# Watch for new rrd files and fill them with random data
# WARNING:
# If the host OS reaches max inode watcher counter, the whole
# setup will fail and so the tests
#
python3 -m pip install watchdog
export GRRD_FORK=1
python3 -u /docker-entrypoint.d/post-start/generate_random_rrd_data.py

# Create hosts and discover services
echo "Setting up hosts and services"
python3 -u /docker-entrypoint.d/post-start/post-configure-checkmk.py --skip-automation-user-creation

# Wait until Checkmk API responds our requests
until curl -f -s -u cmkadmin:abskjfdalkdhjbld http://127.0.0.1:5000/cmk/check_mk/api/1.0/version
until curl -f -s -o /dev/null -u cmkadmin:abskjfdalkdhjbld http://127.0.0.1:5000/cmk/check_mk/api/1.0/version
do
echo Wait until Checkmk API is ready...
sleep 5
done

# Create hosts, discover services, and create automation user
python3 -u /docker-entrypoint.d/post-start/post-configure-checkmk.py
# Create automation user
echo "Setting up automation user"
python3 -u /docker-entrypoint.d/post-start/post-configure-checkmk.py --skip-initial-setup

__EOF__
Loading