Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoucheng361 committed May 11, 2024
1 parent 8498f77 commit 34bcacf
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 22 deletions.
22 changes: 21 additions & 1 deletion .github/scripts/hypo/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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()
Expand Down
22 changes: 17 additions & 5 deletions .github/scripts/hypo/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -505,24 +506,35 @@ 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])
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()
Expand Down
21 changes: 20 additions & 1 deletion .github/scripts/hypo/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/command2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/fsrand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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: |
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/gateway2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,26 @@ jobs:
- name: Test with example
run: |
sudo python3 .github/scripts/hypo/s3_test.py
- name: Download example database
uses: dawidd6/[email protected]
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: |
Expand Down

0 comments on commit 34bcacf

Please sign in to comment.