Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gathercmd test step #115

Merged
merged 1 commit into from
Jul 29, 2022
Merged

Conversation

mimir-d
Copy link
Member

@mimir-d mimir-d commented Jul 28, 2022

  • this is a gather type plugin, holds onto all targets and runs the
    given command once; returns a framework error if the command fails
  • add to contest generator and server

testing:

  • server with resume
> go run . --adminServerAddr "" --resumeJobs --pauseTimeout 10s
[...]
[2022-07-28T22:15:10.605+01:00 D localsetup.go:176] Running command: /usr/bin/sleep 60m attempt=%!s(uint32=0)   job_id=11       run_id=1        step_index=0  step_label=setup
  • contestcli
> go run . start -w < ./descriptors/start-literal.json

with

"Steps": [
    {
        "name": "localsetup",
        "label": "setup",
        "parameters": {
            "binary": [
                "sleep"
            ],
            "args": [
                "60m"
            ]
        }
    }
]

Also tested successful setup, failing setup, canceled while running command.

@mimir-d mimir-d force-pushed the fea/localsetup_step branch 3 times, most recently from 06d59f2 to f4acb36 Compare July 28, 2022 21:53
@mimir-d
Copy link
Member Author

mimir-d commented Jul 28, 2022

last push changes the event model; instead of emitting the same event on all input targets, just use the first one. This makes it more clear that the setup only ran once, instead of per target.

@mimir-d
Copy link
Member Author

mimir-d commented Jul 28, 2022

todo: add teardown equivalent after #83 is merged. When that happens, anything created by the setup will be uniquely identifier thru output vars and the teardown can act on those artifacts exactly.

xaionaro
xaionaro previously approved these changes Jul 29, 2022
xaionaro
xaionaro previously approved these changes Jul 29, 2022
tfg13
tfg13 previously approved these changes Jul 29, 2022
Copy link
Collaborator

@tfg13 tfg13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name this something like GatherCmd to make it a bit more clear what it does.

LGTM, the only thing is the obvious RCE, which we already discussed and is the same as with the cmd plugin.

return ts.setParams(params)
}

// New initializes and returns a new Cmd test step.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// New initializes and returns a new Cmd test step.
// New initializes and returns a new localsetup test step.

@mimir-d mimir-d dismissed stale reviews from tfg13 and xaionaro via 9f44253 July 29, 2022 12:32
@mimir-d mimir-d force-pushed the fea/localsetup_step branch from cae4e70 to 9f44253 Compare July 29, 2022 12:32
@mimir-d
Copy link
Member Author

mimir-d commented Jul 29, 2022

would name this something like GatherCmd

you know.. that's a good point. I was thinking of adding another local_teardown plugin, but it's not different than this one. I should rename to GatherCmd

xaionaro
xaionaro previously approved these changes Jul 29, 2022
- this is a gather type plugin, holds onto all targets and runs the
  given command once; returns a framework error if the command fails
- add to contest generator and server

Signed-off-by: mimir-d <[email protected]>
@mimir-d
Copy link
Member Author

mimir-d commented Jul 29, 2022

renamed to GatherCmd

test with false

  • out status
{
 "ServerID": "fedora-pc1c0jta",
 "Data": {
  "Status": {
   "Name": "test job",
   "State": "JobStateFailed",
   "StateErrMsg": "Job 18 failed after 32.86962ms: exit status 1",
   "StartTime": "2022-07-29T12:39:30Z",
   "EndTime": "2022-07-29T12:39:30Z",
   "RunStatus": {
    "JobID": 18,
    "RunID": 1,
    "StartTime": "0001-01-01T00:00:00Z",
[...]
	"TargetStatuses": [
       {
        "JobID": 18,
        "RunID": 1,
        "TestName": "Literal test",
        "TestStepName": "GatherCmd",
        "TestStepLabel": "setup",
        "Target": {
         "ID": "1234"
        },
        "InTime": "2022-07-29T12:39:30Z",
        "OutTime": "2022-07-29T12:39:30Z",
        "Error": "",
        "Events": [
         {
          "SequenceID": 137,
          "EmitTime": "2022-07-29T12:39:30Z",
          "Header": {
           "JobID": 18,
           "RunID": 1,
           "TestName": "Literal test",
           "TestAttempt": 0,
           "TestStepLabel": "setup"
          },
          "Data": {
           "Target": {
            "ID": "1234"
           },
           "EventName": "GatherCmdStart",
           "Payload": {
            "Path": "/usr/bin/false",
            "Args": [
             "/usr/bin/false"
            ]
           }
          }
         },
         {
          "SequenceID": 138,
          "EmitTime": "2022-07-29T12:39:30Z",
          "Header": {
           "JobID": 18,
           "RunID": 1,
           "TestName": "Literal test",
           "TestAttempt": 0,
           "TestStepLabel": "setup"
          },
          "Data": {
           "Target": {
            "ID": "1234"
           },
           "EventName": "GatherCmdEnd",
           "Payload": {
            "ExitCode": 1,
            "Err": "stdout: \nstderr: "
           }
          }
         }
        ]
       },

@mimir-d mimir-d merged commit 0fe8427 into linuxboot:main Jul 29, 2022
@mimir-d mimir-d deleted the fea/localsetup_step branch July 29, 2022 13:55
@mimir-d mimir-d changed the title Add localsetup test step Add gathercmd test step Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants