diff --git a/e2e_tests/integration/sysinfo-command.spec.ts b/e2e_tests/integration/sysinfo-command.spec.ts new file mode 100644 index 00000000000..db1bf8762a0 --- /dev/null +++ b/e2e_tests/integration/sysinfo-command.spec.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2002-2021 "Neo4j," + * Neo4j Sweden AB [http://neo4j.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import { isEnterpriseEdition } from '../support/utils' + +describe(':sysinfo command', () => { + before(function () { + cy.visit(Cypress.config('url')).title().should('include', 'Neo4j Browser') + cy.wait(3000) + cy.ensureConnection() + }) + beforeEach(() => { + cy.executeCommand(':clear') + }) + + if (isEnterpriseEdition()) { + if (Cypress.config('serverVersion') >= 4.0) { + it('sysinfo shows store size', () => { + cy.executeCommand(':sysinfo') + + cy.get('[data-testid="Database"]').should('not.have.text', '-') + }) + } + + it('sysinfo shows Id allocation', () => { + cy.executeCommand( + 'CREATE (a:TestLabel)-[:CONNECTS]->(b:TestLabel) RETURN a, b' + ) + + cy.executeCommand(':sysinfo') + + cy.get('[data-testid="Relationship Type ID"]').should( + 'not.have.text', + '-' + ) + + // Clear + cy.executeCommand('MATCH (a:TestLabel) DETACH DELETE a') + }) + } +}) diff --git a/src/browser/components/Tables.tsx b/src/browser/components/Tables.tsx index 4512c86462a..21649ff67ee 100644 --- a/src/browser/components/Tables.tsx +++ b/src/browser/components/Tables.tsx @@ -109,7 +109,9 @@ export const SysInfoTableEntry = ({ return mappedValue || !optional ? ( {label} - {mappedValue || missingValuePlaceholder} + + {mappedValue || missingValuePlaceholder} + ) : null } diff --git a/src/shared/modules/dbMeta/dbMetaDuck.ts b/src/shared/modules/dbMeta/dbMetaDuck.ts index f2f42930497..ffbe0440e24 100644 --- a/src/shared/modules/dbMeta/dbMetaDuck.ts +++ b/src/shared/modules/dbMeta/dbMetaDuck.ts @@ -116,7 +116,7 @@ export const initialClientSettings: ClientSettings = { retainEditorHistory: false, // default is true, but set to false until settings read allowTelemetry: true, // default is true. Renamed to client.allow_telemetry after 5.0 authEnabled: true, // default is true - metricsNamespacesEnabled: false, // default is false, Renamed to server.metrics.namespaces.enabled after 5.0 + metricsNamespacesEnabled: false, // pre 5.0: default is false, from and after 5.0: settings removed, always true metricsPrefix: 'neo4j' // default is 'neo4j', Renamed to server.metrics.prefix after 5.0 } // Initial state diff --git a/src/shared/modules/dbMeta/dbMetaEpics.test.ts b/src/shared/modules/dbMeta/dbMetaEpics.test.ts index 564e5612eb1..87b4311dc47 100644 --- a/src/shared/modules/dbMeta/dbMetaEpics.test.ts +++ b/src/shared/modules/dbMeta/dbMetaEpics.test.ts @@ -20,6 +20,7 @@ import { cleanupSettings } from './dbMetaEpics' import { ClientSettings } from './dbMetaDuck' +import { SemVer } from 'semver' const defaultSettings: ClientSettings = { allowOutgoingConnections: true, @@ -30,7 +31,7 @@ const defaultSettings: ClientSettings = { retainEditorHistory: true, allowTelemetry: true, authEnabled: true, - metricsNamespacesEnabled: false, + metricsNamespacesEnabled: true, metricsPrefix: 'neo4j' } @@ -58,22 +59,25 @@ describe('cleanupSettings', () => { retainEditorHistory: true, allowTelemetry: true, authEnabled: true, - metricsNamespacesEnabled: false, + metricsNamespacesEnabled: true, metricsPrefix: 'neo4j4j' } - const newSettings = cleanupSettings(rawSettings) + const newSettings = cleanupSettings(rawSettings, null) expect(newSettings).toEqual(expectedSettings) }) test('default values', () => { - const newSettings = cleanupSettings({}) + const newSettings = cleanupSettings({}, null) expect(newSettings).toEqual(defaultSettings) }) test('browser.allow_outgoing_connections="false"', () => { - const newSettings = cleanupSettings({ - 'browser.allow_outgoing_connections': 'false' - }) + const newSettings = cleanupSettings( + { + 'browser.allow_outgoing_connections': 'false' + }, + null + ) const expectedSettings = { ...defaultSettings, allowOutgoingConnections: false @@ -81,9 +85,12 @@ describe('cleanupSettings', () => { expect(newSettings).toEqual(expectedSettings) }) test('browser.allow_outgoing_connections="true"', () => { - const newSettings = cleanupSettings({ - 'browser.allow_outgoing_connections': 'true' - }) + const newSettings = cleanupSettings( + { + 'browser.allow_outgoing_connections': 'true' + }, + null + ) const expectedSettings: ClientSettings = { ...defaultSettings, allowOutgoingConnections: true @@ -91,7 +98,10 @@ describe('cleanupSettings', () => { expect(newSettings).toEqual(expectedSettings) }) test('clients.allow_telemetry="false"', () => { - const newSettings = cleanupSettings({ 'clients.allow_telemetry': 'false' }) + const newSettings = cleanupSettings( + { 'clients.allow_telemetry': 'false' }, + null + ) const expectedSettings: ClientSettings = { ...defaultSettings, allowTelemetry: false @@ -99,7 +109,10 @@ describe('cleanupSettings', () => { expect(newSettings).toEqual(expectedSettings) }) test('client.allow_telemetry="false"', () => { - const newSettings = cleanupSettings({ 'client.allow_telemetry': 'false' }) + const newSettings = cleanupSettings( + { 'client.allow_telemetry': 'false' }, + null + ) const expectedSettings: ClientSettings = { ...defaultSettings, allowTelemetry: false @@ -107,11 +120,33 @@ describe('cleanupSettings', () => { expect(newSettings).toEqual(expectedSettings) }) test('server.metrics.prefix=""', () => { - const newSettings = cleanupSettings({ 'server.metrics.prefix': '' }) + const newSettings = cleanupSettings({ 'server.metrics.prefix': '' }, null) const expectedSettings: ClientSettings = { ...defaultSettings, metricsPrefix: '' } expect(newSettings).toEqual(expectedSettings) }) + test('metricsNamespacesEnabled should be default false in 4.0', () => { + const newSettings = cleanupSettings( + { 'server.metrics.namespaces.enabled': '' }, + new SemVer('4.0.0') + ) + const expectedSettings: ClientSettings = { + ...defaultSettings, + metricsNamespacesEnabled: false + } + expect(newSettings).toEqual(expectedSettings) + }) + test('metricsNamespacesEnabled should be default true in 5.0', () => { + const newSettings = cleanupSettings( + { 'server.metrics.namespaces.enabled': '' }, + new SemVer('5.0.0') + ) + const expectedSettings: ClientSettings = { + ...defaultSettings, + metricsNamespacesEnabled: true + } + expect(newSettings).toEqual(expectedSettings) + }) }) diff --git a/src/shared/modules/dbMeta/dbMetaEpics.ts b/src/shared/modules/dbMeta/dbMetaEpics.ts index d2a31812cc2..d46fc35505f 100644 --- a/src/shared/modules/dbMeta/dbMetaEpics.ts +++ b/src/shared/modules/dbMeta/dbMetaEpics.ts @@ -79,7 +79,7 @@ import { getListProcedureQuery } from '../cypher/functionsAndProceduresHelper' import { isInt, Record } from 'neo4j-driver' -import { gte } from 'semver' +import semver, { gte, SemVer } from 'semver' import { triggerCredentialsTimeout } from '../credentialsPolicy/credentialsPolicyDuck' async function databaseList(store: any) { @@ -390,13 +390,18 @@ export const serverConfigEpic = (some$: any, store: any) => .do((res: any) => { if (!res) return Rx.Observable.of(null) + const neo4jVersion = getSemanticVersion(store.getState()) + const rawSettings = res.records.reduce((all: any, record: any) => { const name = record.get('name') all[name] = record.get('value') return all }, {}) - const settings: ClientSettings = cleanupSettings(rawSettings) + const settings: ClientSettings = cleanupSettings( + rawSettings, + neo4jVersion + ) // side-effects store.dispatch( @@ -419,7 +424,10 @@ export const serverConfigEpic = (some$: any, store: any) => .do(() => store.dispatch(update({ serverConfigDone: true }))) .mapTo({ type: 'SERVER_CONFIG_DONE' }) -export const cleanupSettings = (rawSettings: any) => { +export const cleanupSettings = ( + rawSettings: any, + neo4jVersion: SemVer | null +) => { const settings: ClientSettings = { allowOutgoingConnections: !isConfigValFalsy( rawSettings['browser.allow_outgoing_connections'] @@ -441,10 +449,11 @@ export const cleanupSettings = (rawSettings: any) => { isConfigValFalsy(rawSettings['client.allow_telemetry']) ), // default true authEnabled: !isConfigValFalsy(rawSettings['dbms.security.auth_enabled']), // default true - // Info: metrics... in versions < 5.0, server.metrics... in versions >= 5.0 + // Info: in versions < 5.0 exists and defaults to false, in versions >= 5.0 is removed and always true metricsNamespacesEnabled: - isConfigValTruthy(rawSettings['metrics.namespaces.enabled']) || - isConfigValTruthy(rawSettings['server.metrics.namespaces.enabled']), // default false + neo4jVersion && semver.satisfies(neo4jVersion, '<5.0.0') + ? isConfigValTruthy(rawSettings['metrics.namespaces.enabled']) + : true, metricsPrefix: rawSettings['metrics.prefix'] ?? rawSettings['server.metrics.prefix'] ??