Skip to content

Commit 8931a2a

Browse files
ci: testdrive: fail on empty input and log number of commands (#22313)
1 parent 6d3de68 commit 8931a2a

File tree

16 files changed

+59
-9
lines changed

16 files changed

+59
-9
lines changed

misc/python/materialize/checks/checks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from materialize.checks.executors import Executor
1414
from materialize.util import MzVersion
1515

16+
TESTDRIVE_NOP = "$ nop"
17+
1618

1719
class Check:
1820
def __init__(self, base_version: MzVersion, rng: Random | None) -> None:
@@ -23,7 +25,7 @@ def _can_run(self, e: Executor) -> bool:
2325
return True
2426

2527
def initialize(self) -> Testdrive:
26-
return Testdrive("")
28+
return Testdrive(TESTDRIVE_NOP)
2729

2830
def manipulate(self) -> list[Testdrive]:
2931
assert False
@@ -67,7 +69,7 @@ def join_validate(self, e: Executor) -> None:
6769

6870
class CheckDisabled(Check):
6971
def manipulate(self) -> list[Testdrive]:
70-
return [Testdrive(""), Testdrive("")]
72+
return [Testdrive(TESTDRIVE_NOP), Testdrive(TESTDRIVE_NOP)]
7173

7274
def validate(self) -> Testdrive:
73-
return Testdrive("")
75+
return Testdrive(TESTDRIVE_NOP)

misc/python/materialize/checks/replica.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from textwrap import dedent
1010

1111
from materialize.checks.actions import Testdrive
12-
from materialize.checks.checks import Check
12+
from materialize.checks.checks import TESTDRIVE_NOP, Check
1313
from materialize.checks.executors import Executor
1414
from materialize.util import MzVersion
1515

@@ -80,7 +80,7 @@ def validate(self) -> Testdrive:
8080
true
8181
"""
8282
if self.base_version < MzVersion.parse("0.66.0-dev")
83-
else ""
83+
else TESTDRIVE_NOP
8484
)
8585
)
8686

misc/python/materialize/checks/roles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from textwrap import dedent
1010

1111
from materialize.checks.actions import Testdrive
12-
from materialize.checks.checks import Check
12+
from materialize.checks.checks import TESTDRIVE_NOP, Check
1313
from materialize.checks.executors import Executor
1414
from materialize.util import MzVersion
1515

@@ -24,7 +24,7 @@ def _if_can_grant_revoke(self, text: str) -> str:
2424
return ""
2525

2626
def initialize(self) -> Testdrive:
27-
return Testdrive("")
27+
return Testdrive(TESTDRIVE_NOP)
2828

2929
def manipulate(self) -> list[Testdrive]:
3030
return [

src/testdrive/src/action.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ mod file;
5151
mod http;
5252
mod kafka;
5353
mod mysql;
54+
mod nop;
5455
mod persist;
5556
mod postgres;
5657
mod protobuf;
@@ -569,6 +570,7 @@ impl Run for PosCommand {
569570
"kafka-verify-commit" => kafka::run_verify_commit(builtin, state).await,
570571
"mysql-connect" => mysql::run_connect(builtin, state).await,
571572
"mysql-execute" => mysql::run_execute(builtin, state).await,
573+
"nop" => nop::run_nop(),
572574
"postgres-connect" => postgres::run_connect(builtin, state).await,
573575
"postgres-execute" => postgres::run_execute(builtin, state).await,
574576
"postgres-verify-slot" => postgres::run_verify_slot(builtin, state).await,

src/testdrive/src/action/nop.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Materialize, Inc. and contributors. All rights reserved.
2+
//
3+
// Use of this software is governed by the Business Source License
4+
// included in the LICENSE file.
5+
//
6+
// As of the Change Date specified in that file, in accordance with
7+
// the Business Source License, use of this software will be governed
8+
// by the Apache License, Version 2.0.
9+
10+
use crate::action::ControlFlow;
11+
12+
pub fn run_nop() -> Result<ControlFlow, anyhow::Error> {
13+
Ok(ControlFlow::Continue)
14+
}

src/testdrive/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ use std::path::Path;
8686
use action::Run;
8787
use anyhow::{anyhow, Context};
8888
use mz_ore::error::ErrorExt;
89+
use tracing::debug;
8990

9091
use crate::action::ControlFlow;
9192
use crate::error::{ErrorLocation, PosError};
@@ -154,6 +155,12 @@ pub(crate) async fn run_line_reader(
154155
// connections until after parsing.
155156
let cmds = parser::parse(line_reader)?;
156157

158+
if cmds.is_empty() {
159+
return Err(PosError::from(anyhow!("No input provided!")));
160+
} else {
161+
debug!("Received {} commands to run", cmds.len());
162+
}
163+
157164
let has_kafka_cmd = cmds.iter().any(|cmd| {
158165
matches!(
159166
&cmd.command,

test/legacy-upgrade/check-from-any_version-noop.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
# by the Apache License, Version 2.0.
99

1010
# no-op to keep the upgrade test glob simple
11+
12+
$ nop

test/legacy-upgrade/check-ssl-from-any_version-noop.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
# by the Apache License, Version 2.0.
99

1010
# no-op to keep the upgrade test glob simple
11+
12+
$ nop

test/legacy-upgrade/create-in-any_version-noop.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
# by the Apache License, Version 2.0.
99

1010
# no-op to keep the upgrade test glob simple
11+
12+
$ nop

test/legacy-upgrade/create-ssl-in-any_version-noop.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
# by the Apache License, Version 2.0.
99

1010
# no-op to keep the upgrade test glob simple
11+
12+
$ nop

0 commit comments

Comments
 (0)