Skip to content

Commit 7956b20

Browse files
authored
Add web to smoke-test, with and without dev certs (#539)
* Add web to smoke-test, with and without dev certs * Only reset caches when a test will run Avoid conflicting with a hanging process if there's no need to delete the files anyway.
1 parent c7012bc commit 7956b20

File tree

2 files changed

+129
-44
lines changed

2 files changed

+129
-44
lines changed

netci.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ def addBuildStepsAndSetMachineAffinity(def job, String os, String configuration)
1313
}
1414
else {
1515
shell("git submodule update --init --recursive");
16-
shell("./build.sh /p:Configuration=${configuration} ${loggingOptions}")
17-
shell("./smoke-test.sh --minimal --projectOutput --configuration ${configuration}")
16+
shell("./build.sh /p:Configuration=${configuration} ${loggingOptions}");
17+
smokeTestExcludes = "";
18+
if (os == "Fedora24" || os == "OSX10.12") {
19+
// Dev certs doesn't seem to work in these platforms. https://github.com/dotnet/source-build/issues/560
20+
smokeTestExcludes += " --excludeWebHttpsTests";
21+
}
22+
shell("./smoke-test.sh --minimal --projectOutput --configuration ${configuration} ${smokeTestExcludes}");
1823
}
1924
};
2025
};

smoke-test.sh

Lines changed: 122 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,40 @@ set -euo pipefail
44
SCRIPT_ROOT="$(cd -P "$( dirname "$0" )" && pwd)"
55
TARBALL_PREFIX=dotnet-sdk-
66
VERSION_PREFIX=2.1
7+
DEV_CERTS_VERSION_DEFAULT=2.1.0
78

89
projectOutput=false
910
keepProjects=false
1011
dotnetDir=""
1112
configuration="Release"
13+
excludeNonWebTests=false
1214
excludeWebTests=false
15+
excludeWebNoHttpsTests=false
16+
excludeWebHttpsTests=false
1317
excludeLocalTests=false
1418
excludeOnlineTests=false
19+
devCertsVersion="$DEV_CERTS_VERSION_DEFAULT"
1520
testingDir="$SCRIPT_ROOT/testing-smoke"
1621
cliDir="$testingDir/builtCli"
1722
logFile="$testingDir/smoke-test.log"
1823
restoredPackagesDir="$testingDir/packages"
24+
testingHome="$testingDir/home"
1925

2026
function usage() {
2127
echo ""
2228
echo "usage:"
23-
echo " --dotnetDir the directory from which to run dotnet"
24-
echo " --configuration the configuration being tested (default=Release)"
25-
echo " --projectOutput echo dotnet's output to console"
26-
echo " --keepProjects keep projects after tests are complete"
27-
echo " --minimal run minimal set of tests - local sources only, no web"
28-
echo " --excludeWebTests don't run tests for web projects"
29-
echo " --excludeLocalTests exclude tests that use local sources for nuget packages"
30-
echo " --excludeOnlineTests exclude test that use online sources for nuget packages"
29+
echo " --dotnetDir the directory from which to run dotnet"
30+
echo " --configuration the configuration being tested (default=Release)"
31+
echo " --projectOutput echo dotnet's output to console"
32+
echo " --keepProjects keep projects after tests are complete"
33+
echo " --minimal run minimal set of tests - local sources only, no web"
34+
echo " --excludeNonWebTests don't run tests for non-web projects"
35+
echo " --excludeWebTests don't run tests for web projects"
36+
echo " --excludeWebNoHttpsTests don't run web project tests with --no-https"
37+
echo " --excludeWebHttpsTests don't run web project tests with https using dotnet-dev-certs"
38+
echo " --excludeLocalTests exclude tests that use local sources for nuget packages"
39+
echo " --excludeOnlineTests exclude test that use online sources for nuget packages"
40+
echo " --devCertsVersion <version> use dotnet-dev-certs <version> instead of default $DEV_CERTS_VERSION_DEFAULT"
3141
echo ""
3242
}
3343

@@ -57,18 +67,30 @@ while :; do
5767
keepProjects=true
5868
;;
5969
--minimal)
60-
excludeWebTests=true
6170
excludeOnlineTests=true
6271
;;
72+
--excludenonwebtests)
73+
excludeNonWebTests=true
74+
;;
6375
--excludewebtests)
6476
excludeWebTests=true
6577
;;
78+
--excludewebnohttpstests)
79+
excludeWebNoHttpsTests=true
80+
;;
81+
--excludewebhttpstests)
82+
excludeWebHttpsTests=true
83+
;;
6684
--excludelocaltests)
6785
excludeLocalTests=true
6886
;;
6987
--excludeonlinetests)
7088
excludeOnlineTests=true
7189
;;
90+
--devcertsversion)
91+
shift
92+
devCertsVersion="$1"
93+
;;
7294
*)
7395
usage
7496
exit 1
@@ -90,6 +112,24 @@ function doCommand() {
90112
mkdir "${lang}_${proj}"
91113
cd "${lang}_${proj}"
92114

115+
newArgs="new $proj -lang $lang"
116+
117+
while :; do
118+
if [ $# -le 0 ]; then
119+
break
120+
fi
121+
case "$1" in
122+
--new-arg)
123+
shift
124+
newArgs="$newArgs $1"
125+
;;
126+
*)
127+
break
128+
;;
129+
esac
130+
shift
131+
done
132+
93133
while :; do
94134
if [ $# -le 0 ]; then
95135
break
@@ -99,9 +139,9 @@ function doCommand() {
99139

100140
if [ "$1" == "new" ]; then
101141
if [ "$projectOutput" == "true" ]; then
102-
"${dotnetCmd}" new $proj -lang $lang | tee -a "$logFile"
142+
"${dotnetCmd}" $newArgs | tee -a "$logFile"
103143
else
104-
"${dotnetCmd}" new $proj -lang $lang >> "$logFile" 2>&1
144+
"${dotnetCmd}" $newArgs >> "$logFile" 2>&1
105145
fi
106146
elif [[ "$1" == "run" && "$proj" =~ ^(web|mvc|webapi|razor)$ ]]; then
107147
if [ "$projectOutput" == "true" ]; then
@@ -110,12 +150,20 @@ function doCommand() {
110150
"${dotnetCmd}" $1 >> "$logFile" 2>&1 &
111151
fi
112152
webPid=$!
113-
echo " waiting 20 seconds for web project with pid $webPid"
114-
sleep 20
115-
echo " sending SIGINT to $webPid"
116-
pkill -SIGINT -P $webPid
153+
killCommand="pkill -SIGTERM -P $webPid"
154+
echo " waiting up to 20 seconds for web project with pid $webPid..."
155+
echo " to clean up manually after an interactive cancellation, run: $killCommand"
156+
for seconds in $(seq 20); do
157+
if [ "$(tail -n 1 "$logFile")" = 'Application started. Press Ctrl+C to shut down.' ]; then
158+
echo " app ready for shutdown after $seconds seconds"
159+
break
160+
fi
161+
sleep 1
162+
done
163+
echo " stopping $webPid" | tee -a "$logFile"
164+
$killCommand
117165
wait $!
118-
echo " terminated with exit code $?"
166+
echo " terminated with exit code $?" | tee -a "$logFile"
119167
else
120168
if [ "$projectOutput" == "true" ]; then
121169
"${dotnetCmd}" $1 | tee -a "$logFile"
@@ -141,35 +189,68 @@ function doCommand() {
141189
echo "finished language $lang, type $proj" | tee -a smoke-test.log
142190
}
143191

192+
function setupDevCerts() {
193+
echo "Setting up dotnet-dev-certs $devCertsVersion to generate dev certificate" | tee -a "$logFile"
194+
(
195+
set -x
196+
"$dotnetDir/dotnet" tool install -g dotnet-dev-certs --version "$devCertsVersion" --add-source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
197+
export DOTNET_ROOT="$dotnetDir"
198+
"$testingHome/.dotnet/tools/dotnet-dev-certs" https
199+
) >> "$logFile" 2>&1
200+
}
201+
144202
function runAllTests() {
145203
# Run tests for each language and template
146-
doCommand C# console new restore run
147-
doCommand C# classlib new restore build
148-
doCommand C# xunit new restore test
149-
doCommand C# mstest new restore test
150-
151-
doCommand VB console new restore run
152-
doCommand VB classlib new restore build
153-
doCommand VB xunit new restore test
154-
doCommand VB mstest new restore test
155-
156-
doCommand F# console new restore run
157-
doCommand F# classlib new restore build
158-
doCommand F# xunit new restore test
159-
doCommand F# mstest new restore test
160-
204+
if [ "$excludeNonWebTests" == "false" ]; then
205+
doCommand C# console new restore run
206+
doCommand C# classlib new restore build
207+
doCommand C# xunit new restore test
208+
doCommand C# mstest new restore test
209+
210+
doCommand VB console new restore run
211+
doCommand VB classlib new restore build
212+
doCommand VB xunit new restore test
213+
doCommand VB mstest new restore test
214+
215+
doCommand F# console new restore run
216+
doCommand F# classlib new restore build
217+
doCommand F# xunit new restore test
218+
doCommand F# mstest new restore test
219+
fi
220+
161221
if [ "$excludeWebTests" == "false" ]; then
162-
doCommand C# web new restore run
163-
doCommand C# mvc new restore run
164-
doCommand C# webapi new restore run
165-
doCommand C# razor new restore run
166-
167-
doCommand F# web new restore run
168-
doCommand F# mvc new restore run
169-
doCommand F# webapi new restore run
222+
if [ "$excludeWebNoHttpsTests" == "false" ]; then
223+
runWebTests --new-arg --no-https
224+
fi
225+
226+
if [ "$excludeWebHttpsTests" == "false" ]; then
227+
setupDevCerts
228+
runWebTests
229+
fi
170230
fi
171231
}
172232

233+
function runWebTests() {
234+
doCommand C# web "$@" new restore run
235+
doCommand C# mvc "$@" new restore run
236+
doCommand C# webapi "$@" new restore run
237+
doCommand C# razor "$@" new restore run
238+
239+
doCommand F# web "$@" new restore run
240+
doCommand F# mvc "$@" new restore run
241+
doCommand F# webapi "$@" new restore run
242+
}
243+
244+
function resetCaches() {
245+
rm -rf "$testingHome"
246+
mkdir "$testingHome"
247+
248+
HOME="$testingHome"
249+
250+
# clean restore path
251+
rm -rf "$restoredPackagesDir"
252+
}
253+
173254
function setupProdConFeed() {
174255
sed -i.bakProdCon "s|PRODUCT_CONTRUCTION_PACKAGES|$prodConFeedUrl|g" "$testingDir/NuGet.Config"
175256
}
@@ -207,6 +288,7 @@ prodConFeedUrl="$(cat "$SCRIPT_ROOT/ProdConFeed.txt")"
207288

208289
# Run all tests, local restore sources first, online restore sources second
209290
if [ "$excludeLocalTests" == "false" ]; then
291+
resetCaches
210292
# Setup NuGet.Config with local restore source
211293
if [ -e "$SCRIPT_ROOT/smoke-testNuGet.Config" ]; then
212294
cp "$SCRIPT_ROOT/smoke-testNuGet.Config" "$testingDir/NuGet.Config"
@@ -220,10 +302,8 @@ if [ "$excludeLocalTests" == "false" ]; then
220302
echo "LOCAL RESTORE SOURCE - ALL TESTS PASSED!"
221303
fi
222304

223-
# clean restore path
224-
rm -rf "$restoredPackagesDir"
225-
226305
if [ "$excludeOnlineTests" == "false" ]; then
306+
resetCaches
227307
# Setup NuGet.Config to use online restore sources
228308
if [ -e "$SCRIPT_ROOT/smoke-testNuGet.Config" ]; then
229309
cp "$SCRIPT_ROOT/smoke-testNuGet.Config" "$testingDir/NuGet.Config"

0 commit comments

Comments
 (0)