Skip to content

Commit

Permalink
CI: upload example db for random test (#4837)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoucheng361 authored May 11, 2024
1 parent cfaffa1 commit 19279bf
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 25 deletions.
23 changes: 22 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,31 @@ 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')
print(f'profile is {profile}')
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')
print(f'profile is {profile}')
settings.load_profile(profile)
juicefs_machine = JuicefsMachine.TestCase()
juicefs_machine.runTest()
Expand Down
22 changes: 21 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,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])
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=30, 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')
print(f'profile is {profile}')
settings.load_profile(profile)

s3machine = S3Machine.TestCase()
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/command2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,27 @@ jobs:
echo "after remove unused software"
sudo df -h
fi
- 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: 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 -E 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
if: always()
with:
name: hypothesis-example-db
path: .hypothesis/examples

- name: Log
if: always()
run: |
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/fsrand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,28 @@ jobs:
run: |
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 -E 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
19 changes: 17 additions & 2 deletions .github/workflows/gateway2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,26 @@ jobs:
- name: Test with example
run: |
sudo python3 .github/scripts/hypo/s3_test.py
sudo -E 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
sudo -E 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()
Expand Down

0 comments on commit 19279bf

Please sign in to comment.