Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upEmbed target server type #107
Conversation
…storing server type
This reverts commit ce55e8e.
|
Great writeup, Alan. Regarding open questions:
|
| identical(x, y) && (attr(x, "enum_id") == attr(y, "enum_id")) | ||
| } | ||
|
|
||
| enum_count <- rlang::env(n = 0) |
jcheng5
Jun 13, 2019
Member
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)
}
})
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. |
| any(grepl("/shiny.min.js$", srcs)) | ||
| }, error = function(e) FALSE) | ||
|
|
||
| if (nrow(df[which(df$name == "SSP-XSRF"),]) == 1 |
alandipert
Jun 13, 2019
Author
Contributor
Can be: df[df$name == "SSP-XSRF",]
Can be: df[df$name == "SSP-XSRF",]
| 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)) |
alandipert
Jun 13, 2019
Author
Contributor
Should also look for "/shiny.js" because minification can be turned off with an option
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.logproduced byshinyloadtest::record_session()withthese servers is very similar, it's not similar in all cases for us to say
that the
recording.logfile 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,
shinycannonfails 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
shinycannonproduced 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
scripttag with a
srcthat ends withshiny.min.js.recording.logfilebelow 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:
versionis 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.
targetwas renamed totarget_urltarget_typeis 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.shinycannonstill work with old recordings?