diff --git a/.github/workflows/dev_python3_10.yml b/.github/workflows/dev_python3_10.yml index 3f0ca9a..9447f9c 100644 --- a/.github/workflows/dev_python3_10.yml +++ b/.github/workflows/dev_python3_10.yml @@ -39,9 +39,5 @@ jobs: run: python ./test/unit_test/generate_report/generate_xml_report.py - name: Test Generate JSON Report run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - name: Test Executor run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.github/workflows/dev_python3_11.yml b/.github/workflows/dev_python3_11.yml index 6879d06..d5140bc 100644 --- a/.github/workflows/dev_python3_11.yml +++ b/.github/workflows/dev_python3_11.yml @@ -39,9 +39,5 @@ jobs: run: python ./test/unit_test/generate_report/generate_xml_report.py - name: Test Generate JSON Report run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - name: Test Executor run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.github/workflows/dev_python3_8.yml b/.github/workflows/dev_python3_8.yml deleted file mode 100644 index 9e695a1..0000000 --- a/.github/workflows/dev_python3_8.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: LoadDensity Dev Python 3.8 - -on: - push: - branches: [ "dev" ] - pull_request: - branches: [ "dev" ] - schedule: - - cron: "0 5 * * *" - -permissions: - contents: read - -jobs: - build_dev_version: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v3 - with: - python-version: "3.8" - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel - pip install -r dev_requirements.txt - - name: Test Fast HTTP User - run: python ./test/unit_test/user_test/fast_http_user_test.py - - name: TestMulti Action User - run: python ./test/unit_test/user_test/http_user_test.py - - name: Test Callback - run: python ./test/unit_test/callback_test/callback_test.py - - name: Test Create Project - run: python ./test/unit_test/create_project/create_project.py - - name: Test Generate HTML Report - run: python ./test/unit_test/generate_report/generate_html_report.py - - name: Test Generate XML Report - run: python ./test/unit_test/generate_report/generate_xml_report.py - - name: Test Generate JSON Report - run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - - name: Test Executor - run: python ./test/unit_test/executor_test/execute.py - diff --git a/.github/workflows/dev_python3_9.yml b/.github/workflows/dev_python3_9.yml index 10b8c82..0290fe0 100644 --- a/.github/workflows/dev_python3_9.yml +++ b/.github/workflows/dev_python3_9.yml @@ -39,9 +39,5 @@ jobs: run: python ./test/unit_test/generate_report/generate_xml_report.py - name: Test Generate JSON Report run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - name: Test Executor run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.github/workflows/stable_python3_10.yml b/.github/workflows/stable_python3_10.yml index 491a5ee..8978647 100644 --- a/.github/workflows/stable_python3_10.yml +++ b/.github/workflows/stable_python3_10.yml @@ -39,9 +39,5 @@ jobs: run: python ./test/unit_test/generate_report/generate_xml_report.py - name: Test Generate JSON Report run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - name: Test Executor run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.github/workflows/stable_python3_11.yml b/.github/workflows/stable_python3_11.yml index 882625f..2bec6e8 100644 --- a/.github/workflows/stable_python3_11.yml +++ b/.github/workflows/stable_python3_11.yml @@ -39,9 +39,5 @@ jobs: run: python ./test/unit_test/generate_report/generate_xml_report.py - name: Test Generate JSON Report run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - name: Test Executor run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.github/workflows/stable_python3_8.yml b/.github/workflows/stable_python3_8.yml deleted file mode 100644 index 3feacb9..0000000 --- a/.github/workflows/stable_python3_8.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: LoadDensity Stable Python3.8 - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - schedule: - - cron: "0 5 * * *" - -permissions: - contents: read - -jobs: - build_stable_version: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v3 - with: - python-version: "3.8" - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel - pip install -r requirements.txt - - name: Test Fast HTTP User - run: python ./test/unit_test/user_test/fast_http_user_test.py - - name: TestMulti Action User - run: python ./test/unit_test/user_test/http_user_test.py - - name: Test Callback - run: python ./test/unit_test/callback_test/callback_test.py - - name: Test Create Project - run: python ./test/unit_test/create_project/create_project.py - - name: Test Generate HTML Report - run: python ./test/unit_test/generate_report/generate_html_report.py - - name: Test Generate XML Report - run: python ./test/unit_test/generate_report/generate_xml_report.py - - name: Test Generate JSON Report - run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - - name: Test Executor - run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.github/workflows/stable_python3_9.yml b/.github/workflows/stable_python3_9.yml index cece06c..305420f 100644 --- a/.github/workflows/stable_python3_9.yml +++ b/.github/workflows/stable_python3_9.yml @@ -39,9 +39,5 @@ jobs: run: python ./test/unit_test/generate_report/generate_xml_report.py - name: Test Generate JSON Report run: python ./test/unit_test/generate_report/generate_json_report.py - - name: Test Interval Scheduler - run: python ./test/unit_test/scheduler_test/sec_interval_test.py - - name: Test Cron Scheduler - run: python ./test/unit_test/scheduler_test/sec_cron_test.py - name: Test Executor run: python ./test/unit_test/executor_test/execute.py \ No newline at end of file diff --git a/.idea/LoadDensity.iml b/.idea/LoadDensity.iml index 74d515a..527ea03 100644 --- a/.idea/LoadDensity.iml +++ b/.idea/LoadDensity.iml @@ -2,9 +2,10 @@ + - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index d1dce60..e82c1ba 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/dev.toml b/dev.toml index 010ac42..ed18548 100644 --- a/dev.toml +++ b/dev.toml @@ -6,15 +6,15 @@ build-backend = "setuptools.build_meta" [project] name = "je_load_density_dev" -version = "0.0.66" +version = "0.0.67" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] description = "Load & Stress Automation Freamework" requires-python = ">=3.9" -license = { text = "MIT" } +license-files = ["LICENSE"] dependencies = [ - "locust", "APScheduler", + "locust", ] classifiers = [ "Programming Language :: Python :: 3.9", @@ -22,7 +22,6 @@ classifiers = [ "Environment :: Win32 (MS Windows)", "Environment :: MacOS X", "Environment :: X11 Applications", - "License :: OSI Approved :: MIT License", "Operating System :: OS Independent" ] @@ -35,8 +34,6 @@ Code = "https://github.com/Intergration-Automation-Testing/LoadDensity" file = "README.md" content-type = "text/markdown" -[tool.setuptools] -license-files = ["LICENSE"] [tool.setuptools.packages] find = { namespaces = false } diff --git a/je_load_density/__init__.py b/je_load_density/__init__.py index 552370f..0b65804 100644 --- a/je_load_density/__init__.py +++ b/je_load_density/__init__.py @@ -41,11 +41,8 @@ from je_load_density.utils.project.create_project_structure import create_project_dir -# Scheduler -from je_load_density.utils.scheduler.extend_apscheduler import SchedulerManager - __all__ = [ - "create_env", "start_test", "SchedulerManager", + "create_env", "start_test", "locust_wrapper_proxy", "prepare_env", "prepare_env", "test_record_instance", diff --git a/je_load_density/utils/executor/action_executor.py b/je_load_density/utils/executor/action_executor.py index b7a8a48..5537710 100644 --- a/je_load_density/utils/executor/action_executor.py +++ b/je_load_density/utils/executor/action_executor.py @@ -12,7 +12,6 @@ from je_load_density.utils.generate_report.generate_xml_report import generate_xml, generate_xml_report from je_load_density.utils.json.json_file.json_file import read_action_json from je_load_density.utils.package_manager.package_manager_class import package_manager -from je_load_density.utils.scheduler.extend_apscheduler import scheduler_manager from je_load_density.wrapper.start_wrapper.start_test import start_test @@ -31,15 +30,6 @@ def __init__(self): "LD_execute_action": self.execute_action, "LD_execute_files": self.execute_files, "LD_add_package_to_executor": package_manager.add_package_to_executor, - # Scheduler - "LD_scheduler_event_trigger": self.scheduler_event_trigger, - "LD_remove_blocking_scheduler_job": scheduler_manager.remove_blocking_job, - "LD_remove_nonblocking_scheduler_job": scheduler_manager.remove_nonblocking_job, - "LD_start_blocking_scheduler": scheduler_manager.start_block_scheduler, - "LD_start_nonblocking_scheduler": scheduler_manager.start_nonblocking_scheduler, - "LD_start_all_scheduler": scheduler_manager.start_all_scheduler, - "LD_shutdown_blocking_scheduler": scheduler_manager.shutdown_blocking_scheduler, - "LD_shutdown_nonblocking_scheduler": scheduler_manager.shutdown_nonblocking_scheduler, } # get all builtin function and add to event dict for function in getmembers(builtins, isbuiltin): @@ -108,17 +98,6 @@ def execute_files(self, execute_files_list: list): execute_detail_list.append(self.execute_action(read_action_json(file))) return execute_detail_list - def scheduler_event_trigger( - self, function: str, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, scheduler_type: str = "nonblocking", wait_type: str = "secondly", - wait_value: int = 1, **trigger_args: Any) -> None: - if scheduler_type == "nonblocking": - scheduler_event = scheduler_manager.nonblocking_scheduler_event_dict.get(wait_type) - else: - scheduler_event = scheduler_manager.blocking_scheduler_event_dict.get(wait_type) - scheduler_event(self.event_dict.get(function), id, args, kwargs, wait_value, **trigger_args) - - executor = Executor() package_manager.executor = executor diff --git a/je_load_density/utils/scheduler/__init__.py b/je_load_density/utils/scheduler/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/je_load_density/utils/scheduler/extend_apscheduler.py b/je_load_density/utils/scheduler/extend_apscheduler.py deleted file mode 100644 index 36abd01..0000000 --- a/je_load_density/utils/scheduler/extend_apscheduler.py +++ /dev/null @@ -1,215 +0,0 @@ -from datetime import datetime -from typing import Callable, Any, Union - -from apscheduler.job import Job -from apscheduler.schedulers.background import BackgroundScheduler -from apscheduler.schedulers.blocking import BlockingScheduler -from apscheduler.util import undefined - - -class SchedulerManager(object): - - def __init__(self): - self._blocking_schedulers: BlockingScheduler = BlockingScheduler() - self._background_schedulers: BackgroundScheduler = BackgroundScheduler() - self.blocking_scheduler_event_dict = { - "secondly": self.add_interval_blocking_secondly, - "minutely": self.add_interval_blocking_minutely, - "hourly": self.add_interval_blocking_hourly, - "daily": self.add_interval_blocking_daily, - "weekly": self.add_interval_blocking_weekly, - } - self.nonblocking_scheduler_event_dict = { - "secondly": self.add_interval_nonblocking_secondly, - "minutely": self.add_interval_nonblocking_minutely, - "hourly": self.add_interval_nonblocking_hourly, - "daily": self.add_interval_nonblocking_daily, - "weekly": self.add_interval_nonblocking_weekly, - } - - def add_blocking_job( - self, func: Callable, trigger: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, id: str = None, name: str = None, - misfire_grace_time: int = undefined, coalesce: bool = undefined, max_instances: int = undefined, - next_run_time: datetime = undefined, jobstore: str = 'default', executor: str = 'default', - replace_existing: bool = False, **trigger_args: Any) -> Job: - """ - Just an apscheduler add job wrapper. - :param func: callable (or a textual reference to one) to run at the given time - :param str|apscheduler.triggers.base.BaseTrigger trigger: trigger that determines when - ``func`` is called - :param list|tuple args: list of positional arguments to call func with - :param dict kwargs: dict of keyword arguments to call func with - :param str|unicode id: explicit identifier for the job (for modifying it later) - :param str|unicode name: textual description of the job - :param int misfire_grace_time: seconds after the designated runtime that the job is still - allowed to be run (or ``None`` to allow the job to run no matter how late it is) - :param bool coalesce: run once instead of many times if the scheduler determines that the - job should be run more than once in succession - :param int max_instances: maximum number of concurrently running instances allowed for this - job - :param datetime next_run_time: when to first run the job, regardless of the trigger (pass - ``None`` to add the job as paused) - :param str|unicode jobstore: alias of the job store to store the job in - :param str|unicode executor: alias of the executor to run the job with - :param bool replace_existing: ``True`` to replace an existing job with the same ``id`` - (but retain the number of runs from the existing one) - :return: Job - """ - params = locals() - params.pop("self") - params.pop("trigger_args") - return self._blocking_schedulers.add_job(**params, **trigger_args) - - def add_nonblocking_job( - self, func: Callable, trigger: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, id: str = None, name: str = None, - misfire_grace_time: int = undefined, coalesce: bool = undefined, max_instances: int = undefined, - next_run_time: datetime = undefined, jobstore: str = 'default', executor: str = 'default', - replace_existing: bool = False, **trigger_args: Any) -> Job: - """ - Just an apscheduler add job wrapper. - :param func: callable (or a textual reference to one) to run at the given time - :param str|apscheduler.triggers.base.BaseTrigger trigger: trigger that determines when - ``func`` is called - :param list|tuple args: list of positional arguments to call func with - :param dict kwargs: dict of keyword arguments to call func with - :param str|unicode id: explicit identifier for the job (for modifying it later) - :param str|unicode name: textual description of the job - :param int misfire_grace_time: seconds after the designated runtime that the job is still - allowed to be run (or ``None`` to allow the job to run no matter how late it is) - :param bool coalesce: run once instead of many times if the scheduler determines that the - job should be run more than once in succession - :param int max_instances: maximum number of concurrently running instances allowed for this - job - :param datetime next_run_time: when to first run the job, regardless of the trigger (pass - ``None`` to add the job as paused) - :param str|unicode jobstore: alias of the job store to store the job in - :param str|unicode executor: alias of the executor to run the job with - :param bool replace_existing: ``True`` to replace an existing job with the same ``id`` - (but retain the number of runs from the existing one) - :return: Job - """ - params = locals() - params.pop("self") - params.pop("trigger_args") - return self._background_schedulers.add_job(**params, **trigger_args) - - def get_blocking_scheduler(self) -> BlockingScheduler: - """ - Return self blocking scheduler - :return: BlockingScheduler - """ - return self._blocking_schedulers - - def get_nonblocking_scheduler(self) -> BackgroundScheduler: - """ - Return self background scheduler - :return: BackgroundScheduler - """ - return self._background_schedulers - - def start_block_scheduler(self, *args: Any, **kwargs: Any) -> None: - """ - Start blocking scheduler - :return: None - """ - self._blocking_schedulers.start(*args, **kwargs) - - def start_nonblocking_scheduler(self, *args: Any, **kwargs: Any) -> None: - """ - Start background scheduler - :return: None - """ - self._background_schedulers.start(*args, **kwargs) - - def start_all_scheduler(self, *args: Any, **kwargs: Any) -> None: - """ - Start background and blocking scheduler - :return: None - """ - self._blocking_schedulers.start(*args, **kwargs) - self._background_schedulers.start(*args, **kwargs) - - def add_interval_blocking_secondly( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, seconds: int = 1, **trigger_args: Any) -> Job: - return self.add_blocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, seconds=seconds, **trigger_args) - - def add_interval_blocking_minutely( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, minutes: int = 1, **trigger_args: Any) -> Job: - return self.add_blocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, minutes=minutes, **trigger_args) - - def add_interval_blocking_hourly( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, hours: int = 1, **trigger_args: Any) -> Job: - return self.add_blocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, hours=hours, **trigger_args) - - def add_interval_blocking_daily( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, days: int = 1, **trigger_args: Any) -> Job: - return self.add_blocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, days=days, **trigger_args) - - def add_interval_blocking_weekly( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, weeks: int = 1, **trigger_args: Any) -> Job: - return self.add_blocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, weeks=weeks, **trigger_args) - - def add_interval_nonblocking_secondly( - self, function: Callable, id: str = None, args: list = None, - kwargs: dict = None, seconds: int = 1, **trigger_args: Any) -> Job: - return self.add_nonblocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, seconds=seconds, **trigger_args) - - def add_interval_nonblocking_minutely( - self, function: Callable, id: str = None, args: list = None, - kwargs: dict = None, minutes: int = 1, **trigger_args: Any) -> Job: - return self.add_nonblocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, minutes=minutes, **trigger_args) - - def add_interval_nonblocking_hourly( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, hours: int = 1, **trigger_args: Any) -> Job: - return self.add_nonblocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, hours=hours, **trigger_args) - - def add_interval_nonblocking_daily( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, days: int = 1, **trigger_args: Any) -> Job: - return self.add_nonblocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, days=days, **trigger_args) - - def add_interval_nonblocking_weekly( - self, function: Callable, id: str = None, args: Union[list, tuple] = None, - kwargs: dict = None, weeks: int = 1, **trigger_args: Any) -> Job: - return self.add_nonblocking_job( - func=function, trigger="interval", id=id, args=args, kwargs=kwargs, weeks=weeks, **trigger_args) - - def add_cron_blocking( - self, function: Callable, id: str = None, **trigger_args: Any) -> Job: - return self.add_blocking_job(func=function, id=id, trigger="cron", **trigger_args) - - def add_cron_nonblocking( - self, function: Callable, id: str = None, **trigger_args: Any) -> Job: - return self.add_nonblocking_job(func=function, id=id, trigger="cron", **trigger_args) - - def remove_blocking_job(self, id: str, jobstore: str = 'default') -> Any: - return self._blocking_schedulers.remove_job(job_id=id, jobstore=jobstore) - - def remove_nonblocking_job(self, id: str, jobstore: str = 'default') -> Any: - return self._background_schedulers.remove_job(job_id=id, jobstore=jobstore) - - def shutdown_blocking_scheduler(self, wait: bool = False) -> None: - self._blocking_schedulers.shutdown(wait=wait) - - def shutdown_nonblocking_scheduler(self, wait: bool = False) -> None: - self._background_schedulers.shutdown(wait=wait) - - -scheduler_manager = SchedulerManager() diff --git a/je_load_density/wrapper/create_locust_env/create_locust_env.py b/je_load_density/wrapper/create_locust_env/create_locust_env.py index 85c3ad2..601f580 100644 --- a/je_load_density/wrapper/create_locust_env/create_locust_env.py +++ b/je_load_density/wrapper/create_locust_env/create_locust_env.py @@ -26,7 +26,7 @@ def prepare_env(user_class: [User], user_count: int = 50, spawn_rate: int = 10, f"prepare_env, user_class: {user_class}, user_count: {user_count}, spawn_rate: {spawn_rate}, " f"test_time: {test_time}, web_ui_dict: {web_ui_dict}" ) - env = create_env(user_class) + env = create_env(user_class, another_event=events) env.runner.start(user_count, spawn_rate=spawn_rate) if web_ui_dict is not None: env.create_web_ui(web_ui_dict.get("host", "127.0.0.1"), web_ui_dict.get("port", 8089)) diff --git a/pyproject.toml b/pyproject.toml index 2c6ca7c..8a1b332 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,16 +6,15 @@ build-backend = "setuptools.build_meta" [project] name = "je_load_density" -version = "0.0.56" +version = "0.0.57" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] description = "Load & Stress Automation Freamework" requires-python = ">=3.9" -license = { text = "MIT" } +license-files = ["LICENSE"] dependencies = [ "locust", - "APScheduler", ] classifiers = [ "Programming Language :: Python :: 3.9", @@ -23,7 +22,6 @@ classifiers = [ "Environment :: Win32 (MS Windows)", "Environment :: MacOS X", "Environment :: X11 Applications", - "License :: OSI Approved :: MIT License", "Operating System :: OS Independent" ] @@ -36,8 +34,5 @@ Code = "https://github.com/Intergration-Automation-Testing/LoadDensity" file = "README.md" content-type = "text/markdown" -[tool.setuptools] -license-files = ["LICENSE"] - [tool.setuptools.packages] find = { namespaces = false }