diff --git a/.github/scripts/hypo/command.py b/.github/scripts/hypo/command.py index 09a3db6702c2..34031d9e4fee 100644 --- a/.github/scripts/hypo/command.py +++ b/.github/scripts/hypo/command.py @@ -28,6 +28,7 @@ from hypothesis import HealthCheck, assume, strategies as st, settings, Verbosity from hypothesis.stateful import rule, precondition, RuleBasedStateMachine, Bundle, initialize, multiple from hypothesis import Phase, seed +from hypothesis.database import DirectoryBasedExampleDatabase import random from common import run_cmd from strategy import * @@ -254,11 +255,30 @@ def teardown(self): if __name__ == '__main__': MAX_EXAMPLE=int(os.environ.get('MAX_EXAMPLE', '100')) STEP_COUNT=int(os.environ.get('STEP_COUNT', '50')) + ci_db = DirectoryBasedExampleDatabase(".hypothesis/examples") settings.register_profile("dev", max_examples=MAX_EXAMPLE, verbosity=Verbosity.debug, print_blob=True, stateful_step_count=STEP_COUNT, deadline=None, \ report_multiple_bugs=False, phases=[Phase.reuse, Phase.generate, Phase.target, Phase.shrink, Phase.explain]) - profile = os.environ.get('PROFILE', 'dev') + settings.register_profile("schedule", max_examples=500, verbosity=Verbosity.debug, + print_blob=True, stateful_step_count=200, deadline=None, \ + report_multiple_bugs=False, + phases=[Phase.reuse, Phase.generate, Phase.target], + database=ci_db) + settings.register_profile("pull_request", max_examples=100, verbosity=Verbosity.debug, + print_blob=True, stateful_step_count=50, deadline=None, \ + report_multiple_bugs=False, + phases=[Phase.reuse, Phase.generate, Phase.target], + database=ci_db) + + if os.environ.get('CI'): + event_name = os.environ.get('GITHUB_EVENT_NAME') + if event_name == 'schedule': + profile = 'schedule' + else: + profile = 'pull_request' + else: + profile = os.environ.get('PROFILE', 'dev') settings.load_profile(profile) juicefs_machine = JuicefsCommandMachine.TestCase() diff --git a/.github/scripts/hypo/fs.py b/.github/scripts/hypo/fs.py index 2f69b5a05ab3..f9c823b7d60d 100644 --- a/.github/scripts/hypo/fs.py +++ b/.github/scripts/hypo/fs.py @@ -15,6 +15,7 @@ from hypothesis import HealthCheck, assume, reproduce_failure, strategies as st, settings, Verbosity from hypothesis.stateful import rule, precondition, RuleBasedStateMachine, Bundle, initialize, multiple, consumes from hypothesis import Phase, seed +from hypothesis.database import DirectoryBasedExampleDatabase from strategy import * from fs_op import FsOperation import random @@ -505,6 +506,7 @@ def teardown(self): if __name__ == '__main__': MAX_EXAMPLE=int(os.environ.get('MAX_EXAMPLE', '100')) STEP_COUNT=int(os.environ.get('STEP_COUNT', '50')) + ci_db = DirectoryBasedExampleDatabase(".hypothesis/examples") settings.register_profile("dev", max_examples=MAX_EXAMPLE, verbosity=Verbosity.debug, print_blob=True, stateful_step_count=STEP_COUNT, deadline=None, \ report_multiple_bugs=False, @@ -512,17 +514,27 @@ def teardown(self): settings.register_profile("schedule", max_examples=1000, verbosity=Verbosity.debug, print_blob=True, stateful_step_count=200, deadline=None, \ report_multiple_bugs=False, - phases=[Phase.reuse, Phase.generate, Phase.target]) - settings.register_profile("pull_request", max_examples=MAX_EXAMPLE, verbosity=Verbosity.debug, - print_blob=True, stateful_step_count=STEP_COUNT, deadline=None, \ + phases=[Phase.reuse, Phase.generate, Phase.target], + database=ci_db) + settings.register_profile("pull_request", max_examples=100, verbosity=Verbosity.debug, + print_blob=True, stateful_step_count=50, deadline=None, \ report_multiple_bugs=False, - phases=[Phase.reuse, Phase.generate, Phase.target]) + phases=[Phase.reuse, Phase.generate, Phase.target], + database=ci_db) settings.register_profile("generate", max_examples=MAX_EXAMPLE, verbosity=Verbosity.debug, print_blob=True, stateful_step_count=STEP_COUNT, deadline=None, \ report_multiple_bugs=False, \ phases=[Phase.generate, Phase.target]) - profile = os.environ.get('PROFILE', 'dev') + if os.environ.get('CI'): + event_name = os.environ.get('GITHUB_EVENT_NAME') + if event_name == 'schedule': + profile = 'schedule' + else: + profile = 'pull_request' + else: + profile = os.environ.get('PROFILE', 'dev') + settings.load_profile(profile) juicefs_machine = JuicefsMachine.TestCase() juicefs_machine.runTest() diff --git a/.github/scripts/hypo/s3.py b/.github/scripts/hypo/s3.py index c074d2d6915c..8e3bb4f5a0ce 100644 --- a/.github/scripts/hypo/s3.py +++ b/.github/scripts/hypo/s3.py @@ -10,6 +10,7 @@ from hypothesis.stateful import rule, precondition, RuleBasedStateMachine, Bundle, initialize, multiple, consumes from hypothesis import Phase, seed from hypothesis import strategies as st +from hypothesis.database import DirectoryBasedExampleDatabase import random from s3_op import S3Client from s3_strategy import * @@ -545,11 +546,29 @@ def teardown(self): if __name__ == '__main__': MAX_EXAMPLE=int(os.environ.get('MAX_EXAMPLE', '100')) STEP_COUNT=int(os.environ.get('STEP_COUNT', '50')) + ci_db = DirectoryBasedExampleDatabase(".hypothesis/examples") settings.register_profile("dev", max_examples=MAX_EXAMPLE, verbosity=Verbosity.debug, print_blob=True, stateful_step_count=STEP_COUNT, deadline=None, \ report_multiple_bugs=False, phases=[Phase.reuse, Phase.generate, Phase.target]) - profile = os.environ.get('PROFILE', 'dev') + settings.register_profile("schedule", max_examples=1000, verbosity=Verbosity.debug, + print_blob=True, stateful_step_count=300, deadline=None, \ + report_multiple_bugs=False, + phases=[Phase.reuse, Phase.generate, Phase.target], + database=ci_db) + settings.register_profile("pull_request", max_examples=100, verbosity=Verbosity.debug, + print_blob=True, stateful_step_count=50, deadline=None, \ + report_multiple_bugs=False, + phases=[Phase.reuse, Phase.generate, Phase.target], + database=ci_db) + if os.environ.get('CI'): + event_name = os.environ.get('GITHUB_EVENT_NAME') + if event_name == 'schedule': + profile = 'schedule' + else: + profile = 'pull_request' + else: + profile = os.environ.get('PROFILE', 'dev') settings.load_profile(profile) s3machine = S3Machine.TestCase() diff --git a/.github/workflows/command2.yml b/.github/workflows/command2.yml index ae41dd68ec3c..9d7645d8fa9b 100644 --- a/.github/workflows/command2.yml +++ b/.github/workflows/command2.yml @@ -103,14 +103,7 @@ jobs: - name: Run All timeout-minutes: 60 run: | - if [ "${{ github.event_name }}" == "schedule" ]; then - MAX_EXAMPLE=500 - STEP_COUNT=200 - else - MAX_EXAMPLE=100 - STEP_COUNT=50 - fi - sudo MAX_EXAMPLE=$MAX_EXAMPLE STEP_COUNT=$STEP_COUNT META1=redis META2=${{matrix.meta}} .github/scripts/command/random.sh test_run_all + sudo LOG_LEVEL=WARNING META1=redis META2=${{matrix.meta}} .github/scripts/command/random.sh test_run_all - name: Upload example database uses: actions/upload-artifact@v3 diff --git a/.github/workflows/fsrand.yml b/.github/workflows/fsrand.yml index ab9a6de1e865..ec10d7b8b5ba 100644 --- a/.github/workflows/fsrand.yml +++ b/.github/workflows/fsrand.yml @@ -95,17 +95,27 @@ jobs: sudo -E python3 .github/scripts/hypo/fs_test.py sudo -E python3 .github/scripts/hypo/acl_test.py + - name: Download example database + uses: dawidd6/action-download-artifact@v2.24.3 + with: + name: hypothesis-example-db + path: .hypothesis/examples + if_no_artifact_found: warn + workflow_conclusion: completed + - name: Test timeout-minutes: 120 run: | - if [ "${{ github.event_name }}" == "schedule" ]; then - PROFILE='schedule' - else - PROFILE='pull_request' - fi - sudo -E PROFILE=${PROFILE} LOG_LEVEL=WARNING python3 .github/scripts/hypo/fs.py 2>&1 | tee fsrand.log + sudo LOG_LEVEL=WARNING python3 .github/scripts/hypo/fs.py 2>&1 | tee fsrand.log exit ${PIPESTATUS[0]} + - name: Upload example database + uses: actions/upload-artifact@v3 + if: always() + with: + name: hypothesis-example-db + path: .hypothesis/examples + - name: check fsrand.log if: always() run: | diff --git a/.github/workflows/gateway2.yml b/.github/workflows/gateway2.yml index 2eb3104d88b6..8fc4c393762d 100644 --- a/.github/workflows/gateway2.yml +++ b/.github/workflows/gateway2.yml @@ -102,11 +102,26 @@ jobs: - name: Test with example run: | sudo python3 .github/scripts/hypo/s3_test.py - + + - name: Download example database + uses: dawidd6/action-download-artifact@v2.24.3 + with: + name: hypothesis-example-db + path: .hypothesis/examples + if_no_artifact_found: warn + workflow_conclusion: completed + - name: Test randomly run: | sudo LOG_LEVEL=WARNING python3 .github/scripts/hypo/s3.py + - name: Upload example database + uses: actions/upload-artifact@v3 + if: always() + with: + name: hypothesis-example-db + path: .hypothesis/examples + - name: check log if: always() run: |