Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def make_dsn(httpserver, auth="uiaeosnrtdy", id=123456):
# after a timeout of 2 seconds, falling back to the ipv4 loopback instead.
host = url.netloc.replace("localhost", "127.0.0.1")
return urllib.parse.urlunsplit(
(url.scheme, "{}@{}".format(auth, host), url.path, url.query, url.fragment,)
(
url.scheme,
"{}@{}".format(auth, host),
url.path,
url.query,
url.fragment,
)
)


Expand Down Expand Up @@ -230,4 +236,7 @@ def deserialize(

def __repr__(self):
# type: (...) -> str
return "<Item headers=%r payload=%r>" % (self.headers, self.payload,)
return "<Item headers=%r payload=%r>" % (
self.headers,
self.payload,
)
4 changes: 3 additions & 1 deletion tests/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def assert_meta(envelope, release="test-example-release", integration=None):
expected_sdk = {
"name": "sentry.native",
"version": "0.4.12",
"packages": [{"name": "github:getsentry/sentry-native", "version": "0.4.12"},],
"packages": [
{"name": "github:getsentry/sentry-native", "version": "0.4.12"},
],
}
if not is_android:
if sys.platform == "win32":
Expand Down
8 changes: 7 additions & 1 deletion tests/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ def destroy(self):
]
if len(coverage_dirs) > 0:
subprocess.run(
["kcov", "--clean", "--merge", coveragedir, *coverage_dirs,]
[
"kcov",
"--clean",
"--merge",
coveragedir,
*coverage_dirs,
]
)


Expand Down
6 changes: 3 additions & 3 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
black==19.10b0
pytest==5.4.1
pytest-httpserver==1.0.0
black==21.9b0
pytest==6.2.5
pytest-httpserver==1.0.1
5 changes: 4 additions & 1 deletion tests/test_integration_crashpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def test_crashpad_crash_after_shutdown(cmake, httpserver):

with httpserver.wait(timeout=10) as waiting:
child = run(
tmp_path, "sentry_example", ["log", "crash-after-shutdown"], env=env,
tmp_path,
"sentry_example",
["log", "crash-after-shutdown"],
env=env,
)
assert child.returncode # well, its a crash after all

Expand Down
94 changes: 72 additions & 22 deletions tests/test_integration_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def test_capture_http(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"})

httpserver.expect_oneshot_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver), SENTRY_RELEASE="🤮🚀")

Expand All @@ -55,7 +56,8 @@ def test_session_http(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -68,7 +70,11 @@ def test_session_http(cmake, httpserver):
env=env,
)
run(
tmp_path, "sentry_example", ["log", "start-session"], check=True, env=env,
tmp_path,
"sentry_example",
["log", "start-session"],
check=True,
env=env,
)

assert len(httpserver.log) == 1
Expand All @@ -82,7 +88,8 @@ def test_capture_and_session_http(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand Down Expand Up @@ -110,7 +117,8 @@ def test_exception_and_session_http(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -137,10 +145,14 @@ def test_exception_and_session_http(cmake, httpserver):

@pytest.mark.skipif(not has_files, reason="test needs a local filesystem")
def test_abnormal_session(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"},)
tmp_path = cmake(
["sentry_example"],
{"SENTRY_BACKEND": "none"},
)

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -166,7 +178,11 @@ def test_abnormal_session(cmake, httpserver):
session_file.write(session)

run(
tmp_path, "sentry_example", ["log", "no-setup"], check=True, env=env,
tmp_path,
"sentry_example",
["log", "no-setup"],
check=True,
env=env,
)

assert len(httpserver.log) == 2
Expand All @@ -186,7 +202,8 @@ def test_inproc_crash_http(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "inproc"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -199,7 +216,11 @@ def test_inproc_crash_http(cmake, httpserver):
assert child.returncode # well, its a crash after all

run(
tmp_path, "sentry_example", ["log", "no-setup"], check=True, env=env,
tmp_path,
"sentry_example",
["log", "no-setup"],
check=True,
env=env,
)

assert len(httpserver.log) == 1
Expand All @@ -219,14 +240,24 @@ def test_inproc_reinstall(cmake, httpserver):

env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))
httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")

child = run(tmp_path, "sentry_example", ["log", "reinstall", "crash"], env=env,)
child = run(
tmp_path,
"sentry_example",
["log", "reinstall", "crash"],
env=env,
)
assert child.returncode # well, its a crash after all

run(
tmp_path, "sentry_example", ["log", "no-setup"], check=True, env=env,
tmp_path,
"sentry_example",
["log", "no-setup"],
check=True,
env=env,
)

assert len(httpserver.log) == 1
Expand All @@ -236,7 +267,8 @@ def test_inproc_dump_inflight(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "inproc"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -256,7 +288,8 @@ def test_breakpad_crash_http(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "breakpad"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -269,7 +302,11 @@ def test_breakpad_crash_http(cmake, httpserver):
assert child.returncode # well, its a crash after all

run(
tmp_path, "sentry_example", ["log", "no-setup"], check=True, env=env,
tmp_path,
"sentry_example",
["log", "no-setup"],
check=True,
env=env,
)

assert len(httpserver.log) == 1
Expand All @@ -290,14 +327,24 @@ def test_breakpad_reinstall(cmake, httpserver):

env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))
httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")

child = run(tmp_path, "sentry_example", ["log", "reinstall", "crash"], env=env,)
child = run(
tmp_path,
"sentry_example",
["log", "reinstall", "crash"],
env=env,
)
assert child.returncode # well, its a crash after all

run(
tmp_path, "sentry_example", ["log", "no-setup"], check=True, env=env,
tmp_path,
"sentry_example",
["log", "no-setup"],
check=True,
env=env,
)

assert len(httpserver.log) == 1
Expand All @@ -308,7 +355,8 @@ def test_breakpad_dump_inflight(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "breakpad"})

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand Down Expand Up @@ -339,7 +387,8 @@ def delayed(req):
return "{}"

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_handler(delayed)
env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver))

Expand All @@ -357,7 +406,8 @@ def delayed(req):
httpserver.clear_log()

httpserver.expect_request(
"/api/123456/envelope/", headers={"x-sentry-auth": auth_header},
"/api/123456/envelope/",
headers={"x-sentry-auth": auth_header},
).respond_with_data("OK")

run(tmp_path, "sentry_example", ["log", "no-setup"], check=True, env=env)
Expand Down
15 changes: 11 additions & 4 deletions tests/test_integration_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

def test_capture_stdout(cmake):
tmp_path = cmake(
["sentry_example"], {"SENTRY_BACKEND": "none", "SENTRY_TRANSPORT": "none",},
["sentry_example"],
{
"SENTRY_BACKEND": "none",
"SENTRY_TRANSPORT": "none",
},
)

output = check_output(
Expand All @@ -43,7 +47,8 @@ def test_multi_process(cmake):
# NOTE: It would have been nice to do *everything* in a unicode-named
# directory, but apparently cmake does not like that either.
tmp_path = cmake(
["sentry_example"], {"SENTRY_BACKEND": "none", "SENTRY_TRANSPORT": "none"},
["sentry_example"],
{"SENTRY_BACKEND": "none", "SENTRY_TRANSPORT": "none"},
)

cwd = tmp_path.joinpath("unicode ❤️ Юля")
Expand Down Expand Up @@ -86,7 +91,8 @@ def test_multi_process(cmake):

def test_inproc_crash_stdout(cmake):
tmp_path = cmake(
["sentry_example"], {"SENTRY_BACKEND": "inproc", "SENTRY_TRANSPORT": "none"},
["sentry_example"],
{"SENTRY_BACKEND": "inproc", "SENTRY_TRANSPORT": "none"},
)

child = run(tmp_path, "sentry_example", ["attachment", "crash"])
Expand All @@ -112,7 +118,8 @@ def test_inproc_crash_stdout(cmake):
@pytest.mark.skipif(not has_breakpad, reason="test needs breakpad backend")
def test_breakpad_crash_stdout(cmake):
tmp_path = cmake(
["sentry_example"], {"SENTRY_BACKEND": "breakpad", "SENTRY_TRANSPORT": "none"},
["sentry_example"],
{"SENTRY_BACKEND": "breakpad", "SENTRY_TRANSPORT": "none"},
)

child = run(tmp_path, "sentry_example", ["attachment", "crash"])
Expand Down