-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed target server type #107
Conversation
…storing server type
This reverts commit ce55e8e.
Great writeup, Alan. Regarding open questions:
|
R/enum.R
Outdated
identical(x, y) && (attr(x, "enum_id") == attr(y, "enum_id")) | ||
} | ||
|
||
enum_count <- rlang::env(n = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's generally not a good idea to have top-level package variables that are objects created by other packages. At shinyloadtest install time, this rlang::env
object will be serialized, but then rlang could be upgraded at a later date and then you could have a mismatch.
Maybe something like this instead:
enum_counter <- local({
n <- 0L
function() {
(n <<- n + 1L)
}
})
We'll probably need to walk through this PR in person, it's a bit much for me to digest without guidance. |
R/detect.R
Outdated
any(grepl("/shiny.min.js$", srcs)) | ||
}, error = function(e) FALSE) | ||
|
||
if (nrow(df[which(df$name == "SSP-XSRF"),]) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be: df[df$name == "SSP-XSRF",]
R/detect.R
Outdated
scripts <- xml2::xml_find_all(html, "/html/head/script") | ||
srcs <- unlist(lapply(scripts, function(script) xml2::xml_attr(script, "src"))) | ||
srcs <- srcs[!is.na(srcs)] | ||
any(grepl("/shiny.min.js$", srcs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also look for "/shiny.js" because minification can be turned off with an option
…ed with (#36) Corresponds to rstudio/shinyloadtest#107
Motivation
shinyloadtest supports recording and playing back sessions against a variety of
target server types, including RStudio Connect, Shiny Server and Shiny Server
Pro, and the "default" server run out of an R console session with
shiny::runApp()
.While the
recording.log
produced byshinyloadtest::record_session()
withthese servers is very similar, it's not similar in all cases for us to say
that the
recording.log
file is server-type agnostic. We have documented thislimitation in the past but we do not explicitly disallow it in
software.
Currently, if a user attempts to play a recording back against a different
server,
shinycannon
fails with an obscure error that will not indicate thedisparity. For example, below is what currently happens when a recording made
against a local R server is played back against an app in Connect:
We can imagine a user wasting a lot of time debugging the above problem before
realizing they simply need to make a new recording against the different target
server.
It would be good if
shinycannon
produced a warning or error message if itdetected the target server differs from the type used to create the recording.
Initial Implementation Idea
The following things are true of the software in its current state:
not included in
recording.log
.errors/exits early if so
when the app requires authentication
requires authentication
So, at least the following enhancements are necessary:
extended so that it can distinguish reliably between RSC, SSP/SSO, R/Shiny
(IDE/R console), and shinyapps.io.
assumes "yes".
and store that type in the recording file.
message/warning/error
Actual Implementation
of application. Applications are considered R/Shiny if they don't appear
to be RSC/SSP/SSO/shinyapps.io but the initial HTML includes a
script
tag with a
src
that ends withshiny.min.js
.recording.log
filebelow for details.
Detect.kt
Recording Format Changes
Previously, the first few lines of a recording looked like this:
Now, the first few lines look like this:
version
is not a semantic version number that could be thought tocorrespond to a release of shinyloadtest. Instead, it is an independent
version specific to the recording format. Its semantics are defined by its
interpretation by shinycannon.
target
was renamed totarget_url
target_type
is introduced.With this PR, shinycannon errors and exits when the recording format is old.
Whether or not to support the old recording format is an open question.
New behavior
shinyloadtest
Previously, if shinyloadtest didn't detect RSC or SSO/SSP, it would assume
R/Shiny and behave like a blind proxy, generating a log of traffic for any
arbitrary HTTP/WS app.
Now, the following kind of thing happens:
New unrelated behaviors
There were a few opportunities to make some low-risk improvements unrelated to this feature while I was working in shinyloadtest, so I took the liberty.
shinycannon
After these changes, shinycannon behaves in the following new ways (assuming the
recording is "new format"):
The following error is produced and shinycannon exits 1:
version
> 1:The following error is produced and shinycannon exits 1:
Shalu and Alan discussed whether or not shinycannon should error/exit here
instead of warn, and decided warning is better because the detection heuristics
are not perfect.
The following error is produced and shinycannon exits 1:
Open Questions
shinyloadtest::record_session()
attempt to continue if the type ofthe target server can't be detected?
with a complex setup or operating under weird circumstances that defeat
our detection would want these tools to work regardless.
accidentally using a recording against the wrong type of server and being
flummoxed by errors
record_session()
could produce awarning message and encode a server type of "Unknown"/
SERVER_TYPE$UNK
.shinycannon
still work with old recordings?