Skip to content

Commit

Permalink
bug 1746940: add sym debug data to File page
Browse files Browse the repository at this point in the history
This adds the data to the upload_file API and adds the data in a Symbol
File Data section to the File page in the ui.
  • Loading branch information
willkg committed Sep 7, 2023
1 parent 0997218 commit e4ed26d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 18 deletions.
27 changes: 27 additions & 0 deletions frontend/src/Common.js
Expand Up @@ -439,6 +439,33 @@ export const ShowFileMetadata = ({ file }) => (
</table>
);

export const ShowFileSymData = ({ file }) => (
<table className="table is-fullwidth">
<tbody>
<tr>
<th>Debug filename</th>
<td>{file.debug_filename}</td>
</tr>
<tr>
<th>Debug id</th>
<td>{file.debug_id}</td>
</tr>
<tr>
<th>Code file (Windows-only)</th>
<td>{file.code_file}</td>
</tr>
<tr>
<th>Code id (Windows-only)</th>
<td>{file.code_id}</td>
</tr>
<tr>
<th>Generator</th>
<td>{file.generator}</td>
</tr>
</tbody>
</table>
);

const capitalize = (s) => {
return s.charAt(0).toUpperCase() + s.slice(1);
};
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/File.js
Expand Up @@ -10,6 +10,7 @@ import {
Loading,
ShowUploadMetadata,
ShowFileMetadata,
ShowFileSymData,
BooleanIcon,
} from "./Common";
import Fetch from "./Fetch";
Expand Down Expand Up @@ -168,6 +169,13 @@ class DisplayFile extends React.PureComponent {
<h4 className="title is-4">Metadata</h4>
<ShowFileMetadata file={file} />

{file.key.endsWith(".sym") && (
<>
<h4 className="title is-4">Symbol file data</h4>
<ShowFileSymData file={file} />
</>
)}

{file.upload && (
<h4 className="title is-4">
<Link to={`/uploads/upload/${file.upload.id}`}>Upload</Link>
Expand Down
5 changes: 5 additions & 0 deletions tecken/api/views.py
Expand Up @@ -556,6 +556,11 @@ def upload_file(request, id):
"url": url,
"completed_at": file_upload.completed_at,
"created_at": file_upload.created_at,
"debug_filename": file_upload.debug_filename,
"debug_id": file_upload.debug_id,
"code_file": file_upload.code_file,
"code_id": file_upload.code_id,
"generator": file_upload.generator,
"upload": None,
}

Expand Down
56 changes: 43 additions & 13 deletions tecken/tests/test_api.py
Expand Up @@ -776,13 +776,13 @@ def test_upload_files(client, settings):
upload=upload,
size=1234,
bucket_name="other-public",
key="v0/bar.dll/A4FC12EFA5/foo.sym",
key="v1/bar.pdb/46A0ADB3F299A70B4C4C44205044422E1/bar.sym",
)
file_upload2 = FileUpload.objects.create(
size=100,
key="v0/foo.pdb/deadbeef/foo.sym",
compressed=True,
bucket_name="symbols-public",
key="v1/libxul.so/A772CC9A3E852CF48965ED79FB65E3150/libxul.so.sym",
compressed=True,
)

response = client.get(url)
Expand All @@ -792,8 +792,10 @@ def test_upload_files(client, settings):
all_ids = {file_upload1.id, file_upload2.id}
assert {x["id"] for x in data["files"]} == all_ids
assert data["batch_size"] == settings.API_FILES_BATCH_SIZE

# No filters yields BIG_NUMBER total
assert data["total"] == 1000000

# Check the 'upload' which should either be None or a dict
for file_upload in data["files"]:
if file_upload["id"] == file_upload1.id:
Expand Down Expand Up @@ -830,11 +832,13 @@ def test_upload_files(client, settings):
assert [x["id"] for x in data["files"]] == [file_upload1.id]

# Filter by key
response = client.get(url, {"key": "foo.sym"})
response = client.get(url, {"key": "sym"})
assert response.status_code == 200
data = response.json()
assert {x["id"] for x in data["files"]} == all_ids
response = client.get(url, {"key": "foo.sym, deadbeef"})
response = client.get(
url, {"key": "libxul.so.sym, A772CC9A3E852CF48965ED79FB65E3150"}
)
assert response.status_code == 200
data = response.json()
assert [x["id"] for x in data["files"]] == [file_upload2.id]
Expand All @@ -844,6 +848,7 @@ def test_upload_files(client, settings):
assert response.status_code == 200
data = response.json()
assert [x["id"] for x in data["files"]] == [file_upload1.id]

# By negated bucket name
response = client.get(url, {"bucket_name": f"!{file_upload1.bucket_name}"})
assert response.status_code == 200
Expand All @@ -867,13 +872,13 @@ def test_upload_files_count(client):
upload=upload,
size=1234,
bucket_name="symbols-public",
key="v0/bar.dll/A4FC12EFA5/foo.sym",
key="v1/bar.pdb/46A0ADB3F299A70B4C4C44205044422E1/bar.sym",
)
file_upload_2 = FileUpload.objects.create(
size=100,
key="v0/foo.pdb/deadbeef/foo.sym",
compressed=True,
bucket_name="symbols-public",
key="v1/libxul.so/A772CC9A3E852CF48965ED79FB65E3150/libxul.so.sym",
compressed=True,
)

# Fetch uploads with no filters
Expand All @@ -883,7 +888,7 @@ def test_upload_files_count(client):
assert data["files"] == [
{
"id": file_upload_2.id,
"key": "v0/foo.pdb/deadbeef/foo.sym",
"key": "v1/libxul.so/A772CC9A3E852CF48965ED79FB65E3150/libxul.so.sym",
"update": False,
"compressed": True,
"size": 100,
Expand All @@ -894,7 +899,7 @@ def test_upload_files_count(client):
},
{
"id": file_upload_1.id,
"key": "v0/bar.dll/A4FC12EFA5/foo.sym",
"key": "v1/bar.pdb/46A0ADB3F299A70B4C4C44205044422E1/bar.sym",
"update": False,
"compressed": False,
"size": 1234,
Expand Down Expand Up @@ -925,7 +930,7 @@ def test_upload_files_count(client):
"compressed": False,
"created_at": ANY,
"id": file_upload_1.id,
"key": "v0/bar.dll/A4FC12EFA5/foo.sym",
"key": "v1/bar.pdb/46A0ADB3F299A70B4C4C44205044422E1/bar.sym",
"size": 1234,
"update": False,
"upload": {
Expand Down Expand Up @@ -1077,7 +1082,15 @@ def test_file_upload(client):
)
# Also, let's pretend there's at least one file upload
file_upload = FileUpload.objects.create(
upload=upload, size=1234, key="foo.pdb/deadbeaf123/foo.sym"
upload=upload,
size=1234,
bucket_name="other-public",
key="v1/bar.pdb/46A0ADB3F299A70B4C4C44205044422E1/bar.sym",
debug_filename="bar.pdb",
debug_id="46A0ADB3F299A70B4C4C44205044422E1",
code_file="bar.dll",
code_id="64EC878F867C000",
generator="mozilla/dump_syms XYZ",
)
url = reverse("api:upload_file", args=(file_upload.id,))
response = client.get(url)
Expand All @@ -1092,7 +1105,24 @@ def test_file_upload(client):

data = response.json()["file"]
assert data["upload"]["user"]["email"] == user.email
assert data["url"] == "/foo.pdb/deadbeaf123/foo.sym"
assert data["url"] == "/bar.pdb/46A0ADB3F299A70B4C4C44205044422E1/bar.sym"
assert list(sorted(data.keys())) == [
"bucket_name",
"code_file",
"code_id",
"completed_at",
"compressed",
"created_at",
"debug_filename",
"debug_id",
"generator",
"id",
"key",
"size",
"update",
"upload",
"url",
]


@pytest.mark.django_db
Expand Down
11 changes: 6 additions & 5 deletions tecken/upload/management/commands/generate_fake_data.py
Expand Up @@ -88,12 +88,13 @@ def handle(self, *args, **options):
FileUpload(
upload=upload,
bucket_name="publicbucket",
key=f"/{debug_info['debug_filename']}/{debug_info['debug_id']}/{sym_file}",
key=f"v1/{debug_info['debug_filename']}/{debug_info['debug_id']}/{sym_file}",
size=random.randint(1000, 100000),
# debug_filename=debug_info["debug_filename"],
# debug_id=debug_info["debug_id"],
# code_file=debug_info["code_file"],
# code_id=debug_info["code_id"],
debug_filename=debug_info["debug_filename"],
debug_id=debug_info["debug_id"],
code_file=debug_info["code_file"],
code_id=debug_info["code_id"],
generator="generate_fake_data",
)
)
FileUpload.objects.bulk_create(objs)

0 comments on commit e4ed26d

Please sign in to comment.