From 9109cac2d3063ac82775a80747a4a5f96737d536 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 28 Feb 2024 12:59:29 -0500 Subject: [PATCH] add exec task type --- .../server/startosis_engine/plan.yml | 14 +++++ .../startosis_engine/plan_yaml_generator.go | 1 + .../plan_yaml_generator_test.go | 57 ++++--------------- 3 files changed, 27 insertions(+), 45 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/plan.yml b/core/server/api_container/server/startosis_engine/plan.yml index e69de29bb2..51207e05bd 100644 --- a/core/server/api_container/server/startosis_engine/plan.yml +++ b/core/server/api_container/server/startosis_engine/plan.yml @@ -0,0 +1,14 @@ +packageId: github.com/kurtosis-tech/plan-yaml-prac + +services: +- name: database + uuid: 1 + image: + name: postgres:latest +- name: tedi + uuid: 2 + image: + name: ubuntu:latest + envVars: + - key: DB_URL + value: '{{ kurtosis.4.ip_address }}' \ No newline at end of file diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go index 0316161b98..13183e7fbf 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator.go @@ -687,6 +687,7 @@ func (pyg *PlanYamlGeneratorImpl) updatePlanYamlFromExec(execInstruction *instru } task = &Task{ //nolint:exhaustruct ServiceName: serviceNameArgumentValue.GoString(), + TaskType: EXEC, } execRecipe, err := builtin_argument.ExtractArgumentValue[*recipe.ExecRecipe](arguments, exec.RecipeArgName) diff --git a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go index 43dea1bd37..2bffcdaf9f 100644 --- a/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go +++ b/core/server/api_container/server/startosis_engine/plan_yaml_generator_test.go @@ -102,37 +102,6 @@ func (suite *PlanYamlGeneratorTestSuite) TearDownTest() { suite.packageContentProvider.RemoveAll() } -func (suite *PlanYamlGeneratorTestSuite) TestFullExecution() { - packageId := "github.com/kurtosis-tech/plan-yaml-prac" - mainFunctionName := "" - relativePathToMainFile := "main.star" - - serializedScript := `def run(plan, args): - plan.add_service( - name="db", - config=ServiceConfig( - image="postgres:alpine", - env_vars = { - "POSTGRES_DB": "tedi", - "POSTGRES_USER": "tedi", - "POSTGRES_PASSWORD": "tedi", - } - ) - ) - - result = plan.exec( - service_name = "db", - recipe = ExecRecipe(command = ["echo", "Hello, world"]), - acceptable_codes=[156], - ) - plan.print(result) -` - serializedJsonParams := "{}" - _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) - require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 3, instructionsPlan.Size()) -} - func (suite *PlanYamlGeneratorTestSuite) TestCurrentlyBeingWorkedOn() { dockerfileModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server/Dockerfile" serverModulePath := "github.com/kurtosis-tech/plan-yaml-prac/server" @@ -168,29 +137,27 @@ CMD ["node", "app.js"] relativePathToMainFile := "main.star" serializedScript := `def run(plan, args): - plan.add_service( - name="db", + database = plan.add_service( + name="database", config=ServiceConfig( - image="postgres:alpine", - env_vars = { - "POSTGRES_DB": "tedi", - "POSTGRES_USER": "tedi", - "POSTGRES_PASSWORD": "tedi", - } + image="postgres:latest", ) ) - result = plan.exec( - service_name = "db", - recipe = ExecRecipe(command = ["echo", "Hello, world"]), - acceptable_codes=[156], + plan.add_service( + name="tedi", + config=ServiceConfig( + image="ubuntu:latest", + env_vars={ + "DB_URL": database.ip_address + }, + ) ) - plan.print(result) ` serializedJsonParams := "{}" _, instructionsPlan, interpretationError := suite.interpreter.Interpret(context.Background(), packageId, mainFunctionName, noPackageReplaceOptions, relativePathToMainFile, serializedScript, serializedJsonParams, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask) require.Nil(suite.T(), interpretationError) - require.Equal(suite.T(), 3, instructionsPlan.Size()) + require.Equal(suite.T(), 2, instructionsPlan.Size()) pyg := NewPlanYamlGenerator( instructionsPlan,