Skip to content

Enable debugger for tests on macOS#446

Merged
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
evidolob:add-debugger
Jan 28, 2025
Merged

Enable debugger for tests on macOS#446
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
evidolob:add-debugger

Conversation

@evidolob
Copy link
Copy Markdown
Collaborator

@evidolob evidolob commented Jan 6, 2025

This PR depends on #427

For example of usage look on "DEVELOPMENT.md"

Copy link
Copy Markdown
Collaborator

@cfergeau cfergeau left a comment

Choose a reason for hiding this comment

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

Looks good to me, a few typos in the doc file. This also needs to be rebased.

Copy link
Copy Markdown
Collaborator

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

Is this an equivalent thing of what the debug tests command do in vscode?
Screenshot 2025-01-09 alle 15 16 19

@evidolob
Copy link
Copy Markdown
Collaborator Author

Is this an equivalent thing of what the debug tests command do in vscode?

@lstocchi No, this PR enables ability to debug gvisor binary, which is special build of this project, which we use to test functionality. In short, we build gvisor, run VM, attach gvisor as 'software' network adapter, run tests which execute some commands in VM(via SSH). As code in test are build in gvisor this PR add ability to debug it.

@evidolob
Copy link
Copy Markdown
Collaborator Author

Launch configuration for VSCode:

    {
      "name": "Connect to server",
      "type": "go",
      "request": "attach",
      "mode": "remote",
      "remotePath": "${workspaceFolder}",
      "port": 2345,
      "host": "localhost"
    }

Copy link
Copy Markdown
Collaborator

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

Unfortunately I was not able to still test it on vscode (I only have that). Added some comments in the meantime.


// #nosec
host = exec.Command(filepath.Join(binDir, "gvproxy"), fmt.Sprintf("--ssh-port=%d", sshPort), fmt.Sprintf("--listen=unix://%s", sock), fmt.Sprintf("--listen-vfkit=unixgram://%s", vfkitSock))
_ = os.Remove(vfkitSock)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should remove the _ = os.Remove(sock) and _ = os.Remove(vfkitSock) in favor of clear()

DEVELOPMENT.md Outdated

#### MacOS

You could debug test with [Delve](https://github.com/go-delve/delve) debugger.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we mention that delve should be in $PATH?

Copy link
Copy Markdown
Collaborator

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

Tested on Vscode and worked fine.

Maybe the only other thing I would add is a very short "how to" section for both IJ and Vscode to describe the steps to be done with the configurations.

Very short like
To debug in vscode, create a launch.json with this (copy/paste your configuration), execute make test-mac-debug in a terminal and when you see Listening for remote connections (connections are not authenticated nor encrypted) on the logs, execute the launch attach request. Now your breakpoints will hit.

Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
@evidolob
Copy link
Copy Markdown
Collaborator Author

@lstocchi I have update the doc, with configuration steps for Goland and Vscode

Copy link
Copy Markdown
Collaborator

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

LGTM!! @evidolob great work 🚀

@cfergeau
Copy link
Copy Markdown
Collaborator

/lgtm
/approve
@lstocchi , you should now be able to use the 2 commands above on PRs you want to merge

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Jan 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfergeau, evidolob, lstocchi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [cfergeau,evidolob,lstocchi]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit e635d66 into containers:main Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants