Skip to content

Commit

Permalink
Increase repeat count for dir-make to reduce test flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Nov 3, 2024
1 parent 284d26e commit cb5264d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 33 deletions.
21 changes: 1 addition & 20 deletions source/server/model/group_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# 1. Manifest has explicit version (2)
# 2. avatars() does 1 read, not 64 reads.
# 3. TODO: Store JSON in pretty format.
# 3. TODO: Store JSON in pretty format?
# 4. TODO: Stores file contents in lined format?

class Group_v2
Expand All @@ -17,8 +17,6 @@ def initialize(externals)
@externals = externals
end

# - - - - - - - - - - - - - - - - - - - - - -

def create(manifest)
manifest.merge!(default_options)
manifest['version'] = 2
Expand All @@ -31,17 +29,13 @@ def create(manifest)
id
end

# - - - - - - - - - - - - - - - - - - -

def manifest(id)
manifest_src = disk.assert(manifest_read_command(id))
manifest = json_parse(manifest_src)
polyfill_manifest_defaults(manifest)
manifest
end

# - - - - - - - - - - - - - - - - - - - - - -

def join(id, indexes)
taken = katas_indexes(id).map{ |index,_| index }
indexes -= taken
Expand All @@ -62,8 +56,6 @@ def join(id, indexes)
end
end

# - - - - - - - - - - - - - - - - - - - - - -

def joined(id)
result = {}
katas_indexes(id).each.with_index(0) do |(group_index,kata_id),index|
Expand All @@ -82,8 +74,6 @@ def joined(id)
include Options
include PolyFiller

# - - - - - - - - - - - - - - - - - - - - - -

def katas_indexes(id)
katas_src = disk.assert(katas_read_command(id))
# G2ws77 15
Expand All @@ -101,14 +91,10 @@ def katas_indexes(id)
# ]
end

# - - - - - - - - - - - - - - - - - - - - - -

def dir_make_command(id, *parts)
disk.dir_make_command(dir_name(id, *parts))
end

# - - - - - - - - - - - - - - - - - - - - - -

def manifest_create_command(id, manifest_src)
disk.file_create_command(manifest_filename(id), manifest_src)
end
Expand All @@ -117,8 +103,6 @@ def manifest_read_command(id)
disk.file_read_command(manifest_filename(id))
end

# - - - - - - - - - - - - - - - - - - - - - -

def katas_create_command(id, src)
disk.file_create_command(katas_filename(id), src)
end
Expand All @@ -131,7 +115,6 @@ def katas_read_command(id)
disk.file_read_command(katas_filename(id))
end

# - - - - - - - - - - - - - -
# names of dirs/files

def dir_name(id, *parts)
Expand All @@ -153,8 +136,6 @@ def katas_filename(id)
# zhTLfa 32
end

# - - - - - - - - - - - - - -

def disk
@externals.disk
end
Expand Down
5 changes: 2 additions & 3 deletions source/server/model/id_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def self.id?(s)
s.chars.all?{ |ch| ALPHABET.include?(ch) }
end

# - - - - - - - - - - - - - - - - - - -

def initialize(externals)
@externals = externals
end
Expand All @@ -37,7 +35,7 @@ def kata_id
include IdPather

def generate_id(pather, not_pather)
42.times.find do
256.times.find do
id = SIZE.times.map{ ALPHABET[random_index] }.join
if reserved?(id)
next
Expand All @@ -57,6 +55,7 @@ def generate_id(pather, not_pather)

return id
end
nil
end

def reserved?(id)
Expand Down
4 changes: 2 additions & 2 deletions test/server/config/check_test_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def table_data

[
[ nil ],
[ 'test.count', stats['test_count'], '>=', 308 ],
[ 'test.count', stats['test_count'], '>=', 310 ],
[ 'test.duration', stats['total_time'], '<=', 100 ],
[ nil ],
[ 'test.failures', stats['failure_count'], '<=', 0 ],
[ 'test.errors', stats['error_count'], '<=', 0 ],
[ 'test.skips', stats['skip_count'], '<=', 0 ],
[ nil ],
[ 'test.lines.total', test_cov['lines' ]['total' ], '<=', 1773 ],
[ 'test.lines.total', test_cov['lines' ]['total' ], '<=', 1781 ],
[ 'test.lines.missed', test_cov['lines' ]['missed'], '<=', 0 ],
[ 'test.branches.total', test_cov['branches']['total' ], '<=', 12 ],
[ 'test.branches.missed', test_cov['branches']['missed'], '<=', 0 ],
Expand Down
19 changes: 15 additions & 4 deletions test/server/disk_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,32 @@ def id58_setup
# - - - - - - - - - - - - - - - - - - - - - - - - -
# dir_exists?() dir_make()

disk_tests '601',
disk_tests '501',
'dir_exists?(k) is false before dir_make(k) and true after' do
dirname = 'groups/34/f6/01'
dirname = 'groups/34/f5/01'
refute disk.run(dir_exists_command(dirname))
disk.run(dir_make_command(dirname))
assert disk.run(dir_exists_command(dirname))
end

disk_tests '602',
disk_tests '502',
'dir_make succeeds once and then fails' do
dirname = 'groups/r5/s6/02'
dirname = 'groups/r5/s5/02'
refute disk.run(dir_exists_command(dirname))
assert disk.run(dir_make_command(dirname))
refute disk.run(dir_make_command(dirname))
end

disk_tests '503',
'dir_make succeeds when it only has to create the last dir' do
dirname = 'groups/q4/s5'
refute disk.run(dir_exists_command(dirname))
assert disk.run(dir_make_command(dirname))
dirname += '/03'
refute disk.run(dir_exists_command(dirname))
assert disk.run(dir_make_command(dirname))
end

# - - - - - - - - - - - - - - - - - - - - - - - - -
# file_create()

Expand Down
8 changes: 4 additions & 4 deletions test/server/id_generation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ def self.id58_prefix
# - - - - - - - - - - - - - - - - - - -

test '13e', %w(
kata-id generation tries 42 times and then gives up and returns nil
kata-id generation tries 256 times and then gives up and returns nil
) do
id_generator = stubbed_id_generator(saver_offline_id*42)
id_generator = stubbed_id_generator(saver_offline_id*256)
assert_nil id_generator.kata_id
end

# - - - - - - - - - - - - - - - - - - -

test '13f', %w(
group-id generation tries 42 times and then gives up and returns nil
group-id generation tries 256 times and then gives up and returns nil
) do
id_generator = stubbed_id_generator(saver_offline_id*42)
id_generator = stubbed_id_generator(saver_offline_id*256)
assert_nil id_generator.group_id
end

Expand Down

0 comments on commit cb5264d

Please sign in to comment.