forked from MTecknology/teckhost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
138 lines (110 loc) · 3.39 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/make -f
##
# Makefile for Teckhost systems
# See env[TH_SRC] and env[TH_CKSUM] for ISO building
##
export WORKSPACE ?= $(abspath $(PWD)/)
export GRUB_EXTRA ?= hostname=testpc1
##
# ISO
##
# Intended for production use (assumes nvme)
teckhost.iso:
./iso/build_iso \
-s iso/preseed.cfg \
-o teckhost.iso \
-x "$(GRUB_EXTRA)" \
-f iso/grub-bios.cfg -g iso/grub-efi.cfg
# Intended for use with automated testing
teckhost-%.iso: testseed.cfg
./iso/build_iso \
-s testseed.cfg \
-o teckhost-$(subst teckhost-,,$(subst .iso,,$@)).iso \
-d /dev/$(subst teckhost-,,$(subst .iso,,$@)) \
-x "$(GRUB_EXTRA)" \
-f iso/grub-bios.cfg -g iso/grub-efi.cfg
# Intended for local developmnt with virtualbox
teckhost-local.iso: testseed.cfg
./iso/build_iso \
-s testseed.cfg \
-o teckhost-local.iso \
-d /dev/sda \
-x "hostname=devpc1 BS_devdir=/srv" \
-f iso/grub-bios.cfg -g iso/grub-efi.cfg
##
# Preeseed
##
testseed.cfg:
cp iso/preseed.cfg testseed.cfg
patch testseed.cfg test/preseed.patch
##
# Test Stuff
##
# This can't be cleanly checked into git
testprep:
chmod 0700 test/.ssh
chmod 0600 test/.ssh/id_ed25519
# Run all tests
test: test-user test-admin
# Rut pytest for user-targeted tests
test-user: testpc1 testprep
python3 -m pytest \
--ssh-config=test/.ssh/config --ssh-identity-file=test/.ssh/id_ed25519 \
--hosts=ssh://tester@testpc1 --type user
# Rut pytest for admin-targeted tests
test-admin: testpc1 testprep
python3 -m pytest \
--ssh-config=test/.ssh/config --ssh-identity-file=test/.ssh/id_ed25519 \
--hosts=ssh://testadmin@testpc1 --type admin
##
# Dev Stuff
##
# Connect to dev host as user
devpc1-ssh: devpc1
ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" \
-i test/.ssh/id_ed25519 ssh://tester@localhost:4224
# Connect to dev host as admin
devpc1-root: devpc1
ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" \
-i test/.ssh/id_ed25519 ssh://testadmin@localhost:4224
# Run tests on dev box
devpc1-test: devpc1
python3 -m pytest \
--ssh-config=test/.ssh/config --ssh-identity-file=test/.ssh/id_ed25519 \
--hosts=ssh://tester@devpc1 --type user
python3 -m pytest \
--ssh-config=test/.ssh/config --ssh-identity-file=test/.ssh/id_ed25519 \
--hosts=ssh://testadmin@devpc1 --type admin
##
# Test Boxes
##
# TEST: The standard virtualbox deployment; replicates production
testpc1: teckhost-sda.iso
ifneq (,$(findstring testpc1,$(shell VBoxManage list runningvms)))
echo 'VM already exists: testpc1'
else
./test/vbox_create -i $(WORKSPACE)/teckhost-sda.iso -n testpc1 \
-p 4222
endif
# DEV: Build a dev box using local file directory for salt data
# Note: The first highstate will still be from git
devpc1: teckhost-local.iso
ifneq (,$(findstring devpc1,$(shell VBoxManage list runningvms)))
echo 'VM already exists: devpc1'
else
./test/vbox_create -i $(WORKSPACE)/teckhost-local.iso -n devpc1 \
-p 4224 -d $(WORKSPACE)
endif
##
# Cleanup
##
clean: clean-testpc1 clean-devcp1
$(RM) testseed.cfg teckhost*.iso
clean-%:
ifneq (,$(findstring pc,$(shell VBoxManage list vms)))
VBoxManage controlvm $(subst clean-,,$@) poweroff || true
VBoxManage unregistervm $(subst clean-,,$@) --delete
else
@echo 'No VMs could match $(subst clean-,,$@); skipping'
endif
.PHONY: test-admin test-user test testprep testpc1 devpc1 devpc1-ssh devcp1-root clean