Skip to content

Commit 80f3c4d

Browse files
author
Digital-Larry
authored
CTD-546 add cloning tests to CI (#119)
* CTD-546 added cloning detection to CI * Tweak auto-reg CI some more * More auto reg clone test tweaks... * Trying to fix urge issue after cloning. * More tweak of CI for interactive * Tweak tweak tweak all day long * Addition updates to auto and interactive CI tests * Tweaking default values for hardware ID and CPUID * Yes, another small tweak * Yet another small tweak * Another small one! * Added another test cae * Adding oemGetDefaultHardwareId to connectd_mp_configure, adjust test parameters * Yet another small change * Removed "backup to .prev" when cloning and having to delete those folders when doing a dpkg --purge. * removed unused variable "mac" * Add test case for auto-registration * Added read of MAC from text file for CI * Adding uid and symlink logging to auto reg test console output. * Tweak #43817 * Tweak n+1 * Tweak n+2 * oops * Tweak n+3 * Tweak n+4 * Getting summary from auto-reg-test.sh * tweak # 5 * tweak n + 6 * Add -g to sort command * More summary logic. * Tweake-7 * Add test separator line * Adjust test summary output * show hardware ID after dprov/bprov steps * splitting apart build and test steps for easier review in CircleCI * tweak n+8 * tweak n+9 * tweak n+10 * tweak n+11 * tweak #12 or so * tweak #14 * tweak #15 * tweak #16 * CTD-537 fix search string to validate service names. I accidentally left this out when I updated the string for the password for the same reason. * Error handling in auto-reg-test. Remove unused variables. * Tweak #17 * logic of return code value flipped * Update version string and changelog. * a little debugging code for clone detect API * CI debugging * CI debug * CI adding a couple missing clone test cases * removed extraneous reference to hardware_id in deviceReset() * More error case handling. * tweak # 21 * Getting closer.... * tweak #26 * tweak #27 * Updated version and changelog. * Added sleep 2 prior to counting running services, seems like we are not waiting long enough for services to fully start.
1 parent 3bcbae1 commit 80f3c4d

File tree

13 files changed

+354
-153
lines changed

13 files changed

+354
-153
lines changed

.circleci/config.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ jobs:
4343
- ~/.npm
4444
- ~/.cache
4545
- run:
46-
name: Build binaries
47-
command: npm run build
46+
name: Build amd64 binary and test dpkg install
47+
command: npm run build-one
48+
- run:
49+
name: Run auto-registration test
50+
command: npm run test-auto
51+
- run:
52+
name: Run interactive registration test and test dpkg --purge
53+
command: npm run test-interactive
54+
- run:
55+
name: Build the rest of the binaries
56+
command: npm run build-all
4857
- store_artifacts:
4958
path: ~/project/build

connectd/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: connectd
2-
Version: 2.5.34
2+
Version: 2.5.36
33
Section: non-free/net
44
Priority: optional
55
Homepage: https://remote.it

connectd/DEBIAN/postrm

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,14 @@ cleanFolder()
1818
{
1919
folder=$1
2020
# remove configuration files and folders
21-
if [ -d /etc/connectd$X"$folder" ]; then
22-
for file in /etc/connectd$X"$folder"/*.* ; do
21+
if [ -d /etc/connectd"$folder" ]; then
22+
for file in /etc/connectd"$folder"/*.* ; do
2323
rm -f $file
2424
done
25-
for file in /etc/connectd$X"$folder"/* ; do
25+
for file in /etc/connectd"$folder"/* ; do
2626
rm -f $file
2727
done
28-
rmdir /etc/connectd$X"$folder"
29-
fi
30-
# handle possible backup folders created if there is an auto reg clone.
31-
if [ -d /etc/connectd$X"$folder".prev ]; then
32-
for file in /etc/connectd$X"$folder".prev/*.* ; do
33-
rm -f $file
34-
done
35-
for file in /etc/connectd$X"$folder".prev/* ; do
36-
rm -f $file
37-
done
38-
rmdir /etc/connectd$X"$folder".prev
28+
rmdir /etc/connectd"$folder"
3929
fi
4030
}
4131

connectd/etc/connectd/oem_settings

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111

1212
oemGetSystemId()
1313
{
14-
15-
cpuid=$(awk '/Serial/ {print $3}' /proc/cpuinfo | sed 's/://g')
14+
if [ -e $CONNECTD_DIR/cpuid.txt ]; then
15+
cpuid=$(cat $CONNECTD_DIR/cpuid.txt)
16+
else
17+
cpuid=$(awk '/Serial/ {print $3}' /proc/cpuinfo | sed 's/://g')
1618

1719
##
1820
## Override default system ID for this platform
1921

2022
# check for legal value
21-
if [ ${#cpuid} -ge 1 ]; then
22-
continue
23-
else
24-
cpuid="Issue: system ID is not set properly. Fix oemGetSystemId() in /etc/connectd/oem_settings."
23+
if [ ${#cpuid} -ge 1 ]; then
24+
continue
25+
else
26+
cpuid="Issue: system ID is not set properly. Fix oemGetSystemId() in /etc/connectd/oem_settings."
27+
fi
2528
fi
26-
2729
# return the System ID
2830
echo $cpuid
2931

connectd/usr/bin/connectd_control

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,12 @@ sendDeviceInfo()
806806
cpu=$(oemGetSystemId)
807807
808808
# Default MAC based - OEM platforms may use different identifiers
809-
mac=$(oemGetDefaultHardwareId)
810-
hw_mac=$(oemGetDefaultHardwareId)
809+
# mac=$(oemGetDefaultHardwareId)
810+
if [ -f "$CONNECTD_DIR/ci_mac.txt" ]; then
811+
hw_mac=$(cat $CONNECTD_DIR/ci_mac.txt)
812+
else
813+
hw_mac=$(oemGetDefaultHardwareId)
814+
fi
811815
812816
# hw id is either already saved by OEM or use default
813817
if [ -f "$CONNECTD_DIR/hardware_id.txt" ]; then
@@ -833,10 +837,12 @@ sendDeviceInfo()
833837
# check for Bulk Service already being registered so we can update - authenticatin wiuth secret
834838
if sudo test -f "$DEVICES_AVAILABLE/$bulk_id_code"; then
835839
secret=$(sudo grep password "$DEVICES_AVAILABLE/$bulk_id_code" | tail -1 | awk '{print $2}')
836-
data='{"BulkIdentificationCode" : "'$bulk_id_code'", "HardwareId" : "'$hardware_id'", "MACAddress" : "'$hw_mac'", "CPUId" : "'$cpu'", "OSLabel" : "'$os'", "R3Package" : "'$r3'", "TCPServiceList" : "'$tcp'", "DeviceSecret" : "'$secret'"}'
840+
data='{"BulkIdentificationCode" : "'$bulk_id_code'", "HardwareId" : "'$hwid'", "MACAddress" : "'$hw_mac'", "CPUId" : "'$cpu'", "OSLabel" : "'$os'", "R3Package" : "'$r3'", "TCPServiceList" : "'$tcp'", "DeviceSecret" : "'$secret'"}'
837841
else
838842
data='{"BulkIdentificationCode" : "'$bulk_id_code'", "HardwareId" : "'$hardware_id'", "MACAddress" : "'$hw_mac'", "CPUId" : "'$cpu'", "OSLabel" : "'$os'", "R3Package" : "'$r3'", "TCPServiceList" : "'$tcp'"}'
839843
fi
844+
845+
echo "DEBUG: $data"
840846
841847
resp=$(curl ${CURL_OPTS} POST -H "content-type:application/json" --data "$data" $DeviceInformationURL )
842848
status=$(jsonval "$resp" "status")
@@ -875,6 +881,7 @@ sendDeviceReady()
875881
876882
deviceReset()
877883
{
884+
echo "Clone detected - device reset."
878885
# save the currect bic to restore after reset
879886
sudo mv "$CONNECTD_BULK_ID" /tmp/bic.txt
880887
@@ -883,40 +890,14 @@ deviceReset()
883890
stop all
884891
reset y
885892
886-
# archive the current pre-reset settings - just in case
887-
if [ -f "$CONNECTD_DIR/hardware_id.txt" ]; then
888-
sudo mv $CONNECTD_DIR/hardware_id.txt $CONNECTD_DIR/hardware_id.txt.prev
889-
fi
890-
if [ -f "$CONNECTD_DIR/registration_key.txt" ]; then
891-
sudo mv $CONNECTD_DIR/registration_key.txt $CONNECTD_DIR/registration_key.txt.prev
892-
fi
893-
if [ -f "$CONNECTD_BULK_ID" ]; then
894-
sudo mv "$CONNECTD_BULK_ID" "$CONNECTD_BULK_ID".prev
895-
fi
896-
if [ -d "$CONNECTD_DIR/services" ]; then
897-
sudo mv $CONNECTD_DIR/services $CONNECTD_DIR/services.prev
898-
fi
899-
if [ -d "$PROVISION_DEFAULT" ]; then
900-
sudo mv "$PROVISION_DEFAULT" "$PROVISION_DEFAULT".prev
901-
fi
902-
if [ -d "$PROVISION_DOWNLOAD" ]; then
903-
sudo mv "$PROVISION_DOWNLOAD" "$PROVISION_DOWNLOAD".prev
904-
fi
905-
if [ -d "$DEVICES_ACTIVE" ]; then
906-
sudo mv "$DEVICES_ACTIVE" "$DEVICES_ACTIVE".prev
907-
fi
908-
if [ -d "$DEVICES_AVAILABLE" ]; then
909-
sudo mv "$DEVICES_AVAILABLE" "$DEVICES_AVAILABLE".prev
910-
fi
911-
912893
# restore the bic and other values
913894
sudo mv /tmp/bic.txt "$CONNECTD_BULK_ID"
914895
915896
# enable connectd
916897
sudo systemctl enable connectd
917898
sudo systemctl enable connectd_schannel
918899
919-
create_config
900+
create_config
920901
}
921902
922903
#
@@ -960,7 +941,7 @@ dprovision()
960941
if [ "$status" = "reset" ]; then
961942
962943
# get the reset hardware ID
963-
hardware_id=$(jsonval "$resp" "HardwareId")
944+
hardware_id=$(jsonval "$resp" "HardwareId")
964945
echo "Service directs to reset for new ID: $hardware_id"
965946
966947
# reset the device
@@ -970,12 +951,12 @@ dprovision()
970951
echo $hardware_id > /tmp/hwid.txt
971952
sudo mv /tmp/hwid.txt $CONNECTD_DIR/hardware_id.txt
972953
973-
# start the process again by sending updated information
974-
sendDeviceInfo
954+
# start the process again by sending updated information
955+
sendDeviceInfo
975956
976-
# get the list again - should be fine now
977-
resp=$(curl ${CURL_OPTS} GET -H "content-type:application/json" "$ProjectListURL/$bulk_id_code/$hardware_id/")
978-
status=$(jsonval "$resp" "status")
957+
# get the list again - should be fine now
958+
resp=$(curl ${CURL_OPTS} GET -H "content-type:application/json" "$ProjectListURL/$bulk_id_code/$hardware_id/")
959+
status=$(jsonval "$resp" "status")
979960
fi
980961
981962
# status now should ready to be used

connectd/usr/bin/connectd_library

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# Copyright (C) 2019 remot3.it, Inc. All rights reserved.
1010

1111
##### Settings #####
12-
LIBVERSION=lib_v2.1.22
12+
LIBVERSION=lib_v2.1.23
1313
AUTHOR="Gary Worsham"
14-
LIBMODIFIED="June 17, 2020"
14+
LIBMODIFIED="June 21, 2020"
1515
GREPFLAGS=
1616
apikey="remote.it.developertoolsHW9iHnd"
1717

@@ -1673,7 +1673,7 @@ registerDevice()
16731673
fi
16741674
printf "Only letters, numbers, underscore, space and dash are allowed.\n\n"
16751675
read alias
1676-
if [ $(validateInput "$alias" "\- \_ \. [a-zA-Z0-9]") != 0 ]; then
1676+
if [ $(validateInput "$alias" "\_ \. [a-zA-Z0-9]-") != 0 ]; then
16771677
printf "\nSorry, %s contains one or more invalid characters.\n\n" "$alias"
16781678
alias=""
16791679
fi

connectd/usr/bin/connectd_mp_configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ echo "================ remote.it software and API version =================="
139139
echo "remote.it connectd package version:$r3"
140140
echo "remote.it API:$api$apv" | sed 's/"//g'
141141
echo "================ Bulk/Auto registration settings ====================="
142+
echo "oemGetDefaultHardwareId returns $(oemGetDefaultHardwareId)"
142143
if [ -e /etc/connectd/hardware_id.txt ]; then
143144
hwid="$(cat /etc/connectd/hardware_id.txt)"
144145
else
49 Bytes
Binary file not shown.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "remote.it-installer",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "System tools for setting up remote.it on your internet connected devices.",
55
"scripts": {
6-
"build": "./scripts/build.sh",
6+
"build-one": "./scripts/build.sh one",
7+
"test-auto": "./test/Auto_Registration/auto-test.sh",
8+
"test-interactive": "./test/Interactive/full-interactive-test.sh",
9+
"build-all": "./scripts/build.sh all",
710
"download-assets": "ts-node scripts/download-assets.ts"
811
},
912
"dependencies": {

scripts/build.sh

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,6 @@ controlFile="$controlFilePath"/control
1616
user=$(whoami)
1717
echo $user
1818
# debugging flag, set to 0 to skip tests
19-
runtests=1
20-
interactive=1
21-
22-
#---------------------------------------------------------------------------------
23-
# add_creds takes the environment variables and puts them into the file
24-
# for use by the intereactive installer tests
25-
add_creds()
26-
{
27-
# get account login credentials from environment variables (set in Circle CI)
28-
if [ "${TESTUSERNAME}" = "" ]; then
29-
echo "TESTUSERNAME environment variable not set! ${TESTUSERNAME}"
30-
exit 1
31-
elif [ "${TESTPASSWORD}" = "" ]; then
32-
echo "TESTPASSWORD environment variable not set! ${TESTPASSWORD}"
33-
exit 1
34-
fi
35-
36-
testusername=${TESTUSERNAME}
37-
testpassword=${TESTPASSWORD}
38-
39-
file1=/usr/bin/connectd_installer
40-
sudo sed -i "/USERNAME/c\USERNAME=$testusername" "$file1"
41-
sudo sed -i "/PASSWORD/c\PASSWORD=$testpassword" "$file1"
42-
grep USERNAME "$file1"
43-
}
44-
4519

4620
#-------------------------------------------------
4721
# setOption() is used to change settings in the connectd_$1 file
@@ -248,9 +222,11 @@ build() {
248222
}
249223

250224
#
251-
echo $SCRIPT_DIR
252-
echo $TEST_DIR
225+
# echo $SCRIPT_DIR
226+
# echo $TEST_DIR
253227

228+
build_one_and_test()
229+
{
254230
# now define and create each build 1 by 1
255231
# the amd64 Debian package should be first as we test installing that package and running
256232
# several registration scenarios prior to building everything else
@@ -263,37 +239,15 @@ build x86_64-ubuntu16.04 1 amd64
263239
# in this section we do some basic installer tests using the amd64 Debian
264240
# package running on the build container
265241

266-
if [ $runtests -eq 1 ]; then
267242
sudo "$TEST_DIR"/dpkg/dpkg-install.sh
268243
if [ $? -ne 0 ]; then
269244
echo "dpkg installation failure!"
270245
exit 1
271246
fi
247+
}
272248

273-
# add the test account credentials.
274-
add_creds
275-
276-
sudo -E "$TEST_DIR"/Auto_Registration/auto-reg-test.sh
277-
if [ $? -ne 0 ]; then
278-
echo "Auto Registration failure!"
279-
exit 1
280-
fi
281-
282-
if [ $interactive -eq 1 ]; then
283-
"$TEST_DIR"/Interactive/full-interactive-test.sh
284-
if [ $? -ne 0 ]; then
285-
echo "Interactive Registration failure!"
286-
exit 1
287-
fi
288-
fi
289-
290-
sudo "$TEST_DIR"/dpkg/dpkg-purge.sh
291-
if [ $? -ne 0 ]; then
292-
echo "dpkg purge failure!"
293-
exit 1
294-
fi
295-
296-
fi
249+
build_all()
250+
{
297251
#---------------------------------------------------
298252
# 32-bit i386 Debian package
299253
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
@@ -429,6 +383,18 @@ build mipsel-gcc342_static 0
429383
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
430384
setOption options "BASEDIR" ""
431385
build mipsel-bmc5354_static 0
386+
}
387+
388+
#==== program starts here
389+
390+
if [ "$1" == "one" ]; then
391+
build_one_and_test
392+
elif [ "$1" == "all" ]; then
393+
build_all
394+
else
395+
echo "build.sh requires parameter one or all"
396+
exit 1
397+
fi
432398

433399
echo "====== build.sh $ver completed =============="
434400
exit 0

0 commit comments

Comments
 (0)