Add cancellation support to instance testing
This commit is contained in:
1 parent
910d57795a
commit
289b845876
2 files changed
+21
-15
No files matched your search
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- A bug where instance testing is not immediately cancelled when the testing page is closed
|
||||||
|
|
||||||
## [0.21.2] - 2024-03-10
|
## [0.21.2] - 2024-03-10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
+15
-15
@@ -16,7 +16,7 @@ function InvidiousInstanceTestingTask(input as object) as object
|
|||||||
content = PrepareTests()
|
content = PrepareTests()
|
||||||
listNode.content = content
|
listNode.content = content
|
||||||
|
|
||||||
RunTests(instance, content)
|
RunTests(instance, content, m.top.cancellation)
|
||||||
|
|
||||||
return invalid
|
return invalid
|
||||||
end function
|
end function
|
||||||
@@ -47,14 +47,14 @@ function CreateTestNode(title as string, func as function) as object
|
|||||||
return testNode
|
return testNode
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function RunTests(instance as string, content as object) as void
|
function RunTests(instance as string, content as object, cancellation as object) as void
|
||||||
testNodes = content.getChildren(-1, 0)
|
testNodes = content.getChildren(-1, 0)
|
||||||
|
|
||||||
timer = CreateObject("roTimespan")
|
timer = CreateObject("roTimespan")
|
||||||
|
|
||||||
for each testNode in testNodes
|
for each testNode in testNodes
|
||||||
timer.Mark()
|
timer.Mark()
|
||||||
m[testNode.func](instance, testNode)
|
m[testNode.func](instance, testNode, cancellation)
|
||||||
|
|
||||||
testNode.duration = timer.TotalMilliseconds()
|
testNode.duration = timer.TotalMilliseconds()
|
||||||
testNode.title = `${testNode.title} (${testNode.duration}ms)`
|
testNode.title = `${testNode.title} (${testNode.duration}ms)`
|
||||||
@@ -69,7 +69,7 @@ function RunTests(instance as string, content as object) as void
|
|||||||
end for
|
end for
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function IsValidUrl(instance as string, testNode as object) as void
|
function IsValidUrl(instance as string, testNode as object, cancellation as object) as void
|
||||||
try
|
try
|
||||||
if not instance.StartsWith("http://") and not instance.StartsWith("https://")
|
if not instance.StartsWith("http://") and not instance.StartsWith("https://")
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
@@ -90,10 +90,10 @@ function IsValidUrl(instance as string, testNode as object) as void
|
|||||||
end try
|
end try
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function IsReachable(instance as string, testNode as object) as void
|
function IsReachable(instance as string, testNode as object, cancellation as object) as void
|
||||||
try
|
try
|
||||||
url = `${instance}${Invidious.STATS_ENDPOINT}`
|
url = `${instance}${Invidious.STATS_ENDPOINT}`
|
||||||
response = HttpClient.Get(url).NoCache().Await()
|
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
testNode.details = response.ErrorMessage()
|
testNode.details = response.ErrorMessage()
|
||||||
@@ -137,11 +137,11 @@ function IsReachable(instance as string, testNode as object) as void
|
|||||||
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CanFetchVideoDetails(instance as string, testNode as object) as void
|
function CanFetchVideoDetails(instance as string, testNode as object, cancellation as object) as void
|
||||||
try
|
try
|
||||||
videoId = "jNQXAC9IVRw"
|
videoId = "jNQXAC9IVRw"
|
||||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||||
response = HttpClient.Get(url).NoCache().Await()
|
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||||
|
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
@@ -171,11 +171,11 @@ function CanFetchVideoDetails(instance as string, testNode as object) as void
|
|||||||
end try
|
end try
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CanFetchVideoComments(instance as string, testNode as object) as void
|
function CanFetchVideoComments(instance as string, testNode as object, cancellation as object) as void
|
||||||
try
|
try
|
||||||
videoId = "jNQXAC9IVRw"
|
videoId = "jNQXAC9IVRw"
|
||||||
url = `${instance}/api/v1/comments/${videoId}`
|
url = `${instance}/api/v1/comments/${videoId}`
|
||||||
response = HttpClient.Get(url).NoCache().Await()
|
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||||
|
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
@@ -212,12 +212,12 @@ function CanFetchVideoComments(instance as string, testNode as object) as void
|
|||||||
end try
|
end try
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CanFetchVideoCaptions(instance as string, testNode as object) as void
|
function CanFetchVideoCaptions(instance as string, testNode as object, cancellation as object) as void
|
||||||
try
|
try
|
||||||
videoId = "jNQXAC9IVRw"
|
videoId = "jNQXAC9IVRw"
|
||||||
label = "English"
|
label = "English"
|
||||||
url = `${instance}/api/v1/captions/${videoId}?label=${label}`
|
url = `${instance}/api/v1/captions/${videoId}?label=${label}`
|
||||||
response = HttpClient.Get(url).NoCache().Await()
|
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||||
|
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
@@ -254,11 +254,11 @@ function CanFetchVideoCaptions(instance as string, testNode as object) as void
|
|||||||
end try
|
end try
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CanFetchVideoThumbails(instance as string, testNode as object) as void
|
function CanFetchVideoThumbails(instance as string, testNode as object, cancellation as object) as void
|
||||||
try
|
try
|
||||||
videoId = "jNQXAC9IVRw"
|
videoId = "jNQXAC9IVRw"
|
||||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||||
response = HttpClient.Get(url).NoCache().Await()
|
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||||
|
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
@@ -290,7 +290,7 @@ function CanFetchVideoThumbails(instance as string, testNode as object) as void
|
|||||||
|
|
||||||
' Note: we could do a HEAD request, but Invidious returns 200 even for invalid thumbnails
|
' Note: we could do a HEAD request, but Invidious returns 200 even for invalid thumbnails
|
||||||
' To make sure we don't get a 200 for an invalid thumbnail, we do a GET request instead
|
' To make sure we don't get a 200 for an invalid thumbnail, we do a GET request instead
|
||||||
response = HttpClient.Get(thumbnail).NoCache().Await()
|
response = HttpClient.Get(thumbnail).NoCache().Cancellation(cancellation).Await()
|
||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
testNode.state = "failed"
|
testNode.state = "failed"
|
||||||
testNode.details = `${thumbnail} is not reachable\n${response.ErrorMessage(false)}`
|
testNode.details = `${thumbnail} is not reachable\n${response.ErrorMessage(false)}`
|
||||||
|
|||||||
Reference in new issue
Block a user