Skip to content

Commit

Permalink
Update testing docs
Browse files Browse the repository at this point in the history
Signed-off-by: khushboo-rancher <[email protected]>
  • Loading branch information
khushboo-rancher committed Mar 20, 2024
1 parent 4ab8d23 commit 4f12632
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 211 deletions.
12 changes: 12 additions & 0 deletions backend/conftest.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ <h1 class="title">Module <code>harvester_e2e_tests.conftest</code></h1>
default=config_data.get(&#39;opensuse-image-url&#39;),
help=(&#39;OpenSUSE image URL&#39;)
)
parser.addoption(
&#39;--ubuntu-image-url&#39;,
action=&#39;store&#39;,
default=config_data.get(&#39;ubuntu-image-url&#39;),
help=(&#39;ubuntu image URL&#39;)
)
parser.addoption(
&#39;--terraform-scripts-location&#39;,
action=&#39;store&#39;,
Expand Down Expand Up @@ -560,6 +566,12 @@ <h2 class="section-title" id="header-functions">Functions</h2>
default=config_data.get(&#39;opensuse-image-url&#39;),
help=(&#39;OpenSUSE image URL&#39;)
)
parser.addoption(
&#39;--ubuntu-image-url&#39;,
action=&#39;store&#39;,
default=config_data.get(&#39;ubuntu-image-url&#39;),
help=(&#39;ubuntu image URL&#39;)
)
parser.addoption(
&#39;--terraform-scripts-location&#39;,
action=&#39;store&#39;,
Expand Down
8 changes: 6 additions & 2 deletions backend/fixtures/images.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ <h1 class="title">Module <code>harvester_e2e_tests.fixtures.images</code></h1>
@pytest.fixture(scope=&#34;session&#34;)
def image_ubuntu(request):
image_server = request.config.getoption(&#34;--image-cache-url&#34;)
url = urlparse(DEFAULT_UBUNTU_IMAGE_URL)
url = urlparse(
request.config.getoption(&#34;--ubuntu-image-url&#34;) or DEFAULT_UBUNTU_IMAGE_URL
)

if image_server:
*_, image_name = url.path.rsplit(&#34;/&#34;, 1)
Expand Down Expand Up @@ -162,7 +164,9 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<pre><code class="python">@pytest.fixture(scope=&#34;session&#34;)
def image_ubuntu(request):
image_server = request.config.getoption(&#34;--image-cache-url&#34;)
url = urlparse(DEFAULT_UBUNTU_IMAGE_URL)
url = urlparse(
request.config.getoption(&#34;--ubuntu-image-url&#34;) or DEFAULT_UBUNTU_IMAGE_URL
)

if image_server:
*_, image_name = url.path.rsplit(&#34;/&#34;, 1)
Expand Down
4 changes: 2 additions & 2 deletions backend/integrations/test_1_images.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1 class="title">Module <code>harvester_e2e_tests.integrations.test_1_images</c
]


@pytest.fixture(params=[&#34;image_opensuse&#34;, &#34;image_k3s&#34;])
@pytest.fixture(params=[&#34;image_opensuse&#34;, &#34;image_ubuntu&#34;])
def image_info(request):
return request.getfixturevalue(request.param)

Expand Down Expand Up @@ -506,7 +506,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@pytest.fixture(params=[&#34;image_opensuse&#34;, &#34;image_k3s&#34;])
<pre><code class="python">@pytest.fixture(params=[&#34;image_opensuse&#34;, &#34;image_ubuntu&#34;])
def image_info(request):
return request.getfixturevalue(request.param)</code></pre>
</details>
Expand Down
42 changes: 8 additions & 34 deletions backend/integrations/test_1_volumes.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ <h1 class="title">Module <code>harvester_e2e_tests.integrations.test_1_volumes</
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from urllib.parse import urljoin

import yaml
<pre><code class="python">import yaml
import pytest

pytest_plugins = [
Expand All @@ -37,25 +35,18 @@ <h1 class="title">Module <code>harvester_e2e_tests.integrations.test_1_volumes</


@pytest.fixture(scope=&#34;module&#34;)
def focal_image_url(request):
base_url = request.config.getoption(&#34;--image-cache-url&#34;).strip()
base_url = base_url or &#34;https://cloud-images.ubuntu.com/focal/current/&#34;
return urljoin(f&#34;{base_url}/&#34;, &#34;focal-server-cloudimg-amd64.img&#34;)


@pytest.fixture(scope=&#34;module&#34;)
def focal_image(api_client, unique_name, focal_image_url, polling_for):
def focal_image(api_client, unique_name, image_ubuntu, polling_for):
image_name = f&#34;img-focal-{unique_name}&#34;

code, data = api_client.images.create_by_url(image_name, focal_image_url)
code, data = api_client.images.create_by_url(image_name, image_ubuntu.url)
assert 201 == code, f&#34;Fail to create image\n{code}, {data}&#34;
code, data = polling_for(&#34;image do created&#34;,
lambda c, d: c == 200 and d.get(&#39;status&#39;, {}).get(&#39;progress&#39;) == 100,
api_client.images.get, image_name)

namespace = data[&#39;metadata&#39;][&#39;namespace&#39;]
name = data[&#39;metadata&#39;][&#39;name&#39;]
yield dict(ssh_user=&#34;ubuntu&#34;, id=f&#34;{namespace}/{name}&#34;, display_name=image_name)
yield dict(ssh_user=image_ubuntu.ssh_user, id=f&#34;{namespace}/{name}&#34;, display_name=image_name)

code, data = api_client.images.get(image_name)
if 200 == code:
Expand Down Expand Up @@ -219,7 +210,7 @@ <h1 class="title">Module <code>harvester_e2e_tests.integrations.test_1_volumes</
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="harvester_e2e_tests.integrations.test_1_volumes.focal_image"><code class="name flex">
<span>def <span class="ident">focal_image</span></span>(<span>api_client, unique_name, focal_image_url, polling_for)</span>
<span>def <span class="ident">focal_image</span></span>(<span>api_client, unique_name, image_ubuntu, polling_for)</span>
</code></dt>
<dd>
<div class="desc"></div>
Expand All @@ -228,18 +219,18 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<span>Expand source code</span>
</summary>
<pre><code class="python">@pytest.fixture(scope=&#34;module&#34;)
def focal_image(api_client, unique_name, focal_image_url, polling_for):
def focal_image(api_client, unique_name, image_ubuntu, polling_for):
image_name = f&#34;img-focal-{unique_name}&#34;

code, data = api_client.images.create_by_url(image_name, focal_image_url)
code, data = api_client.images.create_by_url(image_name, image_ubuntu.url)
assert 201 == code, f&#34;Fail to create image\n{code}, {data}&#34;
code, data = polling_for(&#34;image do created&#34;,
lambda c, d: c == 200 and d.get(&#39;status&#39;, {}).get(&#39;progress&#39;) == 100,
api_client.images.get, image_name)

namespace = data[&#39;metadata&#39;][&#39;namespace&#39;]
name = data[&#39;metadata&#39;][&#39;name&#39;]
yield dict(ssh_user=&#34;ubuntu&#34;, id=f&#34;{namespace}/{name}&#34;, display_name=image_name)
yield dict(ssh_user=image_ubuntu.ssh_user, id=f&#34;{namespace}/{name}&#34;, display_name=image_name)

code, data = api_client.images.get(image_name)
if 200 == code:
Expand All @@ -250,22 +241,6 @@ <h2 class="section-title" id="header-functions">Functions</h2>
api_client.images.get, image_name)</code></pre>
</details>
</dd>
<dt id="harvester_e2e_tests.integrations.test_1_volumes.focal_image_url"><code class="name flex">
<span>def <span class="ident">focal_image_url</span></span>(<span>request)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@pytest.fixture(scope=&#34;module&#34;)
def focal_image_url(request):
base_url = request.config.getoption(&#34;--image-cache-url&#34;).strip()
base_url = base_url or &#34;https://cloud-images.ubuntu.com/focal/current/&#34;
return urljoin(f&#34;{base_url}/&#34;, &#34;focal-server-cloudimg-amd64.img&#34;)</code></pre>
</details>
</dd>
<dt id="harvester_e2e_tests.integrations.test_1_volumes.focal_vm"><code class="name flex">
<span>def <span class="ident">focal_vm</span></span>(<span>api_client, unique_name, focal_image, polling_for)</span>
</code></dt>
Expand Down Expand Up @@ -607,7 +582,6 @@ <h1>Index</h1>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="harvester_e2e_tests.integrations.test_1_volumes.focal_image" href="#harvester_e2e_tests.integrations.test_1_volumes.focal_image">focal_image</a></code></li>
<li><code><a title="harvester_e2e_tests.integrations.test_1_volumes.focal_image_url" href="#harvester_e2e_tests.integrations.test_1_volumes.focal_image_url">focal_image_url</a></code></li>
<li><code><a title="harvester_e2e_tests.integrations.test_1_volumes.focal_vm" href="#harvester_e2e_tests.integrations.test_1_volumes.focal_vm">focal_vm</a></code></li>
<li><code><a title="harvester_e2e_tests.integrations.test_1_volumes.test_create_volume_backing_image" href="#harvester_e2e_tests.integrations.test_1_volumes.test_create_volume_backing_image">test_create_volume_backing_image</a></code></li>
</ul>
Expand Down
Loading

0 comments on commit 4f12632

Please sign in to comment.