Skip to content

Commit e733c5c

Browse files
committed
test writing
1 parent 9414653 commit e733c5c

File tree

6 files changed

+70
-22
lines changed

6 files changed

+70
-22
lines changed

β€Žlabapp/app/app.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def cloudapp_fetch(session, url, timeout, prop, value, headers = {}):
6262
def headers_cleaner(headers):
6363
"""
6464
Remove headers that contain specific substrings.
65+
Use this to make responses look nicer.
6566
"""
6667
unwanted_substrings = ['x-envoy', 'cloudfront', 'x-k8se']
6768
filtered_headers = {
@@ -179,7 +180,7 @@ def port():
179180

180181
@app.route('/vnet')
181182
def vnet():
182-
"""reference page"""
183+
"""vnet page"""
183184
ns = eph_ns()
184185
html = render_md("markdown/reference.md")
185186
return render_template('coming-soon.html',
@@ -190,7 +191,7 @@ def vnet():
190191

191192
@app.route('/netpolicy')
192193
def netp():
193-
"""reference page"""
194+
"""netpolicy page"""
194195
ns = eph_ns()
195196
html = render_md("markdown/reference.md")
196197
return render_template('coming-soon.html',
@@ -226,6 +227,7 @@ def ex_test():
226227
"""Example test"""
227228
try:
228229
s = requests.Session()
230+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
229231
url = f"https://foo.{app.config['base_url']}/"
230232
data = cloudapp_fetch(s, url, 5, 'info', 'bar')
231233
return jsonify(status='success', data=data)
@@ -237,6 +239,7 @@ def ex_test2():
237239
"""Example test"""
238240
try:
239241
s = requests.Session()
242+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
240243
url = f"https://bar.{app.config['base_url']}/"
241244
data = cloudapp_fetch(s, url, 5, 'info', 'foo')
242245
return jsonify(status='success', data=data)
@@ -249,6 +252,7 @@ def lb_aws():
249252
"""Azure LB test"""
250253
try:
251254
s = requests.Session()
255+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
252256
ns = eph_ns()
253257
if not ns:
254258
raise LabException("Ephemeral NS not set")
@@ -263,6 +267,7 @@ def lb_azure():
263267
"""Azure LB test"""
264268
try:
265269
s = requests.Session()
270+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
266271
ns = eph_ns()
267272
if not ns:
268273
raise LabException("Ephemeral NS not set")
@@ -277,6 +282,7 @@ def route1():
277282
"""First Route Test"""
278283
try:
279284
s = requests.Session()
285+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
280286
ns = eph_ns()
281287
if not ns:
282288
raise LabException("Ephemeral NS not set")
@@ -298,6 +304,7 @@ def route2():
298304
"""First Route Test"""
299305
try:
300306
s = requests.Session()
307+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
301308
ns = eph_ns()
302309
if not ns:
303310
raise LabException("Ephemeral NS not set")
@@ -321,6 +328,7 @@ def manip1():
321328
"""First Manip Test"""
322329
try:
323330
s = requests.Session()
331+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
324332
ns = eph_ns()
325333
if not ns:
326334
raise LabException("Ephemeral NS not set")
@@ -330,6 +338,24 @@ def manip1():
330338
return jsonify(status='success', data=r_data)
331339
except (LabException, requests.RequestException, ValueError) as e:
332340
return jsonify(status='fail', error=str(e))
341+
342+
@app.route('/_manip2')
343+
def manip2():
344+
"""First Manip Test"""
345+
try:
346+
s = requests.Session()
347+
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
348+
ns = eph_ns()
349+
if not ns:
350+
raise LabException("Ephemeral NS not set")
351+
base_url = app.config['base_url']
352+
url = f"https://{ns}.{base_url}/"
353+
354+
355+
r_data = cloudapp_fetch(s, url, 5, 'info', {"method": "GET", "path": "/raw"})
356+
return jsonify(status='success', data=r_data)
357+
except (LabException, requests.RequestException, ValueError) as e:
358+
return jsonify(status='fail', error=str(e))
333359

334360

335361
if __name__ == '__main__':

β€Žlabapp/app/markdown/manipulation.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,17 @@ Host: eph-ns.mcn-lab.f5demos.com
162162
```
163163

164164
<div class="left-aligned-button-container">
165-
<button id="requestBtn2" class="btn btn-primary">Test Load Balancer</button>
165+
<button id="requestBtn3" class="btn btn-primary">Test Load Balancer</button>
166166
</div>
167-
<div id="result2" class="mt-3"></div>
167+
<div id="result3" class="mt-3"></div>
168168
<script>
169169
document.getElementById('requestBtn2').addEventListener('click', () => {
170-
makeHttpRequest('requestBtn2', '/_manip2', 'result2');
170+
makeHttpRequest('requestBtn2', '/_manip3', 'result3');
171171
});
172172
</script>
173173

174174

175175
<div style="height:25px" class="d-flex align-items-center pb-3 mb-3 link-dark text-decoration-none border-bottom"></div>
176176

177-
Nice πŸš€! If you've completed all the exercises so far, you have a good foundation for how App Connect addresses common L7 MCN scenarios.
178-
In subsequent labs, we'll explore security and observabilty concepts that build on MCN functionality.
179-
Head over to the <a href="/vnet" class="alert-link">Network Connect</a> exercise.
177+
Finish off App Connect with an exercise on load balancer <strong><a href="/portability" class="alert-link">portability</a></strong>.
180178

β€Žlabapp/app/markdown/portability.md

+37-14
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
<div href="/" class="d-flex align-items-center pb-3 mb-3 link-dark text-decoration-none border-bottom"></div>
88

99

10-
So far we've built an object handling load balancing, routing, and content manipulation across multiple sites.
11-
XC refers to these as "load balancers" but it's really the holistic representation of a service whose components live across a distributed network.
12-
Our object is a simplified representation that does not include WAAP, API Protection, or service policies.
13-
XC is incredibly flexible in defining where that object is advertised.
10+
The configuration built so far handles load balancing, routing, and content manipulation.
11+
XC refers to this object as a "load balancer" -- but it's really the holistic representation of an application whose service endpoints live across the distributed network.
12+
The object is simple -- it doesn't yet include configuration for WAAP, API protection, or a service policy.
13+
14+
What seperate XC from traditional ADCs is the flexibility of defining <strong>where the object is advertised</strong>.
1415

1516
<div style="height:25px"></div>
1617

1718
### **Exercise 1: Advertise Policy**
1819

19-
-- advertise from the Virtual Site
20+
<ul class="list-group">
21+
<li class="list-group-item">
22+
<img src="/static/lb-icon.png" width="auto" height="50px"> &nbsp; &nbsp;
23+
Configure the load balancer to be advertised on the virtual site <strong>shared/mcn-practical-udf-sites</strong>.
24+
</li>
25+
</ul>
2026

2127
<div style="height:25px"></div>
2228

@@ -27,7 +33,9 @@ GET https://eph-ns.mcn-lab.f5demos.com/ HTTP/1.1
2733
Host: eph-ns.mcn-lab.f5demos.com
2834
2935
{
30-
"env": "azure",
36+
"info": {
37+
"path": "/"
38+
}
3139
...
3240
}
3341
```
@@ -38,17 +46,30 @@ Host: eph-ns.mcn-lab.f5demos.com
3846
<div id="result1" class="mt-3"></div>
3947
<script>
4048
document.getElementById('requestBtn1').addEventListener('click', () => {
41-
makeHttpRequest('requestBtn1', '/_manip1', 'result');
49+
makeHttpRequest('requestBtn1', '/_port1', 'result');
4250
});
4351
</script>
4452

53+
54+
<div id="hints">
55+
<p>
56+
<a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Why did that work?</a>
57+
</p>
58+
<div class="row">
59+
<div class="collapse multi-collapse" id="multiCollapseExample1" data-bs-parent="#hints">
60+
<img src="/static/vsite2.png" width="600px" height="auto" alt="temp">
61+
<img src="/static/vsite.png" width="900px" height="auto" alt="temp">
62+
</div>
63+
</div>
64+
</div>
65+
4566
<div style="height:25px"></div>
4667

47-
### **Exercise 2: Find a Friend (Optional)**
68+
### **Exercise 2: Find a Friend**
4869

49-
Test a friend's site. Look at the headers from the previous exercises.
70+
Do you have a friend working on the lab?
71+
Ask them their ephemeral namespace and test that their load balancer is being advertised from your site.
5072

51-
We need an input button for the friend's LB. I can keep my funny name LB around for this as well.
5273

5374
<div style="height:25px"></div>
5475

@@ -59,7 +80,9 @@ GET https://eph-ns.mcn-lab.f5demos.com/ HTTP/1.1
5980
Host: eph-ns.mcn-lab.f5demos.com
6081
6182
{
62-
"env": "azure",
83+
"info": {
84+
"path": "/"
85+
}
6386
...
6487
}
6588
```
@@ -76,7 +99,7 @@ document.getElementById('requestBtn2').addEventListener('click', () => {
7699

77100
<div style="height:25px" class="d-flex align-items-center pb-3 mb-3 link-dark text-decoration-none border-bottom"></div>
78101

79-
Nice πŸš€! If you've completed all the exercises so far, you have a good foundation for how App Connect addresses common L7 MCN scenarios.
80-
In subsequent labs, we'll explore security and observabilty concepts that build on MCN functionality.
81-
Head over to the <a href="/vnet" class="alert-link">Network Connect</a> exercise.
102+
πŸš€ Nice πŸš€!
103+
</br>
104+
82105

β€Žlabapp/app/static/vsite.png

30.2 KB
Loading

β€Žlabapp/app/static/vsite2.png

31.4 KB
Loading

β€Žlabapp/app/templates/base.html

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<li><a href="/lb" class="link-dark rounded">Load Balancing</a></li>
5252
<li><a href="/route" class="link-dark rounded">Routing</a></li>
5353
<li><a href="/manipulation" class="link-dark rounded">Manipulation</a></li>
54+
<li><a href="/portability" class="link-dark rounded">Portability</a></li>
5455
</ul>
5556
</div>
5657
</li>

0 commit comments

Comments
Β (0)