Skip to content

Commit

Permalink
[antlir2_vm] buck part to dump eth0 traffic
Browse files Browse the repository at this point in the history
Summary:
Add a `dump_eth0` attribute to `vm_test` rule that default to the
value of `antlir2.dump_eth0`.

To enable dumping eth0 traffic, one can either use:
```
buck2 test -c antlir2.dump_eth0=1 fbcode//target
```

Test Plan:
```
buck2 test -c antlir2.dump_eth0=1  $(kerctl vmtest-config -e everstore:GICWmAACj33BEzsFAElJ4glD5YhXbuYfAAAf) fbcode//kernel/vmtest/uname_test:uname_test-6.9-local

https://www.internalfb.com/intern/testinfra/testconsole/testrun/14073748886890638/

$ fbcode/tae/testx/scripts/testx artifacts  list 14073748886890638 2> /dev/null | jq .
{
  "run_id": 14073748886890638,
  "test_artifacts": [
    {
      "test_id": 562950104331417,
      "artifacts": [
        {
          "name": "env.txt",
          "handle": "GJgHgRYNVvd5xQ8DAKkPZjWrrZsubswMAAAz",
          "artifact_path": "/tmp/testx-20240927-154852.992554/14073748886890638/562950104331417/env.txt",
          "annotation_path": "/tmp/testx-20240927-154852.992554/14073748886890638/562950104331417/env.txt.annotations"
        },
        {
          "name": "console.txt",
          "handle": "GH7YNRUw2kXZ084BAJMIS-TOtfsJbswMAAAz",
          "artifact_path": "/tmp/testx-20240927-154852.992554/14073748886890638/562950104331417/console.txt",
          "annotation_path": "/tmp/testx-20240927-154852.992554/14073748886890638/562950104331417/console.txt.annotations"
        },
        {
          "name": "eth0.pcap",
          "handle": "GL6PRhZ3OjpwF_oDAJUP8NSoSj9nbswMAABa",
          "artifact_path": "/tmp/testx-20240927-154852.992554/14073748886890638/562950104331417/eth0.pcap",
          "annotation_path": "/tmp/testx-20240927-154852.992554/14073748886890638/562950104331417/eth0.pcap.annotations"
        }
      ]
    }
  ]
}

buck2 test   $(kerctl vmtest-config -e everstore:GICWmAACj33BEzsFAElJ4glD5YhXbuYfAAAf) fbcode//kernel/vmtest/uname_test:uname_test-6.9-local

https://www.internalfb.com/intern/testinfra/testrun/10414574189962407

$ fbcode/tae/testx/scripts/testx artifacts  list 10414574189962407 2> /dev/null | jq .
{
  "run_id": 10414574189962407,
  "test_artifacts": [
    {
      "test_id": 562950104331417,
      "artifacts": [
        {
          "name": "env.txt",
          "handle": "GLibJQ8xunWZy-sCANZQGewLE3xFbswMAAAz",
          "artifact_path": "/tmp/testx-20240927-155040.778857/10414574189962407/562950104331417/env.txt",
          "annotation_path": "/tmp/testx-20240927-155040.778857/10414574189962407/562950104331417/env.txt.annotations"
        },
        {
          "name": "console.txt",
          "handle": "GNBRRBZay_ponBIJAFPO18ttZcxkbswMAAAz",
          "artifact_path": "/tmp/testx-20240927-155040.778857/10414574189962407/562950104331417/console.txt",
          "annotation_path": "/tmp/testx-20240927-155040.778857/10414574189962407/562950104331417/console.txt.annotations"
        }
      ]
    }
  ]
}
```

Reviewed By: wujj123456

Differential Revision: D63567998

fbshipit-source-id: 22fa78b41cb4c294d71589d5688f8214ceb6a7f7
  • Loading branch information
chantra authored and facebook-github-bot committed Sep 30, 2024
1 parent c7c8d04 commit c955386
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions antlir/antlir2/antlir2_vm/bzl/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
test_cmd = cmd_args(test_cmd, "--expect-failure")
if ctx.attrs.postmortem:
test_cmd = cmd_args(test_cmd, "--postmortem")
if ctx.attrs.dump_eth0:
test_cmd = cmd_args(test_cmd, "--dump-eth0-traffic")

test_cmd = cmd_args(
test_cmd,
ctx.attrs.test[ExternalRunnerTestInfo].test_type,
Expand Down Expand Up @@ -109,6 +112,10 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
_vm_test = rule(
impl = _impl,
attrs = {
"dump_eth0": attrs.bool(
doc = "If true, dumps the vm's eth0 traffic to a file. The file location is dictated by testX and uploaded as part of test result",
default = bool(read_config("antlir2", "dump_eth0", False)),
),
"expect_failure": attrs.bool(
doc = "If true, VM is expected to timeout or fail early.",
),
Expand Down

0 comments on commit c955386

Please sign in to comment.