1"use strict";(self.webpackChunkedgemesh=self.webpackChunkedgemesh||[]).push([[123],{1142:(e,n,s)=>{s.r(n),s.d(n,{data:()=>a});const a={key:"v-c252efcc",path:"/guide/test-case.html",title:"Test Case",lang:"en-US",frontmatter:{},excerpt:"",headers:[{level:2,title:"Prepare",slug:"prepare",children:[]},{level:2,title:"HTTP",slug:"http",children:[]},{level:2,title:"HTTPS",slug:"https",children:[]},{level:2,title:"TCP",slug:"tcp",children:[]},{level:2,title:"Websocket",slug:"websocket",children:[]},{level:2,title:"UDP",slug:"udp",children:[]},{level:2,title:"Load Balance",slug:"load-balance",children:[]},{level:2,title:"Cross-Edge-Cloud â",slug:"cross-edge-cloud",children:[]}],filePathRelative:"guide/test-case.md",git:{updatedTime:16456161e5,contributors:[]}}},3240:(e,n,s)=>{s.r(n),s.d(n,{default:()=>h});var a=s(6252);const l=(0,a._)("h1",{id:"test-case",tabindex:"-1"},[(0,a._)("a",{class:"header-anchor",href:"#test-case","aria-hidden":"true"},"#"),(0,a.Uk)(" Test Case")],-1),t=(0,a.Uk)("All the test cases in this chapter can find the corresponding files in the directory "),p={href:"https://github.com/kubeedge/edgemesh/tree/main/examples",target:"_blank",rel:"noopener noreferrer"},c=(0,a.Uk)("examples"),r=(0,a.Uk)("."),o=(0,a._)("h2",{id:"prepare",tabindex:"-1"},[(0,a._)("a",{class:"header-anchor",href:"#prepare","aria-hidden":"true"},"#"),(0,a.Uk)(" Prepare")],-1),i=(0,a._)("ul",null,[(0,a._)("li",null,[(0,a._)("strong",null,"Step 1"),(0,a.Uk)(": Deploy EdgeMesh")])],-1),d=(0,a.Uk)("Please refer to "),u=(0,a.Uk)("Getting Started"),b=(0,a.Uk)(" to deploy EdgeMesh"),m=(0,a.uE)('<ul><li><strong>Step 2</strong>: Deploy Test Pods</li></ul><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/test-pod.yaml\npod/alpine-test created\npod/websocket-test created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h2 id="http" tabindex="-1"><a class="header-anchor" href="#http" aria-hidden="true">#</a> HTTP</h2><p>Deploy a HTTP container application and relevant service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/hostname.yaml\ndeployment.apps/hostname-edge created\nservice/hostname-svc created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Enter the test pod and use <code>curl</code> to access the service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl <span class="token builtin class-name">exec</span> -it alpine-test -- <span class="token function">sh</span>\n<span class="token punctuation">(</span>in the container environment<span class="token punctuation">)</span>\n/ <span class="token comment"># curl hostname-svc:12345</span>\nhostname-edge-5c75d56dc4-rq57t\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h2 id="https" tabindex="-1"><a class="header-anchor" href="#https" aria-hidden="true">#</a> HTTPS</h2><p>Deploy a HTTPS container application and relevant service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ ./examples/nginx-https/tools.sh <span class="token function">install</span>\n<span class="token punctuation">..</span>.\nGetting Private key\nGetting CA Private Key\nsecret/nginxsecret created\nconfigmap/nginxconfigmap created\ndeployment.apps/nginx-https created\nservice/nginx-https created\ncreate https example success<span class="token operator">!</span>\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>Enter the test pod and use <code>curl</code> to access the service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl <span class="token builtin class-name">exec</span> -it alpine-test -- <span class="token function">sh</span>\n<span class="token punctuation">(</span>in the container environment<span class="token punctuation">)</span>\n/ <span class="token comment"># curl -k --cert client.crt --key client.key https://nginx-https</span>\n<span class="token operator"><</span><span class="token operator">!</span>
1DOCTYPE html<span class="token operator">></span>\n<span class="token operator"><</span>html<span class="token operator">></span>\n<span class="token operator"><</span>head<span class="token operator">></span>\n<span class="token operator"><</span>title<span class="token operator">></span>Welcome to nginx<span class="token operator">!</span><span class="token operator"><</span>/title<span class="token operator">></span>\n<span class="token punctuation">..</span>.\n\n<span class="token punctuation">(</span>you can also use external domain name to access related <span class="token function">service</span><span class="token punctuation">)</span>\n/ <span class="token comment"># curl --cacert rootCA.crt --cert client.crt --key client.key https://my-nginx.com</span>\n<span class="token operator"><</span><span class="token operator">!</span>DOCTYPE html<span class="token operator">></span>\n<span class="token operator"><</span>html<span class="token operator">></span>\n<span class="token operator"><</span>head<span class="token operator">></span>\n<span class="token operator"><</span>title<span class="token operator">></span>Welcome to nginx<span class="token operator">!</span><span class="token operator"><</span>/title<span class="token operator">></span>\n<span class="token punctuation">..</span>.\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><details class="custom-container details"><p>examples/nginx-https/tools.sh script function:</p><ol><li>Generate self-signed root certificate, server, client certificates and private keys</li><li>Create nginx-https related secret, configmap, deployment and service</li><li>Copy the certificate and private key to alpine-test</li><li>Write the mapping between IP and domain name (my-nginx.com) to the /etc/hosts file in alpine-test</li></ol><p>Note: Use the cleanup command of the tools.sh script to clear all the resources created above and restore the modification to alpine-test</p></details><h2 id="tcp" tabindex="-1"><a class="header-anchor" href="#tcp" aria-hidden="true">#</a> TCP</h2><p>Deploy a TCP container application and relevant service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/tcp-echo-service.yaml\ndeployment.apps/tcp-echo-deployment created\nservice/tcp-echo-service created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Enter the test pod and use <code>telnet</code> to access the service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl <span class="token builtin class-name">exec</span> -it alpine-test -- <span class="token function">sh</span>\n<span class="token punctuation">(</span>in the container environment<span class="token punctuation">)</span>\n/ <span class="token comment"># telnet tcp-echo-service 2701</span>\nWelcome, you are connected to node ke-edge1.\nRunning on Pod tcp-echo-deployment-66457b769-7zgqb.\nIn namespace default.\nWith IP address <span class="token number">172.17</span>.0.2.\nService default.\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h2 id="websocket" tabindex="-1"><a class="header-anchor" href="#websocket" aria-hidden="true">
1#</a> Websocket</h2><p>Deploy a websocket container application and relevant service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/websocket.yaml\ndeployment.apps/ws-edge created\nservice/ws-svc created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Enter the test pod and use websocket <code>client</code> to access the service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl <span class="token builtin class-name">exec</span> -it websocket-test -- <span class="token function">sh</span>\n<span class="token punctuation">(</span>in the container environment<span class="token punctuation">)</span>\n/ <span class="token comment"># ./client --addr ws-svc:12348</span>\nconnecting to ws://ws-svc.default:12348/echo\nrecv: <span class="token number">2021</span>-12-02 03:42:20.191695384 +0000 UTC <span class="token assign-left variable">m</span><span class="token operator">=</span>+1.004526202\nrecv: <span class="token number">2021</span>-12-02 03:42:21.191724176 +0000 UTC <span class="token assign-left variable">m</span><span class="token operator">=</span>+2.004554995\nrecv: <span class="token number">2021</span>-12-02 03:42:22.191725321 +0000 UTC <span class="token assign-left variable">m</span><span class="token operator">=</span>+3.004556159\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h2 id="udp" tabindex="-1"><a class="header-anchor" href="#udp" aria-hidden="true">#</a> UDP</h2><p>Deploy a UDP container application and relevant service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/hostname-udp.yaml\ndeployment.apps/hostname-edge created\nservice/hostname-udp-svc created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Enter the test pod and use <code>nc</code> to access the service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl <span class="token builtin class-name">exec</span> -it alpine-test -- <span class="token function">sh</span>\n<span class="token punctuation">(</span>in the container environment<span class="token punctuation">)</span>\n/ <span class="token comment"># nc -u hostname-udp-svc 12345</span>\nhostname-edge-5cd47b65d5-8zg27\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h2 id="load-balance" tabindex="-1"><a class="header-anchor" href="#load-balance" aria-hidden="true">#</a> Load Balance</h2><p>Deploy a container application and related services configured with a <code>random</code> load balancing strategy</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/hostname-lb-random.yaml\ndeployment.apps/hostname-lb-edge created\nservice/hostname-lb-svc created\ndestinationrule.networking.istio.io/hostname-lb-svc created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><div class="custom-container tip"><p class="custom-container-title">TIP</p><p>EdgeMesh uses the loadBalancer property in DestinationRule to select different load balancing strategies. While using DestinationRule, the name of the DestinationRule must be equal to the name of the corresponding Service. EdgeMesh will determine the DestinationRule in the same namespace according to the name of the Service</p></div><p>Enter the test pod and use <code>curl</code> multiple times to access the service, you will see that multiple hostname-edge are randomly accessed</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl <span class="token builtin class-name">exec</span> -it alpine-test -- <span class="token function">sh</span>\n<span class="token punctuation">(</span>in the container environment<span class="token punctuation">)</span>\n/ <span class="token comment"># curl hostname-lb-svc:12345</span>\nhostname-lb-edge-7898fff5f9-w82nw\n/ <span class="token comment"># curl hostname-lb-svc:12345</span>\nhostname-lb-edge-7898fff5f9-xjp86\n/ <span class="token comment"># curl hostname-lb-svc:12345</span>\nhostname-lb-edge-7898fff5f9-xjp86\n/ <span class="token comment"># curl hostname-lb-svc:12345</span>\nhostname-lb-edge-7898fff5f9-iq39z\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><h2 id="cross-edge-cloud" tabindex="-1"><a class="header-anchor" href="#cross-edge-cloud" aria-hidden="true">
1#</a> Cross-Edge-Cloud â</h2><p>The busybox-edge in the edgezone can access the tcp-echo-cloud on the cloud, and the busybox-cloud in the cloudzone can access the tcp-echo-edge on the edge</p><p><strong>Deploy</strong></p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ kubectl apply -f examples/cloudzone.yaml\nnamespace/cloudzone created\ndeployment.apps/tcp-echo-cloud created\nservice/tcp-echo-cloud-svc created\ndeployment.apps/busybox-sleep-cloud created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>$ kubectl apply -f examples/edgezone.yaml\nnamespace/edgezone created\ndeployment.apps/tcp-echo-edge created\nservice/tcp-echo-edge-svc created\ndeployment.apps/busybox-sleep-edge created\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><strong>Cloud access edge</strong></p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ <span class="token assign-left variable">BUSYBOX_POD</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span>kubectl get all -n cloudzone <span class="token operator">|</span> <span class="token function">grep</span> pod/busybox <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $1}'</span><span class="token variable">)</span></span>\n$ kubectl -n cloudzone <span class="token builtin class-name">exec</span> <span class="token variable">$BUSYBOX_POD</span> -c busybox -i -t -- <span class="token function">sh</span>\n$ telnet tcp-echo-edge-svc.edgezone <span class="token number">2701</span>\nWelcome, you are connected to node ke-edge1.\nRunning on Pod tcp-echo-edge.\nIn namespace edgezone.\nWith IP address <span class="token number">172.17</span>.0.2.\nService default.\nHello Edge, I am Cloud.\nHello Edge, I am Cloud.\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><strong>Edge access cloud</strong></p><p>At the edge node, use <code>telnet</code> to access the service</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ <span class="token assign-left variable">BUSYBOX_CID</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span>docker <span class="token function">ps</span> <span class="token operator">|</span> <span class="token function">grep</span> k8s_busybox_busybox-sleep-edge <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $1}'</span><span class="token variable">)</span></span>\n$ docker <span class="token builtin class-name">exec</span> -it <span class="token variable">$BUSYBOX_CID</span> <span class="token function">sh</span>\n$ telnet tcp-echo-cloud-svc.cloudzone <span class="token number">2701</span>\nWelcome, you are connected to node k8s-master.\nRunning on Pod tcp-echo-cloud.\nIn namespace cloudzone.\nWith IP address <span class="token number">10.244</span>.0.8.\nService default.\nHello Cloud, I am Edge.\nHello Cloud, I am Edge.\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div>',44),h={render:function(e,n){const s=(0,a.up)("OutboundLink"),h=(0,a.up)("RouterLink");return(0,a.wg)(),(0,a.iD)(a.HY,null,[l,(0,a._)("p",null,[t,(0,a._)("a",p,[c,(0,a.Wm)(s)]),r]),o,i,(0,a._)("p",null,[d,(0,a.Wm)(h,{to:"/guide/getting-started.html"},{default:(0,a.w5)((()=>[u])),_:1}),b]),m],64)}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.