From bb5d813e5c4ffa0315f0b16ca0a2f06195d884fd Mon Sep 17 00:00:00 2001 From: Xin Hao Zhang Date: Tue, 25 Jul 2023 15:10:27 -0400 Subject: [PATCH 1/3] acceptance: make `TestDockerCLI_test_exec_log` wait for unambiguous log line The `TestDockerCLI_test_exec_log` test had a section where it waits for the last executed stmt to appear in the exec_log file before proceeding to the next section. This is done by grep'ing the query string of the last stmt. This works fine most of the time, however, the 2nd last and last stmt executed happen to have the same query string, so it's possible that we are only seeing the 2nd to last stmt in the log. This can cause the test to fail as in the next section, we expect all query logs to be present in the file. This commit fixes this by issuing a distinct query as the last query so that we can grep for a distinct query string to verify all stmts should have been written. A new proc is also added to `common.tcl`: flush_and_sync_logs is a proc that takes 2 arguments, `filename` and `grep_text`. It will trigger a signal hang up to trigger a log flush and then attempt to find the `grep_text` in the specified file. Epic: none Fixes: #106367 --- pkg/cli/interactive_tests/common.tcl | 14 ++++++++++++ pkg/cli/interactive_tests/test_exec_log.tcl | 24 +++++++-------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/pkg/cli/interactive_tests/common.tcl b/pkg/cli/interactive_tests/common.tcl index 38fc46d70c54..2d49cb5b5c44 100644 --- a/pkg/cli/interactive_tests/common.tcl +++ b/pkg/cli/interactive_tests/common.tcl @@ -144,6 +144,20 @@ proc flush_server_logs {} { report "END FLUSH LOGS" } +proc flush_and_sync_logs {filename grep_text} { + report "BEGIN FLUSH LOGS $filename" + system "kill -HUP `cat server_pid` 2>/dev/null" + # Wait for flush to occur. + system "for i in `seq 1 5`; do + grep '$grep_text' $filename && exit 0; + echo still waiting + sleep 1 + done + echo 'server failed to flush logs?' + exit 1" + report "END FLUSH LOGS" +} + proc force_stop_server {argv} { report "BEGIN FORCE STOP SERVER" system "kill -KILL `cat server_pid`" diff --git a/pkg/cli/interactive_tests/test_exec_log.tcl b/pkg/cli/interactive_tests/test_exec_log.tcl index 8d3852db7f5e..f1f0d01f28fa 100644 --- a/pkg/cli/interactive_tests/test_exec_log.tcl +++ b/pkg/cli/interactive_tests/test_exec_log.tcl @@ -97,23 +97,15 @@ send "SELECT 550+5;\r" eexpect 555 eexpect root@ -flush_server_logs +# Use this distinct query to be the boundary - if we see this stmt in the +# exec log, then we should expect all the previous statements in the log too. + +send "SELECT 111;\r" +eexpect 111 +eexpect root@ + +flush_and_sync_logs $logfile "SELECT ..*111..*" -# Now check the items are there in the log file. We need to iterate -# because flush_server_logs only syncs on flush of cockroach.log, not -# the exec log. -# -# We also check the last statement first, this ensures that every -# previous statement is also in the log file after this check -# succeeds. -system "for i in `seq 1 3`; do - grep 'SELECT ..*550..* +' $logfile && exit 0; - echo still waiting; - sleep 1; -done; -echo 'not finding two separate txn counter values?'; -grep 'SELECT ..*550..* +' $logfile; -exit 1;" # Two separate single-stmt txns. system "n=`grep 'SELECT ..*550..* +' $logfile | sed -e 's/.*TxnCounter.:\\(\[0-9\]*\\).*/\\1/g' | uniq | wc -l`; if test \$n -ne 2; then echo unexpected \$n; exit 1; fi" From 9e5de35da06681fc25ab1d1e30652608ea2384e2 Mon Sep 17 00:00:00 2001 From: zachlite Date: Fri, 28 Jul 2023 13:08:08 -0400 Subject: [PATCH 2/3] diagnosticsccl: fix TestUsageQuantization TestUsageQuantization failed with secondary tenants because the test's server.TestingKnobs were not being passed through to test tenant creation. Resolves #106901 Epic: none Release note: None --- pkg/ccl/serverccl/diagnosticsccl/reporter_test.go | 2 -- pkg/server/testserver.go | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/ccl/serverccl/diagnosticsccl/reporter_test.go b/pkg/ccl/serverccl/diagnosticsccl/reporter_test.go index 5fbcf8925324..b6d9ca720509 100644 --- a/pkg/ccl/serverccl/diagnosticsccl/reporter_test.go +++ b/pkg/ccl/serverccl/diagnosticsccl/reporter_test.go @@ -288,8 +288,6 @@ func TestUsageQuantization(t *testing.T) { url := r.URL() s, db, _ := serverutils.StartServer(t, base.TestServerArgs{ - DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(106901), - Settings: st, Knobs: base.TestingKnobs{ Server: &server.TestingKnobs{ diff --git a/pkg/server/testserver.go b/pkg/server/testserver.go index 3f999fc3c8d8..443f1947381a 100644 --- a/pkg/server/testserver.go +++ b/pkg/server/testserver.go @@ -587,9 +587,13 @@ func (ts *TestServer) maybeStartDefaultTestTenant(ctx context.Context) error { // Since we're creating a tenant, it doesn't make sense to pass through the // Server testing knobs, since the bulk of them only apply to the system // tenant. Any remaining knobs which are required by the tenant should be - // setup in StartTenant below. + // passed through here. params.TestingKnobs.Server = &TestingKnobs{} + if ts.params.Knobs.Server != nil { + params.TestingKnobs.Server.(*TestingKnobs).DiagnosticsTestingKnobs = ts.params.Knobs.Server.(*TestingKnobs).DiagnosticsTestingKnobs + } + // Temporarily disable the error that is returned if a tenant should not be started manually, // so that we can start the default test tenant internally here. disableStartTenantError := ts.disableStartTenantError From 790d9c0ecdd67c045452a0c46d76b07c80eb7f9a Mon Sep 17 00:00:00 2001 From: Xin Hao Zhang Date: Thu, 27 Jul 2023 23:57:08 -0400 Subject: [PATCH 3/3] cluster-ui: delete unused vars Delete unused vars in cluster-ui. A following commit will turn unused vars to errors via the eslint config. Release note: None Epic: none --- .../cluster-ui/src/api/databaseDetailsApi.ts | 36 ++++--------------- .../src/columnsSelector/columnsSelector.tsx | 2 +- .../cluster-ui/src/databases/combiners.ts | 1 - .../cluster-ui/src/databases/util.spec.ts | 1 - .../insightDetailsTables.tsx | 2 +- .../statementInsightDetails.tsx | 1 - .../statementInsightDetailsOverviewTab.tsx | 1 - .../statementInsightsTable.tsx | 3 +- .../statementInsightsView.tsx | 1 - .../workloadInsights/util/insightsColumns.tsx | 8 ++--- .../src/jobs/jobsPage/jobsPage.spec.tsx | 3 +- .../schedulesPage/schedulesPage.fixture.tsx | 1 - .../schedules/schedulesPage/schedulesPage.tsx | 2 +- .../selectors/activeExecutions.selectors.ts | 7 +--- .../cluster-ui/src/selectors/common.ts | 10 ------ .../sessions/sessionDetailsPage.fixture.ts | 4 +-- .../src/sessions/sessionsPage.fixture.ts | 8 ++--- .../src/sessions/sessionsPageConnected.tsx | 2 +- .../cluster-ui/src/sessions/sessionsTable.tsx | 7 +--- .../src/sortedtable/sortedtable.tsx | 2 +- .../src/sqlActivity/errorComponent.tsx | 4 +-- .../planDetails/plansTable.tsx | 1 - .../src/statsTableUtil/statsTableUtil.tsx | 3 -- .../databaseDetails.saga.spec.ts | 2 -- .../databasesList/databasesList.reducers.ts | 2 -- .../src/store/jobs/jobs.selectors.ts | 1 - .../src/store/sqlStats/sqlStats.reducer.ts | 4 +-- .../src/timeScaleDropdown/rangeSelect.tsx | 4 +-- .../timeScaleDropdown.spec.tsx | 4 +-- .../cluster-ui/src/timestamp/timestamp.tsx | 2 +- .../src/tracez/snapshot/snapshotPage.spec.tsx | 21 +++++------ .../transactionsCells/transactionsCells.tsx | 2 +- .../cluster-ui/src/util/versions.ts | 3 +- 33 files changed, 42 insertions(+), 113 deletions(-) diff --git a/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts index e3efd52c7618..1fa55bdadefc 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts @@ -93,11 +93,7 @@ const getDatabaseId: DatabaseDetailsQuery = { resp.idResp.error = txn_result.error; } }, - handleMaxSizeError: ( - dbName: string, - response: SqlTxnResult, - dbDetail: DatabaseDetailsResponse, - ) => { + handleMaxSizeError: (_dbName, _response, _dbDetail) => { return new Promise(() => false); }, }; @@ -135,11 +131,7 @@ const getDatabaseGrantsQuery: DatabaseDetailsQuery = { } } }, - handleMaxSizeError: ( - dbName: string, - response: SqlTxnResult, - dbDetail: DatabaseDetailsResponse, - ) => { + handleMaxSizeError: (_dbName, _response, _dbDetail) => { return new Promise(() => false); }, }; @@ -284,11 +276,7 @@ const getDatabaseZoneConfig: DatabaseDetailsQuery = { resp.idResp.error = txn_result.error; } }, - handleMaxSizeError: ( - dbName: string, - response: SqlTxnResult, - dbDetail: DatabaseDetailsResponse, - ) => { + handleMaxSizeError: (_dbName, _response, _dbDetail) => { return new Promise(() => false); }, }; @@ -341,11 +329,7 @@ const getDatabaseSpanStats: DatabaseDetailsQuery = { ); } }, - handleMaxSizeError: ( - dbName: string, - response: SqlTxnResult, - dbDetail: DatabaseDetailsResponse, - ) => { + handleMaxSizeError: (_dbName, _response, _dbDetail) => { return new Promise(() => false); }, }; @@ -390,11 +374,7 @@ const getDatabaseReplicasAndRegions: DatabaseDetailsQuery, - dbDetail: DatabaseDetailsResponse, - ) => { + handleMaxSizeError: (_dbName, _response, _dbDetail) => { return new Promise(() => false); }, }; @@ -444,11 +424,7 @@ const getDatabaseIndexUsageStats: DatabaseDetailsQuery = { resp.stats.indexStats.error = txn_result.error; } }, - handleMaxSizeError: ( - dbName: string, - response: SqlTxnResult, - dbDetail: DatabaseDetailsResponse, - ) => { + handleMaxSizeError: (_dbName, _response, _dbDetail) => { return new Promise(() => false); }, }; diff --git a/pkg/ui/workspaces/cluster-ui/src/columnsSelector/columnsSelector.tsx b/pkg/ui/workspaces/cluster-ui/src/columnsSelector/columnsSelector.tsx index f7a631778c90..b4bbf7d91a3b 100644 --- a/pkg/ui/workspaces/cluster-ui/src/columnsSelector/columnsSelector.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/columnsSelector/columnsSelector.tsx @@ -86,7 +86,7 @@ const customStyles = { ...provided, maxHeight: "310px", }), - option: (provided: any, state: any) => ({ + option: (provided: any, _state: any) => ({ ...provided, backgroundColor: "white", color: "#475872", diff --git a/pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts b/pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts index 4ed0d87e790f..7cc40d8a0986 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts +++ b/pkg/ui/workspaces/cluster-ui/src/databases/combiners.ts @@ -26,7 +26,6 @@ import { DatabaseTablePageDataDetails, IndexStat } from "../databaseTablePage"; import { IndexStatsState } from "../store/indexStats"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { RecommendationType as RecType } from "../indexDetailsPage"; -import { TableIndexStatsResponse } from "../api/indexDetailsApi"; type IndexUsageStatistic = cockroach.server.serverpb.TableIndexStatsResponse.IExtendedCollectedIndexUsageStatistics; const { RecommendationType } = cockroach.sql.IndexRecommendation; diff --git a/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts b/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts index 25190598f443..d3b068988976 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts @@ -8,7 +8,6 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import { assert } from "chai"; import { getNodesByRegionString, normalizePrivileges, diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx index 96473b640d6c..d3cde934a93a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx @@ -19,7 +19,7 @@ import { TransactionDetailsLink, } from "../workloadInsights/util"; import { TimeScale } from "../../timeScaleDropdown"; -import { Timestamp, Timezone } from "../../timestamp"; +import { Timestamp } from "../../timestamp"; interface InsightDetailsTableProps { data: ContentionEvent[]; diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetails.tsx index a90ff2251115..7e36aaf5fc2f 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetails.tsx @@ -76,7 +76,6 @@ export const StatementInsightDetails: React.FC< isTenant, timeScale, hasAdminRole, - setTimeScale, refreshUserSQLRoles, }) => { const [explainPlanState, setExplainPlanState] = useState({ diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx index fa50ab5ef7cf..c7d8afa512d2 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx @@ -33,7 +33,6 @@ import { StatementDetailsLink, TransactionDetailsLink, } from "../workloadInsights/util"; -import { TimeScale } from "../../timeScaleDropdown"; import { getStmtInsightRecommendations } from "../utils"; import { ContentionStatementDetailsTable } from "./insightDetailsTables"; import { WaitTimeInsightsLabels } from "../../detailsPanels/waitTimeInsightsPanel"; diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsTable.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsTable.tsx index ec9ca9935224..f7b88d0614e4 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsTable.tsx @@ -36,9 +36,8 @@ import { Tooltip } from "@cockroachlabs/ui-components"; import { Link } from "react-router-dom"; import classNames from "classnames/bind"; import styles from "../util/workloadInsights.module.scss"; -import { TimeScale } from "../../../timeScaleDropdown"; import { Badge } from "src/badge"; -import { Timestamp, Timezone } from "../../../timestamp"; +import { Timestamp } from "../../../timestamp"; const cx = classNames.bind(styles); diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx index 9d0178f82447..f16ec7c08984 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx @@ -112,7 +112,6 @@ export const StatementInsightsView: React.FC = ({ selectedColumnNames, dropDownSelect, maxSizeApiReached, - isTenant, }: StatementInsightsViewProps) => { const [pagination, setPagination] = useState({ current: 1, diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/insightsColumns.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/insightsColumns.tsx index 2a9f4e432456..46f949043c34 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/insightsColumns.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/insightsColumns.tsx @@ -166,19 +166,19 @@ export const insightsTableTitles: InsightsTableTitleType = { "username", ); }, - schemaName: (execType: InsightExecEnum) => { + schemaName: (_execType: InsightExecEnum) => { return makeToolTip(

The name of the contended schema.

, "schemaName"); }, - databaseName: (execType: InsightExecEnum) => { + databaseName: (_execType: InsightExecEnum) => { return makeToolTip(

The name of the contended database.

, "databaseName", ); }, - tableName: (execType: InsightExecEnum) => { + tableName: (_execType: InsightExecEnum) => { return makeToolTip(

The name of the contended table.

, "tableName"); }, - indexName: (execType: InsightExecEnum) => { + indexName: (_execType: InsightExecEnum) => { return makeToolTip(

The name of the contended index.

, "indexName"); }, applicationName: (execType: InsightExecEnum) => { diff --git a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx index 9749ba7dd11b..0b64b7192d27 100644 --- a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx @@ -13,13 +13,12 @@ import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { JobsPage, JobsPageProps } from "./jobsPage"; import { formatDuration } from "../util/duration"; import { allJobsFixture, earliestRetainedTime } from "./jobsPage.fixture"; -import { prettyDOM, prettyFormat, render } from "@testing-library/react"; +import { render } from "@testing-library/react"; import React from "react"; import { MemoryRouter } from "react-router-dom"; import * as H from "history"; import Job = cockroach.server.serverpb.IJobResponse; -import { CoordinatedUniversalTime, TimezoneContext } from "src/contexts"; const getMockJobsPageProps = (jobs: Array): JobsPageProps => { const history = H.createHashHistory(); diff --git a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx index 46dcd0d1f53a..027245ef2646 100644 --- a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx @@ -7,7 +7,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import * as protos from "@cockroachlabs/crdb-protobuf-client"; import { createMemoryHistory } from "history"; import Long from "long"; import moment from "moment-timezone"; diff --git a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx index 1431341f5bde..f3589511a7c6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx @@ -14,7 +14,7 @@ import { Helmet } from "react-helmet"; import { RouteComponentProps } from "react-router-dom"; import { Schedules } from "src/api/schedulesApi"; import { Delayed } from "src/delayed"; -import { Dropdown, DropdownOption } from "src/dropdown"; +import { Dropdown } from "src/dropdown"; import { Loading } from "src/loading"; import { PageConfig, PageConfigItem } from "src/pageConfig"; import { SortSetting } from "src/sortedtable"; diff --git a/pkg/ui/workspaces/cluster-ui/src/selectors/activeExecutions.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/selectors/activeExecutions.selectors.ts index c9c4ee43edca..651105fd2abd 100644 --- a/pkg/ui/workspaces/cluster-ui/src/selectors/activeExecutions.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/selectors/activeExecutions.selectors.ts @@ -9,12 +9,7 @@ // licenses/APL.txt. import { createSelector } from "reselect"; -import { - ActiveExecutions, - ActiveTransaction, - ExecutionStatus, - ExecutionType, -} from "src/activeExecutions/types"; +import { ActiveExecutions } from "src/activeExecutions/types"; import { AppState } from "src/store"; import { selectActiveExecutionsCombiner } from "src/selectors/activeExecutionsCommon.selectors"; import { selectExecutionID } from "src/selectors/common"; diff --git a/pkg/ui/workspaces/cluster-ui/src/selectors/common.ts b/pkg/ui/workspaces/cluster-ui/src/selectors/common.ts index 1093dbae97d1..6c071c46abfa 100644 --- a/pkg/ui/workspaces/cluster-ui/src/selectors/common.ts +++ b/pkg/ui/workspaces/cluster-ui/src/selectors/common.ts @@ -15,17 +15,7 @@ import { idAttr, statementAttr, txnFingerprintIdAttr, - unset, - ExecutionStatistics, - queryByName, - appAttr, - flattenStatementStats, - FixFingerprintHexValue, } from "src/util"; -import { createSelector } from "@reduxjs/toolkit"; -import { SqlStatsResponse } from "../api"; -import { AggregateStatistics } from "src/statementsTable"; -import { StatementDiagnosticsDictionary } from "src/store/statementDiagnostics"; // The functions in this file are agnostic to the different shape of each // state in db-console and cluster-ui. This file contains selector functions diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetailsPage.fixture.ts b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetailsPage.fixture.ts index 6a25c14f9fa3..6aa07ce9a7eb 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetailsPage.fixture.ts +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetailsPage.fixture.ts @@ -46,8 +46,8 @@ const sessionDetailsPropsBase: SessionDetailsProps = { }, setTimeScale: () => {}, refreshSessions: () => {}, - cancelSession: (req: CancelSessionRequestMessage) => {}, - cancelQuery: (req: CancelQueryRequestMessage) => {}, + cancelSession: (_req: CancelSessionRequestMessage) => {}, + cancelQuery: (_req: CancelQueryRequestMessage) => {}, refreshNodes: () => {}, refreshNodesLiveness: () => {}, uiConfig: { diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.fixture.ts b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.fixture.ts index 4cc2adfd2249..2eb25ec5ffba 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.fixture.ts +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.fixture.ts @@ -210,8 +210,8 @@ export const sessionsPagePropsFixture: SessionsPageProps = { columns: null, internalAppNamePrefix: "$ internal", refreshSessions: () => {}, - cancelSession: (req: CancelSessionRequestMessage) => {}, - cancelQuery: (req: CancelQueryRequestMessage) => {}, + cancelSession: (_req: CancelSessionRequestMessage) => {}, + cancelQuery: (_req: CancelQueryRequestMessage) => {}, onSortingChange: () => {}, }; @@ -239,7 +239,7 @@ export const sessionsPagePropsEmptyFixture: SessionsPageProps = { columns: null, internalAppNamePrefix: "$ internal", refreshSessions: () => {}, - cancelSession: (req: CancelSessionRequestMessage) => {}, - cancelQuery: (req: CancelQueryRequestMessage) => {}, + cancelSession: (_req: CancelSessionRequestMessage) => {}, + cancelQuery: (_req: CancelQueryRequestMessage) => {}, onSortingChange: () => {}, }; diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx index 633d6145b42b..5c3a3255d290 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx @@ -75,7 +75,7 @@ export const selectFilters = createSelector( export const SessionsPageConnected = withRouter( connect( - (state: AppState, props: RouteComponentProps) => ({ + (state: AppState, _props: RouteComponentProps) => ({ sessions: selectSessions(state), internalAppNamePrefix: selectAppName(state), sessionsError: state.adminUI?.sessions.lastError, diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx index 4e6692239172..4667c8440b93 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx @@ -16,12 +16,7 @@ import { DurationToNumber, TimestampToMoment, } from "src/util/convert"; -import { - BytesWithPrecision, - Count, - DATE_FORMAT, - DATE_FORMAT_24_TZ, -} from "src/util/format"; +import { BytesWithPrecision, Count, DATE_FORMAT } from "src/util/format"; import { Link } from "react-router-dom"; import React from "react"; diff --git a/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx b/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx index d87ccf7e823d..9a7045207eba 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx @@ -221,7 +221,7 @@ export class SortedTable extends React.Component< data: T[], sortSetting: SortSetting, columns: ColumnDescriptor[], - pagination?: ISortedTablePagination, + _pagination?: ISortedTablePagination, ): T[] => { if (!sortSetting) { return this.paginatedData(); diff --git a/pkg/ui/workspaces/cluster-ui/src/sqlActivity/errorComponent.tsx b/pkg/ui/workspaces/cluster-ui/src/sqlActivity/errorComponent.tsx index bc8330bf5d83..d5e25a72526a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sqlActivity/errorComponent.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sqlActivity/errorComponent.tsx @@ -11,7 +11,7 @@ import React from "react"; import classNames from "classnames/bind"; import styles from "./sqlActivity.module.scss"; -import moment, { Moment } from "moment-timezone"; +import moment from "moment-timezone"; const cx = classNames.bind(styles); @@ -50,7 +50,7 @@ export function mergeErrors(errs: Error | Error[]): Error { }; errors.forEach( - (x, i, arr) => ( + (x, i) => ( (mergedError.name += ` ${i}: ${x.name};`), (mergedError.message += ` ${i}: ${x.message};`) ), diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx b/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx index 2c0eff373f88..0e858f69a54b 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx @@ -23,7 +23,6 @@ import { limitText, Count, intersperse, - EncodeUriName, EncodeDatabaseTableIndexUri, EncodeDatabaseTableUri, } from "../../util"; diff --git a/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx b/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx index 4d967f03b0aa..7b5da3f938fb 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx @@ -10,7 +10,6 @@ import React from "react"; import { Anchor } from "src/anchor"; -import moment from "moment-timezone"; import { Tooltip } from "@cockroachlabs/ui-components"; import { @@ -25,8 +24,6 @@ import { } from "src/util"; import { Timezone } from "src/timestamp"; -export type NodeNames = { [nodeId: string]: string }; - // Single place for column names. Used in table columns and in columns selector. export const statisticsColumnLabels = { actions: "Actions", diff --git a/pkg/ui/workspaces/cluster-ui/src/store/databaseDetails/databaseDetails.saga.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/databaseDetails/databaseDetails.saga.spec.ts index 01d2e0a98de9..3f794122467c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/databaseDetails/databaseDetails.saga.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/databaseDetails/databaseDetails.saga.spec.ts @@ -30,11 +30,9 @@ import { } from "./databaseDetails.saga"; import { actions, - DatabaseDetailsState, KeyedDatabaseDetailsState, reducer, } from "./databaseDetails.reducer"; -import { DatabasesListState, refreshDatabasesListSaga } from "../databasesList"; describe("DatabaseDetails sagas", () => { const database = "test_db"; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.reducers.ts b/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.reducers.ts index 2e5c1ff2a08d..9cf32cf08fb6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.reducers.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.reducers.ts @@ -12,8 +12,6 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DatabasesListResponse } from "src/api"; import { DOMAIN_NAME, noopReducer } from "../utils"; -import { SqlExecutionRequest } from "../../api/sqlApi"; - export type DatabasesListState = { data: DatabasesListResponse; // Captures thrown errors. diff --git a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts index 6ccf789ffada..7def2159030e 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts @@ -10,7 +10,6 @@ import { createSelector } from "reselect"; import { localStorageSelector } from "../utils/selectors"; -import { adminUISelector } from "../utils/selectors"; export const selectSortSetting = createSelector( localStorageSelector, diff --git a/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts index b1d83753d824..a6329a1e09b7 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts @@ -50,10 +50,10 @@ const sqlStatsSlice = createSlice({ state.inFlight = false; state.valid = false; }, - refresh: (state, action: PayloadAction) => { + refresh: (state, _action: PayloadAction) => { state.inFlight = true; }, - request: (state, action: PayloadAction) => { + request: (state, _action: PayloadAction) => { state.inFlight = true; }, updateTimeScale: (_, _action: PayloadAction) => {}, diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx index 131ba76a93d9..54e8be7ba7f3 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import React, { useState, useRef, useContext } from "react"; +import React, { useState, useRef } from "react"; import { Button, Dropdown } from "antd"; import "antd/lib/button/style"; import "antd/lib/dropdown/style"; @@ -19,7 +19,6 @@ import classNames from "classnames/bind"; import styles from "./rangeSelector.module.scss"; import { TimeWindow } from "./timeScaleTypes"; -import { TimezoneContext } from "../contexts"; import { Timezone } from "src/timestamp"; const cx = classNames.bind(styles); @@ -90,7 +89,6 @@ const RangeSelect = ({ selected, }: RangeSelectProps): React.ReactElement => { const [isVisible, setIsVisible] = useState(false); - const timezone = useContext(TimezoneContext); /** * customDropdownOptionWasJustSelected holds whether the user had just clicked the "Custom time interval" option in * the dropdown menu. diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx index 7d77e0790540..1c9b3bada0f3 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx @@ -26,7 +26,7 @@ import RangeSelect from "./rangeSelect"; import { timeFormat as customMenuTimeFormat } from "../dateRangeMenu"; import { assert } from "chai"; import { TimeWindow, ArrowDirection, TimeScale } from "./timeScaleTypes"; -import { getAllByText, render } from "@testing-library/react"; +import { render } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; /** @@ -285,8 +285,6 @@ describe("TimeScaleDropdown functions", function () { describe("formatRangeSelectSelected", () => { it("formatRangeSelectSelected must return title Past 10 Minutes", () => { - const _ = makeTimeScaleDropdown(state); - const title = formatRangeSelectSelected( currentWindow, state.currentScale, diff --git a/pkg/ui/workspaces/cluster-ui/src/timestamp/timestamp.tsx b/pkg/ui/workspaces/cluster-ui/src/timestamp/timestamp.tsx index 51c9608b3344..4b3153bcab02 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timestamp/timestamp.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timestamp/timestamp.tsx @@ -13,7 +13,7 @@ import React, { useContext } from "react"; import { FormatWithTimezone } from "../util"; import { CoordinatedUniversalTime, TimezoneContext } from "../contexts"; -export function Timezone(props: any) { +export function Timezone() { const timezone = useContext(TimezoneContext); return ( <> diff --git a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/snapshotPage.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/snapshotPage.spec.tsx index a5f602e67661..3ee6deb5eee9 100644 --- a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/snapshotPage.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/snapshotPage.spec.tsx @@ -23,7 +23,6 @@ import { } from "src/api/tracezApi"; import GetTracingSnapshotResponse = cockroach.server.serverpb.GetTracingSnapshotResponse; import Long from "long"; -import { getByTestId } from "@testing-library/dom/types/queries"; const getMockSnapshotPageProps = (): SnapshotPageProps => { const history = H.createHashHistory(); @@ -44,18 +43,14 @@ const getMockSnapshotPageProps = (): SnapshotPageProps => { rawTrace: undefined, rawTraceLoading: false, refreshNodes: () => void {}, - refreshRawTrace: (req: { - nodeID: string; - snapshotID: number; - traceID: Long; - }) => void {}, - refreshSnapshot: (req: { nodeID: string; snapshotID: number }): void => {}, - refreshSnapshots: (id: string): void => {}, - setSort: (value: SortSetting): void => {}, + refreshRawTrace: () => void {}, + refreshSnapshot: (_req: { nodeID: string; snapshotID: number }): void => {}, + refreshSnapshots: (_id: string): void => {}, + setSort: (_value: SortSetting): void => {}, setTraceRecordingType: ( - nodeID: string, - traceID: Long, - recordingMode: RecordingMode, + _nodeID: string, + _traceID: Long, + _recordingMode: RecordingMode, ): Promise => { return Promise.resolve(undefined); }, @@ -73,7 +68,7 @@ const getMockSnapshotPageProps = (): SnapshotPageProps => { snapshotLoading: false, snapshotsLoading: false, sort: undefined, - takeSnapshot: (nodeID: string): Promise => { + takeSnapshot: (_nodeID: string): Promise => { return Promise.resolve(undefined); }, }; diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionsTable/transactionsCells/transactionsCells.tsx b/pkg/ui/workspaces/cluster-ui/src/transactionsTable/transactionsCells/transactionsCells.tsx index c2380da2d0cd..d6b913e7e909 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionsTable/transactionsCells/transactionsCells.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/transactionsTable/transactionsCells/transactionsCells.tsx @@ -12,7 +12,7 @@ import React from "react"; import { Link } from "react-router-dom"; import { getHighlightedText } from "src/highlightedText"; import { Tooltip } from "@cockroachlabs/ui-components"; -import { limitText, unset } from "src/util"; +import { limitText } from "src/util"; import classNames from "classnames/bind"; import statementsStyles from "../../statementsTable/statementsTableContent.module.scss"; import transactionsCellsStyles from "./transactionsCells.module.scss"; diff --git a/pkg/ui/workspaces/cluster-ui/src/util/versions.ts b/pkg/ui/workspaces/cluster-ui/src/util/versions.ts index 0a998e04874e..862aac1b8a5a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/versions.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/versions.ts @@ -60,11 +60,10 @@ export function parseStringToVersion( const matches = inputString.match(regex); if (matches) { - const [, majorVersion, minorVersion, patchVersion, buildNumber] = matches; + const [, majorVersion, minorVersion, patchVersion] = matches; const parsedMajorVersion = parseInt(majorVersion); const parsedMinorVersion = parseInt(minorVersion) || 0; const parsedPatchVersion = parseInt(patchVersion) || 0; - const parsedBuildNumber = parseInt(buildNumber) || 0; return [parsedMajorVersion, parsedMinorVersion, parsedPatchVersion]; } else {