Skip to content

Commit

Permalink
test writing
Browse files Browse the repository at this point in the history
  • Loading branch information
kreynoldsf5 committed May 1, 2024
1 parent 9414653 commit e733c5c
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 22 deletions.
30 changes: 28 additions & 2 deletions labapp/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def cloudapp_fetch(session, url, timeout, prop, value, headers = {}):
def headers_cleaner(headers):
"""
Remove headers that contain specific substrings.
Use this to make responses look nicer.
"""
unwanted_substrings = ['x-envoy', 'cloudfront', 'x-k8se']
filtered_headers = {
Expand Down Expand Up @@ -179,7 +180,7 @@ def port():

@app.route('/vnet')
def vnet():
"""reference page"""
"""vnet page"""
ns = eph_ns()
html = render_md("markdown/reference.md")
return render_template('coming-soon.html',
Expand All @@ -190,7 +191,7 @@ def vnet():

@app.route('/netpolicy')
def netp():
"""reference page"""
"""netpolicy page"""
ns = eph_ns()
html = render_md("markdown/reference.md")
return render_template('coming-soon.html',
Expand Down Expand Up @@ -226,6 +227,7 @@ def ex_test():
"""Example test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
url = f"https://foo.{app.config['base_url']}/"
data = cloudapp_fetch(s, url, 5, 'info', 'bar')
return jsonify(status='success', data=data)
Expand All @@ -237,6 +239,7 @@ def ex_test2():
"""Example test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
url = f"https://bar.{app.config['base_url']}/"
data = cloudapp_fetch(s, url, 5, 'info', 'foo')
return jsonify(status='success', data=data)
Expand All @@ -249,6 +252,7 @@ def lb_aws():
"""Azure LB test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
ns = eph_ns()
if not ns:
raise LabException("Ephemeral NS not set")
Expand All @@ -263,6 +267,7 @@ def lb_azure():
"""Azure LB test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
ns = eph_ns()
if not ns:
raise LabException("Ephemeral NS not set")
Expand All @@ -277,6 +282,7 @@ def route1():
"""First Route Test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
ns = eph_ns()
if not ns:
raise LabException("Ephemeral NS not set")
Expand All @@ -298,6 +304,7 @@ def route2():
"""First Route Test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
ns = eph_ns()
if not ns:
raise LabException("Ephemeral NS not set")
Expand All @@ -321,6 +328,7 @@ def manip1():
"""First Manip Test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
ns = eph_ns()
if not ns:
raise LabException("Ephemeral NS not set")
Expand All @@ -330,6 +338,24 @@ def manip1():
return jsonify(status='success', data=r_data)
except (LabException, requests.RequestException, ValueError) as e:
return jsonify(status='fail', error=str(e))

@app.route('/_manip2')
def manip2():
"""First Manip Test"""
try:
s = requests.Session()
s.headers.update({"User-Agent": "MCN-Lab-Runner/1.0"})
ns = eph_ns()
if not ns:
raise LabException("Ephemeral NS not set")
base_url = app.config['base_url']
url = f"https://{ns}.{base_url}/"


r_data = cloudapp_fetch(s, url, 5, 'info', {"method": "GET", "path": "/raw"})
return jsonify(status='success', data=r_data)
except (LabException, requests.RequestException, ValueError) as e:
return jsonify(status='fail', error=str(e))


if __name__ == '__main__':
Expand Down
10 changes: 4 additions & 6 deletions labapp/app/markdown/manipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,17 @@ Host: eph-ns.mcn-lab.f5demos.com
```

<div class="left-aligned-button-container">
<button id="requestBtn2" class="btn btn-primary">Test Load Balancer</button>
<button id="requestBtn3" class="btn btn-primary">Test Load Balancer</button>
</div>
<div id="result2" class="mt-3"></div>
<div id="result3" class="mt-3"></div>
<script>
document.getElementById('requestBtn2').addEventListener('click', () => {
makeHttpRequest('requestBtn2', '/_manip2', 'result2');
makeHttpRequest('requestBtn2', '/_manip3', 'result3');
});
</script>


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

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

51 changes: 37 additions & 14 deletions labapp/app/markdown/portability.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
<div href="/" class="d-flex align-items-center pb-3 mb-3 link-dark text-decoration-none border-bottom"></div>


So far we've built an object handling load balancing, routing, and content manipulation across multiple sites.
XC refers to these as "load balancers" but it's really the holistic representation of a service whose components live across a distributed network.
Our object is a simplified representation that does not include WAAP, API Protection, or service policies.
XC is incredibly flexible in defining where that object is advertised.
The configuration built so far handles load balancing, routing, and content manipulation.
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.
The object is simple -- it doesn't yet include configuration for WAAP, API protection, or a service policy.

What seperate XC from traditional ADCs is the flexibility of defining <strong>where the object is advertised</strong>.

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

### **Exercise 1: Advertise Policy**

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

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

Expand All @@ -27,7 +33,9 @@ GET https://eph-ns.mcn-lab.f5demos.com/ HTTP/1.1
Host: eph-ns.mcn-lab.f5demos.com
{
"env": "azure",
"info": {
"path": "/"
}
...
}
```
Expand All @@ -38,17 +46,30 @@ Host: eph-ns.mcn-lab.f5demos.com
<div id="result1" class="mt-3"></div>
<script>
document.getElementById('requestBtn1').addEventListener('click', () => {
makeHttpRequest('requestBtn1', '/_manip1', 'result');
makeHttpRequest('requestBtn1', '/_port1', 'result');
});
</script>


<div id="hints">
<p>
<a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Why did that work?</a>
</p>
<div class="row">
<div class="collapse multi-collapse" id="multiCollapseExample1" data-bs-parent="#hints">
<img src="/static/vsite2.png" width="600px" height="auto" alt="temp">
<img src="/static/vsite.png" width="900px" height="auto" alt="temp">
</div>
</div>
</div>

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

### **Exercise 2: Find a Friend (Optional)**
### **Exercise 2: Find a Friend**

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

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

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

Expand All @@ -59,7 +80,9 @@ GET https://eph-ns.mcn-lab.f5demos.com/ HTTP/1.1
Host: eph-ns.mcn-lab.f5demos.com
{
"env": "azure",
"info": {
"path": "/"
}
...
}
```
Expand All @@ -76,7 +99,7 @@ document.getElementById('requestBtn2').addEventListener('click', () => {

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

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


Binary file added labapp/app/static/vsite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added labapp/app/static/vsite2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions labapp/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<li><a href="/lb" class="link-dark rounded">Load Balancing</a></li>
<li><a href="/route" class="link-dark rounded">Routing</a></li>
<li><a href="/manipulation" class="link-dark rounded">Manipulation</a></li>
<li><a href="/portability" class="link-dark rounded">Portability</a></li>
</ul>
</div>
</li>
Expand Down

0 comments on commit e733c5c

Please sign in to comment.