Skip to content

Commit

Permalink
add exec task type
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Feb 28, 2024
1 parent e85af57 commit 9109cac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 45 deletions.
14 changes: 14 additions & 0 deletions core/server/api_container/server/startosis_engine/plan.yml
Original file line number Diff line number Diff line change
@@ -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 }}'
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9109cac

Please sign in to comment.