Skip to content

Commit 464b41d

Browse files
committed
Three new valgrind profiling tests to profile straight accepts, the use of files module and connected to an ldap server.
1 parent 6b01889 commit 464b41d

42 files changed

Lines changed: 1306 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/tests/multi-server/all.mk

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
#
88
# Usage:
99
# make -f src/tests/multi-server/all.mk test.multi-server # run all tests
10-
# make -f src/tests/multi-server/all.mk test.multi-server.5hs-autoaccept.short # run single test
10+
# make -f src/tests/multi-server/all.mk test.multi-server.ci # run all ci tests
11+
# make -f src/tests/multi-server/all.mk test.multi-server.proxy-accept.short_ci # run single test
1112
# make -f src/tests/multi-server/all.mk clean.test.multi-server # clean logs
1213
#
1314

1415
SHELL := /bin/bash
1516

17+
PROFILE ?= profiling1
18+
1619
#
1720
# Allow for stand-alone builds from the local directory.
1821
#
@@ -139,6 +142,9 @@ TEST_MULTI_SERVER_RENDERED.${1}.${2} := $$(patsubst $$(DIR)/tests/${1}/%.j2,
139142

140143
$$(foreach j,$$(TEST_MULTI_SERVER_JINJA_FILES.${1}.${2}),$$(eval $$(call TEST_MULTI_SERVER_RENDER,${1},${2},${3},$$j)))
141144

145+
.PHONY: render.test.multi-server.${1}.${2}
146+
render.test.multi-server.${1}.${2}: $$(TEST_MULTI_SERVER_RENDERED.${1}.${2})
147+
142148
.PHONY: test.multi-server.${1}.${2}
143149
test.multi-server.${1}.${2}: $$(TEST_MULTI_SERVER_RENDERED.${1}.${2})
144150
$$(eval CMD := cd $(TEST_MULTI_SERVER_FRAMEWORK_DIR) && . .venv/bin/activate && DATA_PATH="${4}" python3 -m src.multi_server_test $(TEST_MULTI_SERVER_FLAGS) --project-name "${1}-${2}" --compose "${4}/environment.yml" --test "${4}/template.yml" --use-files --listener-dir "${4}/listener" --log-dir "${4}/logs" --output "${4}/logs/result.log")
@@ -171,7 +177,7 @@ endef
171177
# Discovers *.yml param files in the suite directory and generates
172178
# render + test targets for each.
173179
#
174-
# ${1} = suite dir name (e.g., 5hs-autoaccept)
180+
# ${1} = suite dir name (e.g. proxy-accept)
175181
#
176182
define TEST_MULTI_SERVER
177183
TEST_MULTI_SERVER_PARAM_FILES.${1} := $$(wildcard $$(DIR)/tests/${1}/*.test.yml)
@@ -195,6 +201,8 @@ $(foreach s,$(TEST_MULTI_SERVER_SUITES),$(eval $(call TEST_MULTI_SERVER,$s)))
195201

196202
TEST_MULTI_SERVER_ALL_TESTS := $(foreach s,$(TEST_MULTI_SERVER_SUITES),$(TEST_MULTI_SERVER_TESTS.$(s)))
197203

204+
TEST_MULTI_SERVER_PROF_TESTS := $(foreach s,$(filter prof-%,$(TEST_MULTI_SERVER_SUITES)),$(TEST_MULTI_SERVER_TESTS.$(s)))
205+
198206
######################################################################
199207
#
200208
# Top-level targets
@@ -215,6 +223,61 @@ TEST_MULTI_SERVER_CI_TESTS := $(filter %_ci,$(TEST_MULTI_SERVER_ALL_TESTS))
215223
.PHONY: test.multi-server.ci
216224
test.multi-server.ci: $(TEST_MULTI_SERVER_CI_TESTS)
217225

226+
#
227+
# Ensure the freeradius-prof image is present before running
228+
# any of the profiling tests.
229+
#
230+
231+
# Base profiling image, FreeRADIUS not built on this image
232+
FREERADIUS_PROF_IMAGE := freeradius4-$(PROFILE)/ubuntu24:latest
233+
# Multi-server profiling image; FreeRADIUS dev build specifically for profiling
234+
FREERADIUS_RADENV_PROF_IMAGE := freeradius-prof:latest
235+
236+
.PHONY: freeradius-prof.image
237+
freeradius-prof.image:
238+
${Q}if [ -n "$(FORCE_IMAGE_REBUILD)" ] || [ -z "$$(docker images -q $(FREERADIUS_RADENV_PROF_IMAGE) 2>/dev/null)" ]; then \
239+
$(MAKE) -C $(top_srcdir) crossbuild.ubuntu24; \
240+
$(MAKE) -C $(top_srcdir) crossbuild.ubuntu24.profile.build; \
241+
./src/tests/multi-server/scripts/build_image.sh; \
242+
else \
243+
echo "$(FREERADIUS_RADENV_PROF_IMAGE) available, skipping image creation"; \
244+
fi
245+
246+
$(TEST_MULTI_SERVER_PROF_TESTS): freeradius-prof.image
247+
248+
#
249+
# Copy the valgrind profiling helper script into each prof test's output dir
250+
# so it is available alongside the rendered test configs.
251+
#
252+
PROFILING_SCRIPT_SRC := $(DIR)/scripts/profiling/start_valgrind_profiling.sh
253+
254+
define TEST_MULTI_SERVER_PROF_SCRIPT
255+
$(OUTPUT)/${1}/${2}/start_valgrind_profiling.sh: $(PROFILING_SCRIPT_SRC)
256+
$${Q}mkdir -p $$(@D)
257+
$${Q}cp $$< $$@
258+
259+
test.multi-server.${1}.${2}: $(OUTPUT)/${1}/${2}/start_valgrind_profiling.sh
260+
endef
261+
262+
$(foreach s,$(filter prof-%,$(TEST_MULTI_SERVER_SUITES)),$(foreach p,$(TEST_MULTI_SERVER_PARAM_FILES.$(s)),$(eval $(call TEST_MULTI_SERVER_PROF_SCRIPT,$(s),$(subst .,_,$(patsubst %.test.yml,%,$(notdir $(p))))))))
263+
264+
#
265+
# Ensure the ldap image is present before running prof-ldap tests.
266+
# Builds it automatically via docker.openldap.prof if not found.
267+
#
268+
OPENLDAP_PROF_IMAGE := freeradius4/openldap-prof:latest
269+
270+
.PHONY: openldap.image
271+
openldap.image:
272+
${Q}if [ -n "$(FORCE_IMAGE_REBUILD)" ] || [ -z "$$(docker images -q $(OPENLDAP_PROF_IMAGE) 2>/dev/null)" ]; then \
273+
$(MAKE) -C $(top_srcdir) docker.openldap.prof; \
274+
else \
275+
echo "$(OPENLDAP_PROF_IMAGE) available, skipping image creation"; \
276+
fi
277+
${Q}docker tag $(OPENLDAP_PROF_IMAGE) openldap:latest
278+
279+
$(TEST_MULTI_SERVER_TESTS.prof-ldap): openldap.image
280+
218281
.PHONY: clean.test.multi-server
219282
clean.test.multi-server:
220283
rm -rf $(OUTPUT)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ldap {
2+
server = 'openldap'
3+
identity = 'cn=admin,dc=example,dc=com'
4+
password = 'adminpassword'
5+
base_dn = 'dc=example,dc=com'
6+
7+
update {
8+
control.Password.With-Header += 'userPassword'
9+
}
10+
11+
user {
12+
base_dn = "${..base_dn}"
13+
filter = "(uid=%{Stripped-User-Name || User-Name})"
14+
}
15+
16+
options {
17+
res_timeout = 10
18+
srv_timelimit = 3
19+
net_timeout = 10
20+
}
21+
22+
pool {
23+
start = 0
24+
min = 1
25+
max = 5
26+
connecting = 2
27+
uses = 0
28+
lifetime = 0
29+
}
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
pap {
3+
password_attribute = User-Password
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
User-Name = "testuser"
2+
User-Password = "testpass"
3+
Calling-Station-ID = "F1-F2-F3-F4-F5-F6"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
testuser Password.Cleartext := "testpass"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export TEST_LOADGEN_START_PPS="100"
2+
export TEST_LOADGEN_MAX_PPS="100"
3+
export TEST_LOADGEN_DURATION="60"
4+
export TEST_LOADGEN_STEP="100"
5+
export TEST_LOADGEN_PARALLEL="1"
6+
export TEST_LOADGEN_MAX_BACKLOG="1000"
7+
export TEST_LOADGEN_REPEAT="no"
8+
export TEST_LOADGEN_NUM_MESSAGES=0
9+
10+
for ((pps=$TEST_LOADGEN_START_PPS; pps<=$TEST_LOADGEN_MAX_PPS; pps+=$TEST_LOADGEN_STEP)); do
11+
TEST_LOADGEN_NUM_MESSAGES=$((TEST_LOADGEN_NUM_MESSAGES + TEST_LOADGEN_DURATION * pps))
12+
done
13+
14+
export TEST_LOADGEN_NUM_MESSAGES
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name = profiling-server
2+
3+
raddbdir = /etc/freeradius
4+
confdir = ${raddbdir}
5+
modconfdir = ${confdir}/mods-config
6+
logdir = /var/log/freeradius
7+
radacctdir = ${logdir}/radacct
8+
9+
security {
10+
allow_core_dumps = yes
11+
}
12+
13+
modules {
14+
15+
# Common ldap module configuration
16+
{% include "freeradius/common/mods-available/ldap" %}
17+
18+
# Common pap module configuration
19+
{% include "freeradius/common/mods-available/pap" %}
20+
21+
# Common always module configuration, required for the control policy
22+
{% include "freeradius/common/mods-available/always" %}
23+
24+
}
25+
26+
policy {
27+
28+
# Common control policy configuration, needed for accept action
29+
{% include "freeradius/common/policy.d/control" %}
30+
31+
}
32+
33+
server profiling-server {
34+
35+
namespace = radius
36+
37+
listen load {
38+
handler = load
39+
type = Access-Request
40+
transport = step
41+
42+
step {
43+
44+
# Default packet config to use by proto_load module
45+
filename = ${confdir}/load-generator-packets/packet.conf
46+
47+
# Saving proto_load statistics disabled by default, can be enabled for debugging purposes.
48+
csv = ${confdir}/stats/load-generator-stats.csv
49+
50+
max_attributes = 64
51+
52+
#
53+
# The load profile is configured via environment variables set
54+
# in the testcase configuration files.
55+
#
56+
start_pps = $ENV{TEST_LOADGEN_START_PPS}
57+
max_pps = $ENV{TEST_LOADGEN_MAX_PPS}
58+
duration = $ENV{TEST_LOADGEN_DURATION}
59+
step = $ENV{TEST_LOADGEN_STEP}
60+
max_backlog = $ENV{TEST_LOADGEN_MAX_BACKLOG}
61+
parallel = $ENV{TEST_LOADGEN_PARALLEL}
62+
num_messages = $ENV{TEST_LOADGEN_NUM_MESSAGES}
63+
repeat = no
64+
}
65+
}
66+
67+
listen authentication {
68+
type = Access-Request
69+
transport = udp
70+
require_message_authenticator = auto
71+
limit_proxy_state = auto
72+
73+
limit {
74+
max_clients = 256
75+
max_connections = 256
76+
idle_timeout = 60.0
77+
dynamic_timeout = 600.0
78+
nak_lifetime = 30.0
79+
cleanup_delay = 5.0
80+
}
81+
82+
udp {
83+
ipaddr = *
84+
port = 1812
85+
networks {
86+
allow = 127/8
87+
allow = 192.0.2/24
88+
}
89+
}
90+
91+
tcp {
92+
ipaddr = *
93+
port = 1812
94+
networks {
95+
allow = 127/8
96+
allow = 192.0.2/24
97+
}
98+
}
99+
}
100+
101+
listen authentication {
102+
type = Access-Request
103+
transport = tcp
104+
105+
tcp {
106+
ipaddr = *
107+
port = 1812
108+
networks {
109+
allow = 127/8
110+
allow = 192.0.2/24
111+
}
112+
}
113+
}
114+
115+
client localhost {
116+
shortname = client-localhost
117+
ipaddr = *
118+
secret = testing123
119+
}
120+
121+
recv Access-Request {
122+
ldap
123+
# pap module always listed last
124+
pap
125+
}
126+
127+
authenticate pap {
128+
pap
129+
}
130+
131+
send Access-Accept {
132+
133+
}
134+
135+
send Access-Reject {
136+
137+
}
138+
139+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"time","last_packet","rtt","rttvar","pps","pps_accepted","sent","received","backlog","max_backlog","<usec","us","10us","100us","ms","10ms","100ms","s","blocked"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# virtual server templates placeholder
3+
#
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
User-Name = "testuser"
2+
User-Password = "testpass"
3+
Calling-Station-ID = "F1-F2-F3-F4-F5-F6"

0 commit comments

Comments
 (0)