From 651df406ecf66518005c806d9ccd1bd3260e4af3 Mon Sep 17 00:00:00 2001 From: Gyanendra Mishra Date: Mon, 18 Sep 2023 17:24:14 +0200 Subject: [PATCH] refactor!: rename assert to verify (#1295) ## Description: ## Is this change user facing? YES/NO ## References (if applicable): --- .../startosis_engine/kurtosis_builtins.go | 4 +- .../shared_helpers/service_helpers.go | 4 +- .../{assert/assert.go => verify/verify.go} | 52 +++++++++---------- .../assert_test.go => verify/verify_test.go} | 20 +++---- .../kurtosis_instruction/wait/wait.go | 6 +-- .../test_engine/assert_framework_test.go | 22 ++++---- .../service_config/ready_condition.go | 4 +- .../startosis_interpreter_idempotent_test.go | 12 ++--- docs/docs/starlark-reference/plan.md | 26 +++++----- .../render_templates_test.go | 2 +- .../starlark_exec_test/starlark_exec_test.go | 6 +-- .../startosis_add_service_test.go | 8 +-- ..._add_service_with_ready_conditions_test.go | 2 +- ...add_services_with_ready_conditions_test.go | 2 +- .../startosis_assert_fail_test.go | 4 +- ...rtosis_complex_request_wait_assert_test.go | 32 ++++++------ .../run_task_sh_task_test.go | 18 +++---- .../ci_tests/startosis_simple_script.star | 2 +- .../starlark/upload-file-package/main.star | 2 +- 19 files changed, 114 insertions(+), 114 deletions(-) rename core/server/api_container/server/startosis_engine/kurtosis_instruction/{assert/assert.go => verify/verify.go} (81%) rename core/server/api_container/server/startosis_engine/kurtosis_instruction/{assert/assert_test.go => verify/verify_test.go} (75%) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_builtins.go b/core/server/api_container/server/startosis_engine/kurtosis_builtins.go index 613392584d..bf99003560 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_builtins.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_builtins.go @@ -7,7 +7,6 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/builtins/print_builtin" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/builtins/read_file" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/add_service" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/exec" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/kurtosis_print" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/remove_service" @@ -18,6 +17,7 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/store_service_files" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/upload_files" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" @@ -56,7 +56,7 @@ func KurtosisPlanInstructions(serviceNetwork service_network.ServiceNetwork, run return []*kurtosis_plan_instruction.KurtosisPlanInstruction{ add_service.NewAddService(serviceNetwork, runtimeValueStore), add_service.NewAddServices(serviceNetwork, runtimeValueStore), - assert.NewAssert(runtimeValueStore), + verify.NewVerify(runtimeValueStore), exec.NewExec(serviceNetwork, runtimeValueStore), kurtosis_print.NewPrint(serviceNetwork, runtimeValueStore), remove_service.NewRemoveService(serviceNetwork), diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers/service_helpers.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers/service_helpers.go index f360e8c6ff..706a067989 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers/service_helpers.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers/service_helpers.go @@ -4,7 +4,7 @@ import ( "context" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/service" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_types" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/recipe" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" @@ -75,7 +75,7 @@ func ExecuteServiceAssertionWithRecipe( } func assertResult(currentResult starlark.Comparable, assertion string, target starlark.Comparable) error { - err := assert.Assert(currentResult, assertion, target) + err := verify.Verify(currentResult, assertion, target) if err != nil { return err } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert/assert.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go similarity index 81% rename from core/server/api_container/server/startosis_engine/kurtosis_instruction/assert/assert.go rename to core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go index 149e0f258b..abeab09a6f 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert/assert.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify.go @@ -1,4 +1,4 @@ -package assert +package verify import ( "context" @@ -20,7 +20,7 @@ import ( ) const ( - AssertBuiltinName = "assert" + VerifyBuiltinName = "verify" RuntimeValueArgName = "value" AssertionArgName = "assertion" @@ -41,10 +41,10 @@ var StringTokenToComparisonStarlarkToken = map[string]syntax.Token{ "<": syntax.LT, } -func NewAssert(runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtosis_plan_instruction.KurtosisPlanInstruction { +func NewVerify(runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtosis_plan_instruction.KurtosisPlanInstruction { return &kurtosis_plan_instruction.KurtosisPlanInstruction{ KurtosisBaseBuiltin: &kurtosis_starlark_framework.KurtosisBaseBuiltin{ - Name: AssertBuiltinName, + Name: VerifyBuiltinName, Arguments: []*builtin_argument.BuiltinArgument{ { @@ -57,7 +57,7 @@ func NewAssert(runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtos Name: AssertionArgName, IsOptional: false, ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String], - Validator: ValidateAssertionToken, + Validator: ValidateVerificationToken, }, { Name: TargetArgName, @@ -69,7 +69,7 @@ func NewAssert(runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtos }, Capabilities: func() kurtosis_plan_instruction.KurtosisPlanInstructionCapabilities { - return &AssertCapabilities{ + return &VerifyCapabilities{ runtimeValueStore: runtimeValueStore, runtimeValue: "", // populated at interpretation time @@ -86,7 +86,7 @@ func NewAssert(runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtos } } -type AssertCapabilities struct { +type VerifyCapabilities struct { runtimeValueStore *runtime_value_store.RuntimeValueStore runtimeValue string @@ -94,12 +94,12 @@ type AssertCapabilities struct { target starlark.Comparable } -func (builtin *AssertCapabilities) Interpret(_ string, arguments *builtin_argument.ArgumentValuesSet) (starlark.Value, *startosis_errors.InterpretationError) { +func (builtin *VerifyCapabilities) Interpret(_ string, arguments *builtin_argument.ArgumentValuesSet) (starlark.Value, *startosis_errors.InterpretationError) { runtimeValue, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, RuntimeValueArgName) if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", RuntimeValueArgName) } - assertion, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, AssertionArgName) + verification, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, AssertionArgName) if err != nil { return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", AssertionArgName) } @@ -108,7 +108,7 @@ func (builtin *AssertCapabilities) Interpret(_ string, arguments *builtin_argume return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", TargetArgName) } - builtin.assertion = assertion.GoString() + builtin.assertion = verification.GoString() builtin.runtimeValue = runtimeValue.GoString() builtin.target = target @@ -118,11 +118,11 @@ func (builtin *AssertCapabilities) Interpret(_ string, arguments *builtin_argume return starlark.None, nil } -func (builtin *AssertCapabilities) Validate(_ *builtin_argument.ArgumentValuesSet, _ *startosis_validator.ValidatorEnvironment) *startosis_errors.ValidationError { +func (builtin *VerifyCapabilities) Validate(_ *builtin_argument.ArgumentValuesSet, _ *startosis_validator.ValidatorEnvironment) *startosis_errors.ValidationError { return nil } -func (builtin *AssertCapabilities) Execute(_ context.Context, _ *builtin_argument.ArgumentValuesSet) (string, error) { +func (builtin *VerifyCapabilities) Execute(_ context.Context, _ *builtin_argument.ArgumentValuesSet) (string, error) { currentValue, err := magic_string_helper.GetOrReplaceRuntimeValueFromString(builtin.runtimeValue, builtin.runtimeValueStore) if err != nil { return "", err @@ -136,44 +136,44 @@ func (builtin *AssertCapabilities) Execute(_ context.Context, _ *builtin_argumen return "", err } } - err = Assert(currentValue, builtin.assertion, targetWithReplacedRuntimeValuesMaybe) + err = Verify(currentValue, builtin.assertion, targetWithReplacedRuntimeValuesMaybe) if err != nil { return "", err } - instructionResult := fmt.Sprintf("Assertion succeeded. Value is '%s'.", currentValue.String()) + instructionResult := fmt.Sprintf("Verification succeeded. Value is '%s'.", currentValue.String()) return instructionResult, nil } -func (builtin *AssertCapabilities) TryResolveWith(instructionsAreEqual bool, _ *enclave_plan_persistence.EnclavePlanInstruction, _ *enclave_structure.EnclaveComponents) enclave_structure.InstructionResolutionStatus { +func (builtin *VerifyCapabilities) TryResolveWith(instructionsAreEqual bool, _ *enclave_plan_persistence.EnclavePlanInstruction, _ *enclave_structure.EnclaveComponents) enclave_structure.InstructionResolutionStatus { if instructionsAreEqual { return enclave_structure.InstructionIsEqual } return enclave_structure.InstructionIsUnknown } -func (builtin *AssertCapabilities) FillPersistableAttributes(builder *enclave_plan_persistence.EnclavePlanInstructionBuilder) { - builder.SetType(AssertBuiltinName) +func (builtin *VerifyCapabilities) FillPersistableAttributes(builder *enclave_plan_persistence.EnclavePlanInstructionBuilder) { + builder.SetType(VerifyBuiltinName) } -// Assert verifies whether the currentValue matches the targetValue w.r.t. the assertion operator -// TODO: This and ValidateAssertionToken below are used by both assert and wait. Refactor it to a better place -func Assert(currentValue starlark.Comparable, assertion string, targetValue starlark.Comparable) error { +// Verify verifies whether the currentValue matches the targetValue w.r.t. the assertion operator +// TODO: This and ValidateVerificationToken below are used by both verify and wait. Refactor it to a better place +func Verify(currentValue starlark.Comparable, assertion string, targetValue starlark.Comparable) error { if comparisonToken, found := StringTokenToComparisonStarlarkToken[assertion]; found { if currentValue.Type() != targetValue.Type() { - return stacktrace.NewError("Assert failed because '%v' is type '%v' and '%v' is type '%v'", currentValue, currentValue.Type(), targetValue, targetValue.Type()) + return stacktrace.NewError("Verify failed because '%v' is type '%v' and '%v' is type '%v'", currentValue, currentValue.Type(), targetValue, targetValue.Type()) } result, err := currentValue.CompareSameType(comparisonToken, targetValue, 1) if err != nil { - return stacktrace.Propagate(err, "Assert comparison failed '%v' '%v' '%v'", currentValue, assertion, targetValue) + return stacktrace.Propagate(err, "Verify comparison failed '%v' '%v' '%v'", currentValue, assertion, targetValue) } if !result { - return stacktrace.NewError("Assertion failed '%v' '%v' '%v'", currentValue, assertion, targetValue) + return stacktrace.NewError("Verification failed '%v' '%v' '%v'", currentValue, assertion, targetValue) } return nil } else if assertion == InCollectionAssertionToken || assertion == NotInCollectionAssertionToken { iterableTarget, ok := targetValue.(starlark.Iterable) if !ok { - return stacktrace.NewError("Assertion failed, expected an iterable object but got '%v'", targetValue.Type()) + return stacktrace.NewError("Verification failed, expected an iterable object but got '%v'", targetValue.Type()) } iterator := iterableTarget.Iterate() @@ -192,12 +192,12 @@ func Assert(currentValue starlark.Comparable, assertion string, targetValue star if assertion == NotInCollectionAssertionToken && !currentValuePresentInIterable { return nil } - return stacktrace.NewError("Assertion failed '%v' '%v' '%v'", currentValue, assertion, targetValue) + return stacktrace.NewError("Verification failed '%v' '%v' '%v'", currentValue, assertion, targetValue) } return stacktrace.NewError("The '%s' token '%s' seems invalid. This is a Kurtosis bug as it should have been validated earlier", AssertionArgName, assertion) } -func ValidateAssertionToken(value starlark.Value) *startosis_errors.InterpretationError { +func ValidateVerificationToken(value starlark.Value) *startosis_errors.InterpretationError { strValue, ok := value.(starlark.String) if !ok { return startosis_errors.NewInterpretationError("'%s' argument should be a 'starlark.String', got '%s'", AssertionArgName, reflect.TypeOf(value)) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert/assert_test.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify_test.go similarity index 75% rename from core/server/api_container/server/startosis_engine/kurtosis_instruction/assert/assert_test.go rename to core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify_test.go index ba5955e2ec..ec87e950de 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert/assert_test.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify/verify_test.go @@ -1,4 +1,4 @@ -package assert +package verify import ( "github.com/stretchr/testify/require" @@ -10,28 +10,28 @@ func TestAssert_StringsEqual(t *testing.T) { currentValue := starlark.String("Hello") assertion := "==" targetValue := starlark.String("Hello") - require.Nil(t, Assert(currentValue, assertion, targetValue)) + require.Nil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_StringsNonEqual(t *testing.T) { currentValue := starlark.String("Hello") assertion := "==" targetValue := starlark.String("World") - require.NotNil(t, Assert(currentValue, assertion, targetValue)) + require.NotNil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_IntsLt(t *testing.T) { currentValue := starlark.MakeInt(1) assertion := "<" targetValue := starlark.MakeInt(5) - require.Nil(t, Assert(currentValue, assertion, targetValue)) + require.Nil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_IntsGtFalse(t *testing.T) { currentValue := starlark.MakeInt(1) assertion := ">" targetValue := starlark.MakeInt(5) - require.NotNil(t, Assert(currentValue, assertion, targetValue)) + require.NotNil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_ListIn(t *testing.T) { @@ -41,7 +41,7 @@ func TestAssert_ListIn(t *testing.T) { starlark.String("Hello"), starlark.String("World"), }) - require.Nil(t, Assert(currentValue, assertion, targetValue)) + require.Nil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_ListInFalse(t *testing.T) { @@ -51,7 +51,7 @@ func TestAssert_ListInFalse(t *testing.T) { starlark.String("Hello"), starlark.String("World"), }) - require.NotNil(t, Assert(currentValue, assertion, targetValue)) + require.NotNil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_ListNotIn(t *testing.T) { @@ -61,7 +61,7 @@ func TestAssert_ListNotIn(t *testing.T) { starlark.String("Hello"), starlark.String("World"), }) - require.Nil(t, Assert(currentValue, assertion, targetValue)) + require.Nil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_ListNotInFalse(t *testing.T) { @@ -71,7 +71,7 @@ func TestAssert_ListNotInFalse(t *testing.T) { starlark.String("Hello"), starlark.String("World"), }) - require.NotNil(t, Assert(currentValue, assertion, targetValue)) + require.NotNil(t, Verify(currentValue, assertion, targetValue)) } func TestAssert_InvalidToken(t *testing.T) { @@ -81,5 +81,5 @@ func TestAssert_InvalidToken(t *testing.T) { starlark.String("Hello"), starlark.String("World"), }) - require.NotNil(t, Assert(currentValue, assertion, targetValue)) + require.NotNil(t, Verify(currentValue, assertion, targetValue)) } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go index 79b1174532..4c6f228c6a 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/wait/wait.go @@ -7,8 +7,8 @@ import ( "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/service_network" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_plan_persistence" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/enclave_structure" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/shared_helpers" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" @@ -66,7 +66,7 @@ func NewWait(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *r Name: AssertionArgName, IsOptional: false, ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String], - Validator: assert.ValidateAssertionToken, + Validator: verify.ValidateVerificationToken, }, { Name: TargetArgName, @@ -206,7 +206,7 @@ func (builtin *WaitCapabilities) Interpret(_ string, arguments *builtin_argument return nil, startosis_errors.NewInterpretationError("An error occurred while creating return value for %v instruction", WaitBuiltinName) } - if _, ok := builtin.target.(starlark.Iterable); (builtin.assertion == assert.InCollectionAssertionToken || builtin.assertion == assert.NotInCollectionAssertionToken) && !ok { + if _, ok := builtin.target.(starlark.Iterable); (builtin.assertion == verify.InCollectionAssertionToken || builtin.assertion == verify.NotInCollectionAssertionToken) && !ok { return nil, startosis_errors.NewInterpretationError("'%v' assertion requires an iterable for target values, got '%v'", builtin.assertion, builtin.target.Type()) } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/assert_framework_test.go b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/assert_framework_test.go index cc6b75dc8b..1a6b6aa2a0 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/assert_framework_test.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/test_engine/assert_framework_test.go @@ -3,7 +3,7 @@ package test_engine import ( "fmt" "github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/uuid_generator" - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_plan_instruction" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/runtime_value_store" "github.com/stretchr/testify/require" @@ -15,14 +15,14 @@ const ( runtimeValueValue = "Hello World!" ) -type assertTestCase struct { +type verificationTestcase struct { *testing.T runtimeValueStore *runtime_value_store.RuntimeValueStore runtimeValueUuid string } -func (suite *KurtosisPlanInstructionTestSuite) TestAssert() { +func (suite *KurtosisPlanInstructionTestSuite) TestVerify() { runtimeValueUuid, err := uuid_generator.GenerateUUIDString() suite.Require().Nil(err) err = suite.runtimeValueStore.SetValue(runtimeValueUuid, map[string]starlark.Comparable{ @@ -30,30 +30,30 @@ func (suite *KurtosisPlanInstructionTestSuite) TestAssert() { }) suite.Require().NoError(err) - suite.run(&assertTestCase{ + suite.run(&verificationTestcase{ T: suite.T(), runtimeValueUuid: runtimeValueUuid, runtimeValueStore: suite.runtimeValueStore, }) } -func (t *assertTestCase) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanInstruction { - return assert.NewAssert(t.runtimeValueStore) +func (t *verificationTestcase) GetInstruction() *kurtosis_plan_instruction.KurtosisPlanInstruction { + return verify.NewVerify(t.runtimeValueStore) } -func (t *assertTestCase) GetStarlarkCode() string { +func (t *verificationTestcase) GetStarlarkCode() string { runtimeValue := fmt.Sprintf("{{kurtosis:%s:value.runtime_value}}", t.runtimeValueUuid) assertion := "==" targetValue := runtimeValueValue - return fmt.Sprintf("%s(%s=%q, %s=%q, %s=%q)", assert.AssertBuiltinName, assert.RuntimeValueArgName, runtimeValue, assert.AssertionArgName, assertion, assert.TargetArgName, targetValue) + return fmt.Sprintf("%s(%s=%q, %s=%q, %s=%q)", verify.VerifyBuiltinName, verify.RuntimeValueArgName, runtimeValue, verify.AssertionArgName, assertion, verify.TargetArgName, targetValue) } -func (t *assertTestCase) GetStarlarkCodeForAssertion() string { +func (t *verificationTestcase) GetStarlarkCodeForAssertion() string { return "" } -func (t *assertTestCase) Assert(interpretationResult starlark.Value, executionResult *string) { +func (t *verificationTestcase) Assert(interpretationResult starlark.Value, executionResult *string) { require.Equal(t, starlark.None, interpretationResult) - expectedExecutionResult := fmt.Sprintf(`Assertion succeeded. Value is '%q'.`, runtimeValueValue) + expectedExecutionResult := fmt.Sprintf(`Verification succeeded. Value is '%q'.`, runtimeValueValue) require.Equal(t, expectedExecutionResult, *executionResult) } diff --git a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/ready_condition.go b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/ready_condition.go index 1f835b4ec0..f07d54bf25 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/ready_condition.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_types/service_config/ready_condition.go @@ -1,7 +1,7 @@ package service_config import ( - "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/assert" + "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_instruction/verify" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/builtin_argument" "github.com/kurtosis-tech/kurtosis/core/server/api_container/server/startosis_engine/kurtosis_starlark_framework/kurtosis_type_constructor" @@ -49,7 +49,7 @@ func NewReadyConditionType() *kurtosis_type_constructor.KurtosisTypeConstructor Name: AssertionAttr, IsOptional: false, ZeroValueProvider: builtin_argument.ZeroValueProvider[starlark.String], - Validator: assert.ValidateAssertionToken, + Validator: verify.ValidateVerificationToken, }, { Name: TargetAttr, diff --git a/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go b/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go index c78d3e5cfb..042416359c 100644 --- a/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_interpreter_idempotent_test.go @@ -304,7 +304,7 @@ func (suite *StartosisInterpreterIdempotentTestSuite) TestInterpretAndOptimize_A service_1 = plan.add_service(name="service_1", config=ServiceConfig(image="kurtosistech/image:1.2.3")) plan.print("Service 1 - IP: {} - Hostname: {}".format(service_1.ip_address, service_1.hostname)) plan.exec(service_name="service_1", recipe=ExecRecipe(command=["echo", "Hello World!"])) - plan.assert(value=service_1.ip_address, assertion="==", target_value="fake_ip") + plan.verify(value=service_1.ip_address, assertion="==", target_value="fake_ip") ` // Interpretation of the initial script to generate the current enclave plan _, currentEnclavePlan, interpretationApiErr := suite.interpreter.Interpret( @@ -324,7 +324,7 @@ func (suite *StartosisInterpreterIdempotentTestSuite) TestInterpretAndOptimize_A service_1 = plan.add_service(name="service_1", config=ServiceConfig(image="kurtosistech/image:1.5.0")) # <-- version updated plan.print("Service 1 - IP: {} - Hostname: {}".format(service_1.ip_address, service_1.hostname)) # <-- identical plan.exec(service_name="service_1", recipe=ExecRecipe(command=["echo", "Hello World!"])) # <-- identical but should be rerun b/c service_1 updated - plan.assert(value=service_1.ip_address, assertion="==", target_value="fake_ip") # <-- identical b/c we don't track runtime value provenance yet + plan.verify(value=service_1.ip_address, assertion="==", target_value="fake_ip") # <-- identical b/c we don't track runtime value provenance yet ` // Interpret the updated script against the current enclave plan _, instructionsPlan, interpretationError := suite.interpreter.InterpretAndOptimizePlan( @@ -356,7 +356,7 @@ func (suite *StartosisInterpreterIdempotentTestSuite) TestInterpretAndOptimize_A require.False(suite.T(), scheduledInstruction3.IsExecuted()) scheduledInstruction4 := instructionSequence[3] - require.Regexp(suite.T(), `assert\(value="{{kurtosis:[a-z0-9]{32}:ip_address\.runtime_value}}", assertion="==", target_value="fake_ip"\)`, scheduledInstruction4.GetInstruction().String()) + require.Regexp(suite.T(), `verify\(value="{{kurtosis:[a-z0-9]{32}:ip_address\.runtime_value}}", assertion="==", target_value="fake_ip"\)`, scheduledInstruction4.GetInstruction().String()) require.True(suite.T(), scheduledInstruction4.IsExecuted()) } @@ -373,7 +373,7 @@ func (suite *StartosisInterpreterIdempotentTestSuite) TestInterpretAndOptimize_U ) service_1 = plan.add_service(name="service_1", config=ServiceConfig(image="kurtosistech/image:1.2.3", files={"/path/": files_artifact})) plan.exec(service_name="service_1", recipe=ExecRecipe(command=["echo", "Hello World!"])) - plan.assert(value=service_1.ip_address, assertion="==", target_value="fake_ip") + plan.verify(value=service_1.ip_address, assertion="==", target_value="fake_ip") ` // Interpretation of the initial script to generate the current enclave plan _, currentEnclavePlan, interpretationApiErr := suite.interpreter.Interpret( @@ -398,7 +398,7 @@ func (suite *StartosisInterpreterIdempotentTestSuite) TestInterpretAndOptimize_U ) service_1 = plan.add_service(name="service_1", config=ServiceConfig(image="kurtosistech/image:1.2.3", files={"/path/": files_artifact})) plan.exec(service_name="service_1", recipe=ExecRecipe(command=["echo", "Hello World!"])) - plan.assert(value=service_1.ip_address, assertion="==", target_value="fake_ip") + plan.verify(value=service_1.ip_address, assertion="==", target_value="fake_ip") ` // Interpret the updated script against the current enclave plan _, instructionsPlan, interpretationError := suite.interpreter.InterpretAndOptimizePlan( @@ -430,7 +430,7 @@ func (suite *StartosisInterpreterIdempotentTestSuite) TestInterpretAndOptimize_U require.False(suite.T(), scheduledInstruction3.IsExecuted()) // since the service has been updated, the exec will be re-run scheduledInstruction4 := instructionSequence[3] - require.Regexp(suite.T(), `assert\(value="{{kurtosis:[a-z0-9]{32}:ip_address\.runtime_value}}", assertion="==", target_value="fake_ip"\)`, scheduledInstruction4.GetInstruction().String()) + require.Regexp(suite.T(), `verify\(value="{{kurtosis:[a-z0-9]{32}:ip_address\.runtime_value}}", assertion="==", target_value="fake_ip"\)`, scheduledInstruction4.GetInstruction().String()) require.True(suite.T(), scheduledInstruction4.IsExecuted()) // this instruction is not affected, i.e. it won't be re-run } diff --git a/docs/docs/starlark-reference/plan.md b/docs/docs/starlark-reference/plan.md index c51f2507a0..d97be9f8f7 100644 --- a/docs/docs/starlark-reference/plan.md +++ b/docs/docs/starlark-reference/plan.md @@ -96,14 +96,14 @@ services will be rolled back and the instruction will return an execution error. ::: -assert +verify ------ -The `assert` instruction throws an [Execution phase error][multi-phase-runs-reference] if the defined assertion fails. +The `verify` instruction throws an [Execution phase error][multi-phase-runs-reference] if the defined assertion fails. ```python -plan.assert( - # The value currently being asserted. +plan.verify( + # The value currently being verified. # MANDATORY value = "test1", @@ -117,7 +117,7 @@ plan.assert( target_value = "test2", ) # This fails in runtime given that "test1" == "test2" is false -plan.assert( +plan.verify( # Value can also be a runtime value derived from a `get_value` call value = response["body"], assertion = "==", @@ -127,10 +127,10 @@ plan.assert( :::caution -Asserts are typed, so running +Verifications are typed, so running ```python -plan.assert( +plan.verify( value = "0", assertion = "==", target_value = 0, @@ -180,7 +180,7 @@ plan.print(result["code"]) The instruction returns a `dict` whose values are [future reference][future-references-reference] to the output and exit code of the command. `result["output"]` is a future reference to the output of the command, and `result["code"]` is a future reference to the exit code. -They can be chained to [`assert`][assert] and [`wait`][wait]: +They can be chained to [`verify`][verify] and [`wait`][wait]: ```python exec_recipe = ExecRecipe( @@ -188,7 +188,7 @@ exec_recipe = ExecRecipe( ) result = plan.exec(service_name="my_service", recipe=exec_recipe) -plan.assert(result["code"], "==", 0) +plan.verify(result["code"], "==", 0) plan.wait(service_name="my_service", recipe=exec_recipe, field="output", assertion="!=", target_value="Greetings, world") ``` @@ -322,7 +322,7 @@ post_response = plan.request( NOTE: In the above example, `response` also has a custom field `extract.second-element-from-list-head` and the value is `world` which is extracted from the `response[body]`. -These fields can be used in conjunction with [`assert`][assert] and [`wait`][wait] instructions, like so: +These fields can be used in conjunction with [`verify`][verify] and [`wait`][wait] instructions, like so: ```python # Following the example above, response["extract.second-element-from-list-head"] is world post_response = plan.request( @@ -331,7 +331,7 @@ post_response = plan.request( ) # Assert if the extracted field in the response is world -plan.assert(response["extract.second-element-from-list-head"], "==", "world") +plan.verify(response["extract.second-element-from-list-head"], "==", "world") # Make a post request and check if the extracted field in the response is world plan.wait(service_name="my_service", recipe=post_request_recipe, field="extract.second-element-from-list-head", assertion="==", target_value="world") @@ -609,7 +609,7 @@ The return value is a [future reference][future-references-reference] to the nam wait ---- -The `wait` instruction fails the Starlark script or package with an execution error if the provided [assertion][assert] does not succeed within a given period of time. +The `wait` instruction fails the Starlark script or package with an execution error if the provided [verification][verify] does not succeed within a given period of time. If the assertion succeeds, `wait` returns the result of the given Recipe - i.e. the same output as [`plan.request`][request] or [`plan.exec`][exec]. @@ -665,7 +665,7 @@ plan.print(recipe_result["code"]) [add-service]: #add_service [add-services]: #add_services -[assert]: #assert +[verify]: #verify [extract]: #extract [exec]: #exec [request]: #request diff --git a/internal_testsuites/golang/testsuite/render_templates_test/render_templates_test.go b/internal_testsuites/golang/testsuite/render_templates_test/render_templates_test.go index da3252768b..015768eb92 100644 --- a/internal_testsuites/golang/testsuite/render_templates_test/render_templates_test.go +++ b/internal_testsuites/golang/testsuite/render_templates_test/render_templates_test.go @@ -56,7 +56,7 @@ def run(plan): endpoint = "/" + filePath, ) response = plan.wait(recipe=get_recipe, field="code", assertion="==", target_value=200, service_name="file-server") - plan.assert(response["body"], "==", expected_contents) + plan.verify(response["body"], "==", expected_contents) ` ) diff --git a/internal_testsuites/golang/testsuite/starlark_exec_test/starlark_exec_test.go b/internal_testsuites/golang/testsuite/starlark_exec_test/starlark_exec_test.go index 971794e2b3..e893ce58f2 100644 --- a/internal_testsuites/golang/testsuite/starlark_exec_test/starlark_exec_test.go +++ b/internal_testsuites/golang/testsuite/starlark_exec_test/starlark_exec_test.go @@ -40,9 +40,9 @@ def run(plan, args): } ) exec_result = plan.exec(recipe=exec_recipe, service_name="test", acceptable_codes=[0], skip_code_check=True) - plan.assert(exec_result["code"], "==", %d) - plan.assert(exec_result["output"], "==", "%s") - plan.assert(exec_result["extract.len"], "==", %d) + plan.verify(exec_result["code"], "==", %d) + plan.verify(exec_result["output"], "==", "%s") + plan.verify(exec_result["extract.len"], "==", %d) ` ) diff --git a/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_test.go b/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_test.go index c0395e8ef2..809a8a6c20 100644 --- a/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_test.go +++ b/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_test.go @@ -43,7 +43,7 @@ def run(plan): ), service_name = SERVICE_NAME_2, ) - plan.assert(connection_result["code"], "==", SUCCESS_CODE) + plan.verify(connection_result["code"], "==", SUCCESS_CODE) test_ip_address_cmd = "nc -zv {0} {1}".format(datastore_1.ip_address, GRPC_PORT) connection_result = plan.exec( @@ -52,7 +52,7 @@ def run(plan): ), service_name = SERVICE_NAME_2, ) - plan.assert(connection_result["code"], "==", SUCCESS_CODE) + plan.verify(connection_result["code"], "==", SUCCESS_CODE) ` ) @@ -72,13 +72,13 @@ Command returned with exit code '0' and the following output: [a-z-0-9]+ \([0-9\.]+:1323\) open -------------------- -Assertion succeeded. Value is '0'. +Verification succeeded. Value is '0'. Command returned with exit code '0' and the following output: -------------------- [0-9\.]+ \([0-9\.]+:1323\) open -------------------- -Assertion succeeded. Value is '0'. +Verification succeeded. Value is '0'. ` require.Nil(t, runResult.InterpretationError, "Unexpected interpretation error.") require.Empty(t, runResult.ValidationErrors, "Unexpected validation error") diff --git a/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_with_ready_conditions_test.go b/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_with_ready_conditions_test.go index 6339e73ba4..7d3a3ce0f9 100644 --- a/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_with_ready_conditions_test.go +++ b/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_service_with_ready_conditions_test.go @@ -54,7 +54,7 @@ func (suite *StartosisAddServiceTestSuite) TestStartosis_AddServiceWithReadyCond runResult, _ := suite.RunScript(ctx, script) t := suite.T() - expectedLastAssertionErrorStr := fmt.Sprintf("Assertion failed '%v' '==' '%v'", okStatusCode, serverErrorStatusCode) + expectedLastAssertionErrorStr := fmt.Sprintf("Verification failed '%v' '==' '%v'", okStatusCode, serverErrorStatusCode) require.Nil(t, runResult.InterpretationError, "Unexpected interpretation error") require.Empty(t, runResult.ValidationErrors, "Unexpected validation error") diff --git a/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_services_with_ready_conditions_test.go b/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_services_with_ready_conditions_test.go index 6963915f6d..efdd4ea3ac 100644 --- a/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_services_with_ready_conditions_test.go +++ b/internal_testsuites/golang/testsuite/startosis_add_service_test/startosis_add_services_with_ready_conditions_test.go @@ -59,7 +59,7 @@ func (suite *StartosisAddServiceTestSuite) TestStartosis_AddServicesWithReadyCon func (suite *StartosisAddServiceTestSuite) TestStartosis_AddServicesWithReadyConditionsCheckFail() { ctx := context.Background() - expectedLastAssertionErrorStr := fmt.Sprintf("Assertion failed '%v' '==' '%v'", okStatusCode, serverErrorStatusCode) + expectedLastAssertionErrorStr := fmt.Sprintf("Verification failed '%v' '==' '%v'", okStatusCode, serverErrorStatusCode) script := fmt.Sprintf(addServicesWithReadyConditionsScript, serverErrorStatusCode, serverErrorStatusCode) runResult, _ := suite.RunScript(ctx, script) diff --git a/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_assert_fail_test.go b/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_assert_fail_test.go index 1304bdb4e7..5f35b383f2 100644 --- a/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_assert_fail_test.go +++ b/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_assert_fail_test.go @@ -24,10 +24,10 @@ def run(plan): } ) response = plan.wait(recipe=get_recipe, field="code", assertion="==", target_value=200, interval="100ms", timeout="30s", service_name="web-server-assert-fail-test") - plan.assert(response["code"], "!=", 200) + plan.verify(response["code"], "!=", 200) # dumb test to validate we can pass 2 runtime values here - plan.assert(response["code"], "==", response["code"]) + plan.verify(response["code"], "==", response["code"]) ` ) diff --git a/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_complex_request_wait_assert_test.go b/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_complex_request_wait_assert_test.go index 0050441d75..ae27a8c83c 100644 --- a/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_complex_request_wait_assert_test.go +++ b/internal_testsuites/golang/testsuite/startosis_request_wait_assert_test/startosis_complex_request_wait_assert_test.go @@ -25,16 +25,16 @@ def run(plan): } ) response = plan.wait(recipe=get_recipe, field="code", assertion="==", target_value=200, interval="10s", timeout="200s", service_name="web-server-complex-request-wait-test") - plan.assert(response["code"], "==", 200) - plan.assert("My test returned " + response["code"], "==", "My test returned 200") - plan.assert(response["code"], "!=", 500) - plan.assert(response["code"], ">=", 200) - plan.assert(response["code"], "<=", 200) - plan.assert(response["code"], "<", 300) - plan.assert(response["code"], ">", 100) - plan.assert(response["code"], "IN", [100, 200]) - plan.assert(response["code"], "NOT_IN", [100, 300]) - plan.assert(response["extract.exploded-slash"], "==", "bar") + plan.verify(response["code"], "==", 200) + plan.verify("My test returned " + response["code"], "==", "My test returned 200") + plan.verify(response["code"], "!=", 500) + plan.verify(response["code"], ">=", 200) + plan.verify(response["code"], "<=", 200) + plan.verify(response["code"], "<", 300) + plan.verify(response["code"], ">", 100) + plan.verify(response["code"], "IN", [100, 200]) + plan.verify(response["code"], "NOT_IN", [100, 300]) + plan.verify(response["extract.exploded-slash"], "==", "bar") post_recipe = PostHttpRequestRecipe( port_id = "http-port", endpoint = "/", @@ -47,9 +47,9 @@ def run(plan): ) plan.wait(recipe=post_recipe, field="code", assertion="==", target_value=200, service_name="web-server-complex-request-wait-test") post_response = plan.request(recipe=post_recipe, service_name="web-server-complex-request-wait-test") - plan.assert(post_response["code"], "==", 200) - plan.assert(post_response["extract.my-content-type"], "==", "text/plain") - plan.assert(post_response["extract.my-body"], "==", "bar") + plan.verify(post_response["code"], "==", 200) + plan.verify(post_response["extract.my-content-type"], "==", "text/plain") + plan.verify(post_response["extract.my-body"], "==", "bar") post_recipe_no_body = PostHttpRequestRecipe( port_id = "http-port", endpoint = "/", @@ -59,12 +59,12 @@ def run(plan): } ) post_recipe_no_body_output = plan.wait(recipe=post_recipe_no_body, field="code", assertion="==", target_value=200, service_name = "web-server-complex-request-wait-test") - plan.assert(post_recipe_no_body_output["extract.my-content-type"], "==", "application/json") + plan.verify(post_recipe_no_body_output["extract.my-content-type"], "==", "application/json") exec_recipe = ExecRecipe( command = ["echo", "hello", post_response["extract.my-body"]] ) exec_result = plan.wait(recipe=exec_recipe, field="code", assertion="==", target_value=0, service_name="web-server-complex-request-wait-test") - plan.assert(exec_result["output"], "==", "hello bar\n") + plan.verify(exec_result["output"], "==", "hello bar\n") # content_type default to application/json post_json = PostHttpRequestRecipe( @@ -76,7 +76,7 @@ def run(plan): } ) post_json_response = plan.request(recipe = post_json, service_name = "web-server-complex-request-wait-test") - plan.assert(post_json_response["extract.my-json"], "==", '{"a":"b"}') + plan.verify(post_json_response["extract.my-json"], "==", '{"a":"b"}') ` ) diff --git a/internal_testsuites/golang/testsuite/startosis_run_sh_task_test/run_task_sh_task_test.go b/internal_testsuites/golang/testsuite/startosis_run_sh_task_test/run_task_sh_task_test.go index fe2f3ffcf1..1a33a9ee08 100644 --- a/internal_testsuites/golang/testsuite/startosis_run_sh_task_test/run_task_sh_task_test.go +++ b/internal_testsuites/golang/testsuite/startosis_run_sh_task_test/run_task_sh_task_test.go @@ -13,28 +13,28 @@ const ( def run(plan): result1 = plan.run_sh(run="echo kurtosis") result2 = plan.run_sh(run="mkdir -p /src/{0} && cd /src/{0} && echo $(pwd)".format(result1.output)) - plan.assert(result2.output, "==", "/src/kurtosis\n") + plan.verify(result2.output, "==", "/src/kurtosis\n") ` runshStarlarkFileArtifact = ` def run(plan): result = plan.run_sh(run="mkdir -p /src && echo kurtosis > /src/tech.txt", store=["/src/tech.txt", "/src"], image="ethpandaops/ethereum-genesis-generator:1.0.14") file_artifacts = result.files_artifacts result2 = plan.run_sh(run="cat /temp/tech.txt", files={"/temp": file_artifacts[0]}) - plan.assert(result2.output, "==", "kurtosis\n") + plan.verify(result2.output, "==", "kurtosis\n") result3 = plan.run_sh(run="cat /task/src/tech.txt", files={"/task": file_artifacts[1]}) - plan.assert(result3.output, "==", "kurtosis\n") + plan.verify(result3.output, "==", "kurtosis\n") ` runshStarlarkFileArtifactFailure = ` def run(plan): result = plan.run_sh(run="cat /tmp/kurtosis.txt") - plan.assert(value=result.code, assertion="==", target_value="0") + plan.verify(value=result.code, assertion="==", target_value="0") ` runshStarlarkWithTimeout = ` def run(plan): result = plan.run_sh(run="sleep 45s", wait="30s") - plan.assert(value=result.code, assertion="==", target_value="0") + plan.verify(value=result.code, assertion="==", target_value="0") ` runshStarlarkIgnoreParentDir = ` @@ -42,21 +42,21 @@ def run(plan): result1 = plan.run_sh(run="mkdir -p /src/data && echo kurtosis > /src/data/kurtosis.txt",store=["/src/*"]) files_artifacts = result1.files_artifacts result2 = plan.run_sh(files={"/temp": files_artifacts[0]}, run="cat /temp/data/kurtosis.txt") - plan.assert(result2.output, "==", "kurtosis\n") + plan.verify(result2.output, "==", "kurtosis\n") ` ) func TestStarlark_RunshTaskSimple(t *testing.T) { ctx := context.Background() runResult, _ := test_helpers.SetupSimpleEnclaveAndRunScript(t, ctx, runshTest, runshStarlarkSimple) - expectedOutput := "Command returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nCommand returned with exit code '0' and the following output:\n--------------------\n/src/kurtosis\n\n--------------------\nAssertion succeeded. Value is '\"/src/kurtosis\\n\"'.\n" + expectedOutput := "Command returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nCommand returned with exit code '0' and the following output:\n--------------------\n/src/kurtosis\n\n--------------------\nVerification succeeded. Value is '\"/src/kurtosis\\n\"'.\n" require.Equal(t, expectedOutput, string(runResult.RunOutput)) } func TestStarlark_RunshTaskFileArtifact(t *testing.T) { ctx := context.Background() runResult, _ := test_helpers.SetupSimpleEnclaveAndRunScript(t, ctx, runshTest, runshStarlarkFileArtifact) - expectedOutput := "Command returned with exit code '0' with no output\nCommand returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nAssertion succeeded. Value is '\"kurtosis\\n\"'.\nCommand returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nAssertion succeeded. Value is '\"kurtosis\\n\"'.\n" + expectedOutput := "Command returned with exit code '0' with no output\nCommand returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nVerification succeeded. Value is '\"kurtosis\\n\"'.\nCommand returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nVerification succeeded. Value is '\"kurtosis\\n\"'.\n" require.Equal(t, expectedOutput, string(runResult.RunOutput)) } @@ -79,6 +79,6 @@ func TestStarlark_RunshTimesoutSuccess(t *testing.T) { func TestStarlark_RunshFileArtifactWithoutParentDir(t *testing.T) { ctx := context.Background() runResult, _ := test_helpers.SetupSimpleEnclaveAndRunScript(t, ctx, runshTest, runshStarlarkIgnoreParentDir) - expectedOutput := "Command returned with exit code '0' with no output\nCommand returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nAssertion succeeded. Value is '\"kurtosis\\n\"'.\n" + expectedOutput := "Command returned with exit code '0' with no output\nCommand returned with exit code '0' and the following output:\n--------------------\nkurtosis\n\n--------------------\nVerification succeeded. Value is '\"kurtosis\\n\"'.\n" require.Equal(t, expectedOutput, string(runResult.RunOutput)) } diff --git a/internal_testsuites/starlark/ci_tests/startosis_simple_script.star b/internal_testsuites/starlark/ci_tests/startosis_simple_script.star index 1eeeac8335..f68f50421a 100644 --- a/internal_testsuites/starlark/ci_tests/startosis_simple_script.star +++ b/internal_testsuites/starlark/ci_tests/startosis_simple_script.star @@ -5,7 +5,7 @@ DATASTORE_PORT_NUMBER = 1323 DATASTORE_PORT_PROTOCOL = "TCP" def run(plan, args): - plan.assert(str(args), "==", "{}") + plan.verify(str(args), "==", "{}") plan.print("Adding service " + DATASTORE_SERVICE_NAME + ".") config = ServiceConfig( diff --git a/internal_testsuites/starlark/upload-file-package/main.star b/internal_testsuites/starlark/upload-file-package/main.star index b5f09653fc..1f3c8a5975 100644 --- a/internal_testsuites/starlark/upload-file-package/main.star +++ b/internal_testsuites/starlark/upload-file-package/main.star @@ -24,7 +24,7 @@ def run(plan, args): ) expected_file_hash = args["file_hash"] - plan.assert( + plan.verify( value=result["output"], assertion="==", target_value=expected_file_hash,