Skip to content

Commit 014bd29

Browse files
Merge pull request #1 from StuartWheater/v6.1-dev_dsdanger
V6.1 dev dsdanger
2 parents ca5273b + b642bd3 commit 014bd29

6 files changed

Lines changed: 209 additions & 47 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
^LICENSE.md$
55
^azure-pipelines\.yml$
66
^azure-pipelines_site\.pp$
7+
^azure-pipelines_site-dsdanger\.pp$
78
^azure-pipelines_check\.Rout$
89
^azure-pipelines_test\.Rout$
910
^checkDocumentationUpdated\.sh$

azure-pipelines.yml

Lines changed: 133 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ resources:
4242
endpoint: datashield-testing
4343
name: datashield/testStatus
4444
ref: master
45-
45+
4646
- repository: datashield-infrastructureRepo
4747
type: github
4848
endpoint: datashield-testing
49-
name: datashield/datashield-infrastructure
50-
ref: v6.1-dev
49+
name: StuartWheater/datashield-infrastructure
50+
ref: v6.1-dev_dsdanger
5151

5252

5353
#########################################################################################
@@ -123,15 +123,18 @@ jobs:
123123
# Install R and all the dependencies dsBaseClient requires.
124124
# If previous steps have failed then don't run.
125125
- bash: |
126-
126+
127127
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
128128
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/"
129129
sudo apt-get update
130-
130+
131131
sudo apt-get install -qq libxml2-dev libcurl4-openssl-dev libssl-dev libgsl-dev r-base -y
132132
sudo R -q -e "install.packages(c('devtools','metafor','fields','covr'), dependencies=TRUE, repos='https://cloud.r-project.org')"
133133
sudo R -q -e "install.packages(c('DSI','DSOpal','DSLite'), dependencies=TRUE, repos='https://cloud.r-project.org')"
134134
135+
# XML grep for coverage report merging
136+
sudo apt-get install -qq xml-twig-tools -y
137+
135138
displayName: 'Install all dependencies for dsBaseClient'
136139
condition: succeeded()
137140
@@ -157,10 +160,10 @@ jobs:
157160
echo "Run devtools::document() locally then commit again."
158161
exit 1
159162
else
160-
echo "Documentation up to date."
161-
exit 0
163+
echo "Documentation up to date."
164+
exit 0
162165
fi
163-
166+
164167
workingDirectory: $(Pipeline.Workspace)/dsBaseClient
165168
displayName: 'Check manual updated before being committed'
166169
condition: succeeded()
@@ -172,7 +175,7 @@ jobs:
172175
# If previous steps have failed then don't run.
173176
# If this step fails still mark as failed, but don't stop the rest of the steps running.
174177
- bash: |
175-
178+
176179
R -q -e "library('devtools'); devtools::check(args = c('--no-examples'))" | tee azure-pipelines_check.Rout
177180
grep --quiet "^0 errors" azure-pipelines_check.Rout && grep --quiet " 0 warnings" azure-pipelines_check.Rout && grep --quiet " 0 notes" azure-pipelines_check.Rout
178181
@@ -186,7 +189,7 @@ jobs:
186189
# Install dsBase. This uses the datashield-infrastructure repo (and its dependencies) to do the install with puppet.
187190
# If previous steps have failed then don't run.
188191
- bash: |
189-
192+
190193
# Set up puppet and r10k
191194
wget -nv https://apt.puppetlabs.com/puppet5-release-xenial.deb
192195
sudo dpkg -i puppet5-release-xenial.deb
@@ -196,11 +199,11 @@ jobs:
196199
197200
sudo apt-get install puppet-agent -y
198201
sudo /opt/puppetlabs/puppet/bin/gem install r10k
199-
202+
200203
pushd puppet/environments/datashield_azurepipelines
201204
sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install
202205
popd
203-
206+
204207
sudo /opt/puppetlabs/bin/puppet apply $(Pipeline.Workspace)/dsBaseClient/azure-pipelines_site.pp --environment datashield_azurepipelines --environmentpath puppet/environments
205208
206209
workingDirectory: $(Pipeline.Workspace)/datashield-infrastructure
@@ -216,24 +219,99 @@ jobs:
216219
# TODO: Tidy up variable names - use timestamps here.
217220
# TODO: Why is DSLite needed for this to run?!
218221
- bash: |
219-
222+
220223
# There is an issue with the way we are using packages. The wrapped up test command
221224
# below fails in a way that implies that it is not installed. I cannot figure out
222225
# why this is case. As a work around we can run some of the functions below. My
223226
# best guess is that there is an implicit build or similar that happens. Although
224227
# I cannot replicate that directly with build etc directly.
225-
228+
226229
# None of the below make the tests run
227230
#sudo R -e 'devtools::reload(".")'
228231
#sudo R -e 'library(dsBaseClient)'
229232
#sudo R -e 'devtools::check_built()'
230233
#sudo R --verbose -e 'devtools::build()'
231-
234+
232235
# Any of the below makes the tests work.
233236
#sudo R --verbose -e 'devtools::test()'
234237
#sudo R --verbose -e 'devtools::install()'
235238
sudo R --verbose -e 'devtools::check()'
236-
239+
240+
pwd
241+
mkdir $(Pipeline.Workspace)/logs
242+
243+
# run the coverage tool and output to coveragelist.csv
244+
# testthat::testpackage uses a MultiReporter, comprised of a ProgressReporter and JunitReporter
245+
# R output and messages are redirected by sink() to test_console_output.txt
246+
# junit reporter output is to test_results.xml
247+
#
248+
# "_-|arg-|smk-|datachk-|disc-|math-|expt-|expt_smk-"
249+
sudo R -q -e '
250+
library(covr);
251+
dsbase.res <- covr::package_coverage(
252+
type = c("none"),
253+
code = c(
254+
'"'"'
255+
library(testthat);
256+
output_file <- file("test_console_output_dsbase.txt");
257+
sink(output_file);
258+
sink(output_file, type = "message");
259+
library(testthat);
260+
junit_rep <- JunitReporter$new(file = "test_results_dsbase.xml");
261+
progress_rep <- ProgressReporter$new(max_failures = 999999);
262+
multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
263+
testthat::test_package("$(projectName)", filter = "_-", reporter = multi_rep, stop_on_failure = FALSE)
264+
'"'"'
265+
)
266+
);
267+
base::saveRDS(dsbase.res, "test_results_dsbase.rds")'
268+
269+
# display the test console output
270+
cat test_console_output_dsbase.txt
271+
272+
grep --quiet "Failed: 0" test_console_output_dsbase.txt
273+
274+
workingDirectory: $(Pipeline.Workspace)/dsBaseClient
275+
displayName: 'Code coverage and JUnit report output, with dsBase'
276+
condition: succeeded()
277+
278+
279+
#####################################################################################
280+
# Install dsDanger on server
281+
# If previous steps have failed then don't run
282+
- bash: |
283+
284+
sudo /opt/puppetlabs/bin/puppet apply $(Pipeline.Workspace)/dsBaseClient/azure-pipelines_site-dsdanger.pp --environment datashield_azurepipelines --environmentpath puppet/environments
285+
286+
workingDirectory: $(Pipeline.Workspace)/datashield-infrastructure
287+
displayName: 'Install dsDanger DataSHIELD package on server'
288+
condition: succeeded()
289+
290+
291+
#####################################################################################
292+
# Install dsDangerClient.
293+
# If previous steps have failed then don't run
294+
- bash: |
295+
296+
sudo R -q -e 'devtools::install()'
297+
sudo R -q -e "library('devtools'); devtools::install_github(repo='datashield/dsDangerClient', ref='v6.1-dev', dependencies = TRUE)"
298+
299+
workingDirectory: $(Pipeline.Workspace)/dsBaseClient
300+
displayName: 'Install dsDangerClient DataSHIELD package'
301+
condition: succeeded()
302+
303+
304+
#####################################################################################
305+
# Essentially run devtools::test() on the checked out code. This is wrapped up with
306+
# code coverage. The actual command is vary convoluted as it had to do some things
307+
# which are not default behaviour: output the results to a JUnit xml file, not stop
308+
# when a small number of errors have happened, run through the code coverage tool.
309+
# TODO: Tidy up variable names - use timestamps here.
310+
- bash: |
311+
312+
# See, 'Code coverage and JUnit report output' for issues with the approach and improvement needed.
313+
sudo R --verbose -e 'devtools::check()'
314+
237315
pwd
238316
mkdir $(Pipeline.Workspace)/logs
239317
@@ -243,35 +321,50 @@ jobs:
243321
# junit reporter output is to test_results.xml
244322
sudo R -q -e '
245323
library(covr);
324+
dsdanger.res <- covr::package_coverage(
325+
type = c("none"),
326+
code = c(
327+
'"'"'
328+
library(testthat);
329+
output_file <- file("test_console_output_dsdanger.txt");
330+
sink(output_file);
331+
sink(output_file, type = "message");
332+
library(testthat);
333+
junit_rep <- JunitReporter$new(file = "test_results_dsdanger.xml");
334+
progress_rep <- ProgressReporter$new(max_failures = 999999);
335+
multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
336+
testthat::test_package("$(projectName)", filter = "smk_dgr-",reporter = multi_rep, stop_on_failure = FALSE)
337+
'"'"'
338+
)
339+
);
340+
base::saveRDS(dsdanger.res, "test_results_dsdanger.rds")'
341+
342+
# Merge coverage results
343+
cat test_results_dsbase.txt test_results_dsdanger.txt > $(Pipeline.Workspace)/logs/test_console_output.txt
344+
xml_grep --pretty_print indented --wrap "testsuites" --descr "" --cond "testsuite" test_results_dsbase.xml test_results_dsdanger.xml > test_results.xml
345+
346+
# Create 'coveragelist.csv'
347+
sudo R -q -e '
348+
library(covr);
349+
dsbase.res <- base::readRDS("test_results_dsbase.rds")
350+
dsdanger.res <- base::readRDS("test_results_dsdanger.rds")
246351
write.csv(
247-
coverage_to_list(
248-
covr::package_coverage(
249-
type = c("none"),
250-
code = c(
251-
'"'"'library(testthat);
252-
output_file <- file("test_console_output.txt");
253-
sink(output_file);
254-
sink(output_file, type = "message");
255-
library(testthat);
256-
junit_rep <- JunitReporter$new(file = "test_results.xml");
257-
progress_rep <- ProgressReporter$new(max_failures = 999999);
258-
multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
259-
testthat::test_package("$(projectName)", filter = "$(test_filter)",reporter = multi_rep, stop_on_failure = FALSE)'"'"')
260-
)
261-
),
262-
"coveragelist.csv"
263-
)'
264-
352+
coverage_to_list(
353+
c(dsbase.res, dsdanger.res)
354+
"coveragelist.csv"
355+
)
356+
)'
357+
265358
# display the test console output
266-
cat test_console_output.txt
359+
cat test_console_output_dsdanger.txt
360+
267361
mv coveragelist.csv $(Pipeline.Workspace)/logs
268362
mv test_results.xml $(Pipeline.Workspace)/logs
269-
mv test_console_output.txt $(Pipeline.Workspace)/logs
270-
271-
grep --quiet "Failed: 0" $(Pipeline.Workspace)/logs/test_console_output.txt
363+
364+
grep --quiet "Failed: 0" test_console_output_dsdanger.txt
272365
273366
workingDirectory: $(Pipeline.Workspace)/dsBaseClient
274-
displayName: 'Code coverage and JUnit report output'
367+
displayName: 'Code coverage and JUnit report output, with dsBase and dsDanger'
275368
condition: succeeded()
276369
277370
@@ -280,7 +373,7 @@ jobs:
280373
# echo them so finding bugs should be easier.
281374
# This should run even if previous steps have failed.
282375
- bash: |
283-
376+
284377
# Strip out when error and failure = 0 and count the number of times it does not.
285378
issue_count=$(sed 's/failures="0" errors="0"//' test_results.xml | grep --count errors=)
286379
echo "Number of testsuites with issues: "$issue_count

azure-pipelines_site-dsdanger.pp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Datashield for Azure Pipelines testing.
2+
#
3+
# Install mysql and mongodb, include test data but don't install the firewall.
4+
# This is an example please change to meet the needs of your install. Consider changing any passwords in this file!
5+
#
6+
7+
class { ::datashield:
8+
opal_password => 'datashield_test&',
9+
opal_password_hash => '$shiro1$SHA-256$500000$gcnVxdEmOjaN+NfsK/1NsA==$UOobbhJsBBojnbsfzIBX9GTWjWQFi8aJZxFvFKmOiSE=',
10+
11+
test_data => true, # Install the test data
12+
firewall => false, # Do not install the firewall
13+
mysql => true, # Install mysql server
14+
mongodb => true, # Install mongodb server
15+
remote_mongodb => false, # There is not a remote mongodb server
16+
remote_mysql => false, # There is not a remote mysql server
17+
18+
dsbase_githubusername => 'datashield',
19+
dsbase_ref => 'v6.1-dev',
20+
dsdanger_githubusername => 'datashield',
21+
dsdanger_ref => 'v6.1-dev'
22+
}

azure-pipelines_site.pp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
dsbase_githubusername => 'datashield',
1919
dsbase_ref => 'v6.1-dev',
20-
dsstats_githubusername => 'datashield',
21-
dsstats_ref => '',
22-
dsgraphics_githubusername => 'datashield',
23-
dsgraphics_ref => '',
24-
dsmodelling_githubusername => 'datashield',
25-
dsmodelling_ref => ''
20+
dsdanger_githubusername => 'datashield',
21+
dsdanger_ref => ''
2622
}

tests/testthat/setup.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Datashield test suite set up
1212
#
1313

14-
context("setup")
14+
context("setup - start")
1515

1616
library(lme4)
1717
library(e1071)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2018-2020 University of Newcastle upon Tyne. All rights reserved.
3+
#
4+
# This program and the accompanying materials
5+
# are made available under the terms of the GNU Public License v3.0.
6+
#
7+
# You should have received a copy of the GNU General Public License
8+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
#-------------------------------------------------------------------------------
10+
11+
#
12+
# Set up
13+
#
14+
15+
context("ds.asCharacter::smk_dgr::setup")
16+
17+
require(dsDangerClient)
18+
19+
connect.studies.dataset.cnsim(list("LAB_TSC"))
20+
21+
test_that("setup", {
22+
ds_expect_variables(c("D"))
23+
})
24+
25+
#
26+
# Tests
27+
#
28+
29+
context("ds.asCharacter::smk_dgr::simple test")
30+
test_that("simple test", {
31+
res <- ds.asCharacter("D$LAB_TSC")
32+
33+
expect_equal(length(res), 2)
34+
expect_equal(res$is.object.created, "A data object <ascharacter.newobj> has been created in all specified data sources")
35+
expect_equal(res$validity.check, "<ascharacter.newobj> appears valid in all sources")
36+
})
37+
38+
#
39+
# Done
40+
#
41+
42+
context("ds.asCharacter::smk_dgr::stutdown")
43+
44+
test_that("setup", {
45+
ds_expect_variables(c("D", "ascharacter.newobj"))
46+
})
47+
48+
disconnect.studies.dataset.cnsim()
49+
50+
context("ds.asCharacter::smk_dgr::done")

0 commit comments

Comments
 (0)