Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test with external network disabled and aproxy setup #175

Merged
merged 35 commits into from
Jan 5, 2024

Conversation

yhaliaw
Copy link
Collaborator

@yhaliaw yhaliaw commented Dec 19, 2023

Overview

For setup of a integration test, deploy a juju machine and disable external network access in it, then deploy the charm within the juju machine with aproxy setup.

Use tinyproxy instead of proxy.py.

Rationale

This test whether the charm works in an environment with HTTP proxy.
There were previous bugs related to not all traffic is routed through the proxy.

Tinyproxy is written in C and much faster than proxy.py. Since the deployment (juju, downloading image, installing deps) will be using the proxy, switching the a faster proxy seems to reduce the chance of failure.

Checklist

src/charm.py Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has totally checked 133 files.

Valid Invalid Ignored Fixed
0 57 76 0
Click to see the invalid file list
  • actions.yaml
  • charmcraft.yaml
  • config.yaml
  • generate-src-docs.sh
  • lib/charms/grafana_agent/v0/cos_agent.py
  • metadata.yaml
  • pyproject.toml
  • scripts/build-image.sh
  • scripts/pre-integration-test.sh
  • scripts/repo_policy_compliance_service.py
  • src/charm.py
  • src/charm_state.py
  • src/errors.py
  • src/event_timer.py
  • src/firewall.py
  • src/github_client.py
  • src/github_metrics.py
  • src/github_type.py
  • src/lxd.py
  • src/lxd_type.py
  • src/metrics.py
  • src/repo_policy_compliance_client.py
  • src/runner.py
  • src/runner_logs.py
  • src/runner_manager.py
  • src/runner_manager_type.py
  • src/runner_metrics.py
  • src/runner_type.py
  • src/shared_fs.py
  • src/utilities.py
  • tests/init.py
  • tests/conftest.py
  • tests/integration/conftest.py
  • tests/integration/helpers.py
  • tests/integration/test_charm_fork_repo.py
  • tests/integration/test_charm_metrics.py
  • tests/integration/test_charm_no_runner.py
  • tests/integration/test_charm_one_runner.py
  • tests/integration/test_charm_scheduled_events.py
  • tests/integration/test_charm_with_proxy.py
  • tests/integration/test_self_hosted_runner.py
  • tests/status_name.py
  • tests/unit/init.py
  • tests/unit/conftest.py
  • tests/unit/mock.py
  • tests/unit/test_charm.py
  • tests/unit/test_charm_state.py
  • tests/unit/test_github_client.py
  • tests/unit/test_github_metrics.py
  • tests/unit/test_metrics.py
  • tests/unit/test_runner.py
  • tests/unit/test_runner_logs.py
  • tests/unit/test_runner_manager.py
  • tests/unit/test_runner_metrics.py
  • tests/unit/test_shared_fs.py
  • tests/unit/test_utilities.py
  • tox.ini

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has totally checked 133 files.

Valid Invalid Ignored Fixed
0 57 76 0
Click to see the invalid file list
  • actions.yaml
  • charmcraft.yaml
  • config.yaml
  • generate-src-docs.sh
  • lib/charms/grafana_agent/v0/cos_agent.py
  • metadata.yaml
  • pyproject.toml
  • scripts/build-image.sh
  • scripts/pre-integration-test.sh
  • scripts/repo_policy_compliance_service.py
  • src/charm.py
  • src/charm_state.py
  • src/errors.py
  • src/event_timer.py
  • src/firewall.py
  • src/github_client.py
  • src/github_metrics.py
  • src/github_type.py
  • src/lxd.py
  • src/lxd_type.py
  • src/metrics.py
  • src/repo_policy_compliance_client.py
  • src/runner.py
  • src/runner_logs.py
  • src/runner_manager.py
  • src/runner_manager_type.py
  • src/runner_metrics.py
  • src/runner_type.py
  • src/shared_fs.py
  • src/utilities.py
  • tests/init.py
  • tests/conftest.py
  • tests/integration/conftest.py
  • tests/integration/helpers.py
  • tests/integration/test_charm_fork_repo.py
  • tests/integration/test_charm_metrics.py
  • tests/integration/test_charm_no_runner.py
  • tests/integration/test_charm_one_runner.py
  • tests/integration/test_charm_scheduled_events.py
  • tests/integration/test_charm_with_proxy.py
  • tests/integration/test_self_hosted_runner.py
  • tests/status_name.py
  • tests/unit/init.py
  • tests/unit/conftest.py
  • tests/unit/mock.py
  • tests/unit/test_charm.py
  • tests/unit/test_charm_state.py
  • tests/unit/test_github_client.py
  • tests/unit/test_github_metrics.py
  • tests/unit/test_metrics.py
  • tests/unit/test_runner.py
  • tests/unit/test_runner_logs.py
  • tests/unit/test_runner_manager.py
  • tests/unit/test_runner_metrics.py
  • tests/unit/test_shared_fs.py
  • tests/unit/test_utilities.py
  • tox.ini

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has totally checked 133 files.

Valid Invalid Ignored Fixed
0 57 76 0
Click to see the invalid file list
  • actions.yaml
  • charmcraft.yaml
  • config.yaml
  • generate-src-docs.sh
  • lib/charms/grafana_agent/v0/cos_agent.py
  • metadata.yaml
  • pyproject.toml
  • scripts/build-image.sh
  • scripts/pre-integration-test.sh
  • scripts/repo_policy_compliance_service.py
  • src/charm.py
  • src/charm_state.py
  • src/errors.py
  • src/event_timer.py
  • src/firewall.py
  • src/github_client.py
  • src/github_metrics.py
  • src/github_type.py
  • src/lxd.py
  • src/lxd_type.py
  • src/metrics.py
  • src/repo_policy_compliance_client.py
  • src/runner.py
  • src/runner_logs.py
  • src/runner_manager.py
  • src/runner_manager_type.py
  • src/runner_metrics.py
  • src/runner_type.py
  • src/shared_fs.py
  • src/utilities.py
  • tests/init.py
  • tests/conftest.py
  • tests/integration/conftest.py
  • tests/integration/helpers.py
  • tests/integration/test_charm_fork_repo.py
  • tests/integration/test_charm_metrics.py
  • tests/integration/test_charm_no_runner.py
  • tests/integration/test_charm_one_runner.py
  • tests/integration/test_charm_scheduled_events.py
  • tests/integration/test_charm_with_proxy.py
  • tests/integration/test_self_hosted_runner.py
  • tests/status_name.py
  • tests/unit/init.py
  • tests/unit/conftest.py
  • tests/unit/mock.py
  • tests/unit/test_charm.py
  • tests/unit/test_charm_state.py
  • tests/unit/test_github_client.py
  • tests/unit/test_github_metrics.py
  • tests/unit/test_metrics.py
  • tests/unit/test_runner.py
  • tests/unit/test_runner_logs.py
  • tests/unit/test_runner_manager.py
  • tests/unit/test_runner_metrics.py
  • tests/unit/test_shared_fs.py
  • tests/unit/test_utilities.py
  • tox.ini

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has totally checked 133 files.

Valid Invalid Ignored Fixed
0 57 76 0
Click to see the invalid file list
  • actions.yaml
  • charmcraft.yaml
  • config.yaml
  • generate-src-docs.sh
  • lib/charms/grafana_agent/v0/cos_agent.py
  • metadata.yaml
  • pyproject.toml
  • scripts/build-image.sh
  • scripts/pre-integration-test.sh
  • scripts/repo_policy_compliance_service.py
  • src/charm.py
  • src/charm_state.py
  • src/errors.py
  • src/event_timer.py
  • src/firewall.py
  • src/github_client.py
  • src/github_metrics.py
  • src/github_type.py
  • src/lxd.py
  • src/lxd_type.py
  • src/metrics.py
  • src/repo_policy_compliance_client.py
  • src/runner.py
  • src/runner_logs.py
  • src/runner_manager.py
  • src/runner_manager_type.py
  • src/runner_metrics.py
  • src/runner_type.py
  • src/shared_fs.py
  • src/utilities.py
  • tests/init.py
  • tests/conftest.py
  • tests/integration/conftest.py
  • tests/integration/helpers.py
  • tests/integration/test_charm_fork_repo.py
  • tests/integration/test_charm_metrics.py
  • tests/integration/test_charm_no_runner.py
  • tests/integration/test_charm_one_runner.py
  • tests/integration/test_charm_scheduled_events.py
  • tests/integration/test_charm_with_proxy.py
  • tests/integration/test_self_hosted_runner.py
  • tests/status_name.py
  • tests/unit/init.py
  • tests/unit/conftest.py
  • tests/unit/mock.py
  • tests/unit/test_charm.py
  • tests/unit/test_charm_state.py
  • tests/unit/test_github_client.py
  • tests/unit/test_github_metrics.py
  • tests/unit/test_metrics.py
  • tests/unit/test_runner.py
  • tests/unit/test_runner_logs.py
  • tests/unit/test_runner_manager.py
  • tests/unit/test_runner_metrics.py
  • tests/unit/test_shared_fs.py
  • tests/unit/test_utilities.py
  • tox.ini

@yhaliaw yhaliaw marked this pull request as ready for review January 4, 2024 01:35
@yhaliaw yhaliaw requested a review from a team as a code owner January 4, 2024 01:35
jdkandersson
jdkandersson previously approved these changes Jan 4, 2024
Copy link
Collaborator

@cbartz cbartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one nitpicky comment

tests/integration/test_charm_with_proxy.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@yanksyoon yanksyoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor questions!

src/charm.py Show resolved Hide resolved
tests/integration/test_charm_with_proxy.py Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Jan 4, 2024

Test coverage for 5e9c51e

Name                         Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------
src/charm.py                   433     98    107     25    75%   79-80, 86-88, 112-113, 117-119, 155-157, 168->180, 178, 221-229, 241-245, 276, 356-361, 384, 401-402, 411-434, 452-454, 462-465, 472, 475-476, 492, 496-501, 546->549, 562-563, 565-566, 600-607, 631-632, 644-646, 661-662, 690-691, 693-694, 696-697, 771->773, 834-835, 851, 869-871, 875
src/charm_state.py              75      6     10      0    91%   90-97
src/errors.py                   37      0      0      0   100%
src/event_timer.py              42      8      4      0    74%   94-97, 117-120
src/firewall.py                 43     25     10      0    38%   38-42, 64-67, 75-149
src/github_client.py            68      6     32      3    87%   124, 146, 158-165, 183->216
src/github_metrics.py           14      0      0      0   100%
src/github_type.py              50      0      0      0   100%
src/lxd_type.py                 37      0      2      0   100%
src/metrics.py                  73      2     10      1    96%   61->64, 170-171
src/metrics_type.py              6      0      0      0   100%
src/runner.py                  320     70     96     24    73%   44->46, 125, 252-253, 294-303, 327-332, 337, 357, 361-371, 420->423, 426-428, 435, 449, 459, 463, 465, 480, 506-511, 527-540, 551-590, 595, 633, 679-681, 685, 703, 738, 764, 769-781, 795, 800->802, 805-807
src/runner_logs.py              32      4      6      2    84%   33-36, 56->55, 60-61
src/runner_manager.py          268     42     90      8    83%   122, 167-169, 182-183, 195-197, 203-208, 212-213, 223-224, 243, 321-323, 388, 407-411, 436, 488, 522, 628-641, 651, 656-667
src/runner_manager_type.py      33      0      6      0   100%
src/runner_metrics.py          123      8     20      2    93%   147-148, 160, 191-192, 307-311
src/runner_type.py              45      0     10      0   100%
src/shared_fs.py                80     10     12      0    89%   73-74, 160-161, 166-167, 173-174, 196-197
src/utilities.py                68      6     20      8    84%   74->76, 78->84, 89-91, 121, 135, 173, 226
------------------------------------------------------------------------
TOTAL                         1847    285    435     73    82%

Static code analysis report

Run started:2024-01-04 09:52:10.102123

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 4063
  Total lines skipped (#nosec): 0
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 12

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@yhaliaw yhaliaw merged commit 54a91e6 into main Jan 5, 2024
50 checks passed
@yhaliaw yhaliaw deleted the test/proxy-env branch January 5, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants