Skip to content

Commit 9f76e65

Browse files
Merge branch 'release/0.14.4'
2 parents 5ce39a1 + ca6c059 commit 9f76e65

File tree

6 files changed

+178
-11
lines changed

6 files changed

+178
-11
lines changed

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
check: shellcheck spelling
1+
SHELL=bash
2+
3+
check: shellcheck check-cli spelling
4+
5+
assert_bats:
6+
command -v "bats"
7+
echo "BATS_SUPPORT_HOME=$${BATS_SUPPORT_HOME:?}"
8+
echo "BATS_ASSERT_HOME=$${BATS_ASSERT_HOME:?}"
9+
10+
assert_rstudio:
11+
command -v "rserver"
12+
13+
check-cli: assert_bats assert_rstudio
14+
(cd tests/; PATH="../bin:$${PATH}" bats *.bats)
215

316
shellcheck:
417
(cd bin; \

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## Version 0.14.4 [2024-01-16]
2+
3+
### Bug Fixes
4+
5+
* `rsc start` would generate obscure errors such as `ports.sh: line
6+
15: [[:` and `port4me.bash: line 275: 3: Bad file descriptor`.
7+
This was due to a teeny, but critical bug in **port4me**
8+
0.7.0. Fixed by updating to new **port4me** 0.7.1.
9+
10+
111
## Version 0.14.3 [2024-01-15]
212

313
### New Features

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,20 @@ As before, the RStudio Server is available at
333333
334334
```sh
335335
$ cd /path/to/software
336-
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.14.3.tar.gz
337-
$ tar xf 0.14.3.tar.gz
338-
$ PATH=/path/to/softwarerstudio-server-controller-0.14.3/bin:$PATH
336+
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.14.4.tar.gz
337+
$ tar xf 0.14.4.tar.gz
338+
$ PATH=/path/to/softwarerstudio-server-controller-0.14.4/bin:$PATH
339339
$ export PATH
340340
$ rsc --version
341-
0.14.3
341+
0.14.4
342342
```
343343
344344
To verify that the tool can find R and the RStudio Server executables,
345345
call:
346346
347347
```sh
348348
$ rsc --version --full
349-
rsc: 0.14.3
349+
rsc: 0.14.4
350350
RStudio Server: 2023.06.2+561 (Mountain Hydrangea) for Linux [/path/to/rstudio-server/bin/rstudio-server]
351351
R: 4.3.1 (2023-06-16) -- "Shortstop Beagle" [/path/to/R/bin/R]
352352
```

bin/incl/port4me.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#' Requirements:
3939
#' * Bash (>= 4)
4040
#'
41-
#' Version: 0.7.0
41+
#' Version: 0.7.1
4242
#' Copyright: Henrik Bengtsson (2022-2024)
4343
#' License: MIT
4444
#' Source code: https://github.com/HenrikBengtsson/port4me
@@ -293,11 +293,11 @@ _p4m_lcg_port() {
293293
has_subset=true
294294
fi
295295

296-
if ${PORT4ME_DEBUG}; then
296+
if ${PORT4ME_DEBUG:-false}; then
297297
{
298298
echo "(min,max): ($min,$max)"
299299
echo "subset: [n=${#subset[@]}]"
300-
} >&3
300+
}
301301
fi
302302

303303
## Sample values in [0,m-2] (sic!), but reject until in [min,max],

bin/rsc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
### rsc config --full
6464
### rsc log
6565
###
66-
### Version: 0.14.3
66+
### Version: 0.14.4
6767
### Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
6868
### License: ISC
6969

@@ -298,7 +298,7 @@ function remove_stray_lockfile {
298298
mdebug "remove_stray_lockfile() ..."
299299

300300
## Nothing to do?
301-
[[ ! -f "${lockfile}" ]] || [[ -n "$(rserver_pid true)" ]] || [[ -n "$(rsession_pid true)" ]] || [[ -n "$(ssh_revtunnel_pid true)" ]] && return 0;
301+
[[ ! -f "${lockfile}" ]] || [[ -n "$(rserver_pid true)" ]] || [[ -n "$(rsession_pid true)" ]] || [[ -n "$(ssh_revtunnel_pid true)" ]] && { mdebug "remove_stray_lockfile() ... done"; return 0; }
302302

303303
## Here we know that there's neither a rserver PID nor a rsession PID
304304
rm "${lockfile}"
@@ -398,16 +398,25 @@ function make_rserver_conf {
398398
local workdir
399399
local datadir
400400
local port
401+
402+
mdebug "make_rserver_conf() ..."
403+
401404
workdir=$(config_dir)
402405
assert_dir_exists "${workdir}"
403406
port=${1:?}
407+
mdebug " - workdir=${workdir}"
408+
mdebug " - port=${port}"
404409

405410
datadir=$(rserver_data_dir)
406411

407412
if [[ "${port}" == "port4me" ]]; then
413+
mdebug "port4me() ..."
408414
port=$(PORT4ME_TOOL=rsc port4me 2>&1)
409415
relay_condition "${port}"
416+
mdebug "port4me() ... done"
410417
fi
418+
419+
mdebug "port=${port}"
411420
assert_port_free "${port}"
412421

413422
{
@@ -451,6 +460,8 @@ function make_rserver_conf {
451460
## The web port for the RStudio Server
452461
echo "www-port=${port:?}"
453462
} > "${workdir}/rserver.conf"
463+
464+
mdebug "make_rserver_conf() ... done"
454465
}
455466

456467

@@ -1536,10 +1547,12 @@ term_colors enable
15361547

15371548
## Remove any stray files
15381549
if ! ${force}; then
1550+
mdebug "Removing stray files ..."
15391551
remove_stray_pid_file rserver
15401552
remove_stray_pid_file rsession
15411553
remove_stray_pid_file rserver_monitor
15421554
remove_stray_lockfile
1555+
mdebug "Removing stray files ... done"
15431556
fi
15441557

15451558
if [[ "${action}" == "config" ]]; then
@@ -1709,11 +1722,14 @@ elif [[ "${action}" == "wait" ]]; then
17091722
rserver_hostname
17101723
rserver_port
17111724
elif [[ "${action}" == "start" ]]; then
1725+
mdebug "Assert sufficient software setup ..."
17121726
## Assert executables are available
17131727
assert_executable R
17141728
assert_r
17151729
assert_executable rserver
17161730
assert_executable rsession
1731+
mdebug "Assert sufficient software setup ... done"
1732+
17171733
if [[ "${port}" != "port4me" ]]; then
17181734
assert_port_free "${port}"
17191735
fi
@@ -1729,11 +1745,13 @@ elif [[ "${action}" == "start" ]]; then
17291745
make_config_dir
17301746
acquire_lock_file
17311747

1748+
mdebug "Setup RStudio Server configurations ..."
17321749
make_database_conf
17331750
make_rserver_conf "${port}"
17341751
make_rsession_envs
17351752
make_rsession_sh
17361753
make_rsession_conf
1754+
mdebug "Setup RStudio Server configurations ... done"
17371755

17381756
mdebug "PID for rsc (this process): $$"
17391757

tests/rsc.bats

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/usr/bin/env bats
2+
3+
setup() {
4+
load "${BATS_SUPPORT_HOME:?}/load.bash"
5+
load "${BATS_ASSERT_HOME:?}/load.bash"
6+
7+
path="$(dirname "${BATS_TEST_FILENAME}")"
8+
9+
## Test with a fresh user config and data folder
10+
_RSC_TEST_DIR_=$(mktemp -d)
11+
export _RSC_TEST_DIR_
12+
13+
XDG_CONFIG_HOME=${_RSC_TEST_DIR_}
14+
export XDG_CONFIG_HOME
15+
XDG_DATA_HOME=${_RSC_TEST_DIR_}
16+
export XDG_DATA_HOME
17+
18+
export RSC_AUTH="auth-via-env"
19+
export RSC_PASSWORD="random"
20+
}
21+
22+
teardown() {
23+
rm -rf "${_RSC_TEST_DIR_}"
24+
}
25+
26+
@test "XDG_CONFIG_HOME is a temporary folder" {
27+
run echo "${XDG_CONFIG_HOME:-<not set>}"
28+
assert_success
29+
refute_output --partial "not set"
30+
assert_output --partial "$(dirname "$(mktemp -d)")"
31+
32+
run echo "${XDG_DATA_HOME:-<not set>}"
33+
assert_success
34+
refute_output --partial "not set"
35+
assert_output --partial "$(dirname "$(mktemp -d)")"
36+
}
37+
38+
@test "rsc --version works" {
39+
run rsc --version
40+
assert_success
41+
assert_output --regexp "[[:digit:]]+([.][[:digit:]]+)+(|-[[:digit:]]+)"
42+
}
43+
44+
@test "rsc --version --full works" {
45+
run rsc --version --full
46+
assert_success
47+
assert_output --regexp "rsc: [[:digit:]]+([.][[:digit:]]+)+(|-[[:digit:]]+)"
48+
assert_output --regexp "RStudio Server: "
49+
assert_output --regexp "R: [[:digit:]]+([.][[:digit:]]+)+(|-[[:digit:]]+)"
50+
}
51+
52+
@test "rsc --help works" {
53+
run rsc --help
54+
assert_success
55+
assert_output --partial "rsc"
56+
assert_output --partial "RStudio Server Controller"
57+
assert_output --partial "Usage:"
58+
assert_output --partial "Commands:"
59+
assert_output --partial "Options:"
60+
assert_output --partial "Version:"
61+
assert_output --partial "License:"
62+
}
63+
64+
@test "rsc status works" {
65+
run rsc status
66+
assert_success
67+
assert_output --partial "rserver: "
68+
assert_output --partial "rsession: "
69+
assert_output --partial "rserver monitor: "
70+
assert_output --partial "SSH reverse tunnel (optional): "
71+
assert_output --partial "lock file: "
72+
}
73+
74+
@test "rsc status --full works" {
75+
run rsc status --full
76+
assert_success
77+
assert_output --partial "rserver: "
78+
assert_output --partial "rsession: "
79+
assert_output --partial "rserver monitor: "
80+
assert_output --partial "SSH reverse tunnel (optional): "
81+
assert_output --partial "lock file: "
82+
}
83+
84+
@test "rsc config works" {
85+
run rsc config
86+
assert_success
87+
assert_output --partial "RStudio Server Controller Storage:"
88+
assert_output --partial "RStudio User State Storage:"
89+
assert_output --partial "XDG_CONFIG_HOME=$(dirname "$(mktemp -d)")"
90+
assert_output --partial "XDG_DATA_HOME=$(dirname "$(mktemp -d)")"
91+
}
92+
93+
@test "rsc config --full works" {
94+
run rsc config --full
95+
assert_success
96+
}
97+
98+
@test "rsc log works" {
99+
run rsc log
100+
assert_success
101+
}
102+
103+
@test "rsc reset works" {
104+
run rsc reset
105+
assert_success
106+
}
107+
108+
@test "rsc reset --force works" {
109+
run rsc reset --force
110+
assert_success
111+
}
112+
113+
@test "rsc stop works" {
114+
run rsc stop
115+
assert_success
116+
}
117+
118+
@test "rsc start --debug --dryrun works" {
119+
run rsc start --debug --dryrun 2>&1
120+
assert_failure
121+
assert_output --partial "DRYRUN: rserver --config-file="
122+
assert_output --partial "DRYRUN: rserver_monitor launched"
123+
assert_output --partial "ERROR: It looks like the RStudio Server failed during launch"
124+
assert_output --partial "Shutting down RStudio Server ..."
125+
assert_output --partial "Shutting down RStudio Server ... done"
126+
}

0 commit comments

Comments
 (0)