Skip to content
Merged
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
58 changes: 58 additions & 0 deletions e2e_tests/integration/sysinfo-command.spec.ts
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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')
})
}
})
4 changes: 3 additions & 1 deletion src/browser/components/Tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export const SysInfoTableEntry = ({
return mappedValue || !optional ? (
<StyledTr>
<StyledTdKey>{label}</StyledTdKey>
<StyledTd>{mappedValue || missingValuePlaceholder}</StyledTd>
<StyledTd data-testid={label}>
{mappedValue || missingValuePlaceholder}
</StyledTd>
</StyledTr>
) : null
}
2 changes: 1 addition & 1 deletion src/shared/modules/dbMeta/dbMetaDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 48 additions & 13 deletions src/shared/modules/dbMeta/dbMetaEpics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import { cleanupSettings } from './dbMetaEpics'
import { ClientSettings } from './dbMetaDuck'
import { SemVer } from 'semver'

const defaultSettings: ClientSettings = {
allowOutgoingConnections: true,
Expand All @@ -30,7 +31,7 @@ const defaultSettings: ClientSettings = {
retainEditorHistory: true,
allowTelemetry: true,
authEnabled: true,
metricsNamespacesEnabled: false,
metricsNamespacesEnabled: true,
metricsPrefix: 'neo4j'
}

Expand Down Expand Up @@ -58,60 +59,94 @@ 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
}
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
}
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
}
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
}
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)
})
})
21 changes: 15 additions & 6 deletions src/shared/modules/dbMeta/dbMetaEpics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand All @@ -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']
Expand All @@ -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'] ??
Expand Down