Skip to content

Commit 15d0303

Browse files
committed
ci: display port usage information
It might help to identify the reason of flaky test `test_replicaset_bootstrap_cartridge_app_second_bootstrap` when/if it fails next time. Needed for #TNTP-3709
1 parent 350bf7c commit 15d0303

File tree

8 files changed

+118
-29
lines changed

8 files changed

+118
-29
lines changed

.github/workflows/full-ci.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,27 @@ jobs:
4040
with:
4141
tarantool-version: '${{ matrix.tarantool-version }}'
4242

43-
- name: Static code check
44-
uses: ./.github/actions/static-code-check
43+
# - name: Static code check
44+
# uses: ./.github/actions/static-code-check
4545

46-
- name: Unit tests
47-
run: mage unitfull
46+
# - name: Unit tests
47+
# run: mage unitfull
4848

4949
# This server starts and listen on 8084 port that is used for tests.
5050
- name: Stop Mono server
51-
run: sudo systemctl kill mono-xsp4 || true
51+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
52+
run: |
53+
sudo netstat -tupln
54+
sudo systemctl kill mono-xsp4 || echo "failed to kill mono-xsp4 (exit status $?)"
5255
5356
- name: Integration tests
5457
env:
5558
TT_ENABLE_COREDUMP_TESTS: '1'
56-
run: mage integrationfull
59+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
60+
run: |
61+
sudo netstat -tupln
62+
while mage integrationfull; do echo "test succeed, trying another attempt..."; done
63+
# mage integrationfull || { sudo netstat -tupln; exit 1; }
5764

5865
full-ci-ce-linux-arm64:
5966
if: false
@@ -132,20 +139,27 @@ jobs:
132139
sdk-version: '${{ matrix.sdk-version }}'
133140
sdk-download-token: '${{ secrets.SDK_DOWNLOAD_TOKEN }}'
134141

135-
- name: Static code check
136-
uses: ./.github/actions/static-code-check
142+
# - name: Static code check
143+
# uses: ./.github/actions/static-code-check
137144

138-
- name: Unit tests
139-
run: mage unitfull
145+
# - name: Unit tests
146+
# run: mage unitfull
140147

141148
# This server starts and listen on 8084 port that is used for tests.
142149
- name: Stop Mono server
143-
run: sudo systemctl kill mono-xsp4 || true
150+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
151+
run: |
152+
sudo netstat -tupln
153+
sudo systemctl kill mono-xsp4 || echo "failed to kill mono-xsp4 (exit status $?)"
144154
145155
- name: Integration tests
146156
env:
147157
TT_ENABLE_COREDUMP_TESTS: '1'
148-
run: mage integrationfull
158+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
159+
run: |
160+
sudo netstat -tupln
161+
while mage integrationfull; do echo "test succeed, trying another attempt..."; done
162+
# mage integrationfull || { sudo netstat -tupln; exit 1; }
149163

150164
full-ci-macOS:
151165
if: false

.github/workflows/tests.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,25 @@ jobs:
4848
with:
4949
tarantool-version: '${{ matrix.tarantool-version }}'
5050

51-
- name: Static code check
52-
uses: ./.github/actions/static-code-check
51+
# - name: Static code check
52+
# uses: ./.github/actions/static-code-check
5353

54-
- name: Unit tests
55-
run: mage unit
54+
# - name: Unit tests
55+
# run: mage unit
5656

5757
# This server starts and listen on 8084 port that is used for tests.
5858
- name: Stop Mono server
59-
run: sudo systemctl kill mono-xsp4 || true
59+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
60+
run: |
61+
sudo netstat -tupln
62+
sudo systemctl kill mono-xsp4 || echo "failed to kill mono-xsp4 (exit status $?)"
6063
6164
- name: Integration tests
62-
run: mage integration
65+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
66+
run: |
67+
sudo netstat -tupln
68+
while mage integration; do echo "test succeed, trying another attempt..."; done
69+
# mage integration || { sudo netstat -tupln; exit 1; }
6370

6471
tests-ce-linux-arm64:
6572
if: false
@@ -138,18 +145,25 @@ jobs:
138145
sdk-version: '${{ matrix.sdk-version }}'
139146
sdk-download-token: '${{ secrets.SDK_DOWNLOAD_TOKEN }}'
140147

141-
- name: Static code check
142-
uses: ./.github/actions/static-code-check
148+
# - name: Static code check
149+
# uses: ./.github/actions/static-code-check
143150

144-
- name: Unit tests
145-
run: mage unit
151+
# - name: Unit tests
152+
# run: mage unit
146153

147154
# This server starts and listen on 8084 port that is used for tests.
148155
- name: Stop Mono server
149-
run: sudo systemctl kill mono-xsp4 || true
156+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
157+
run: |
158+
sudo netstat -tupln
159+
sudo systemctl kill mono-xsp4 || echo "failed to kill mono-xsp4 (exit status $?)"
150160
151161
- name: Integration tests
152-
run: mage integration
162+
# netstat is used to help find the cause of TNTP-3709, remove it as soon as it's found.
163+
run: |
164+
sudo netstat -tupln
165+
while mage integration; do echo "test succeed, trying another attempt..."; done
166+
# mage integration || { sudo netstat -tupln; exit 1; }
153167

154168
tests-mac-os-ce:
155169
if: false

cli/replicaset/cartridge.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ func (c *CartridgeApplication) bootstrapInstance(instanceName, replicasetName st
498498
UUID: &replicasetUUID,
499499
JoinServers: joinOpts,
500500
}}
501+
fmt.Println("bootstrapInstance: opts:")
502+
for i, opt := range opts {
503+
fmt.Printf("[%d]: %+v\n", i, opt)
504+
}
501505
return cartridgeEditReplicasets(evaler, opts, timeout)
502506
}
503507

@@ -608,6 +612,7 @@ func updateCartridgeReplicasets(evaler connector.Evaler, discovered Replicasets,
608612
opts.UUID = &uuid
609613
}
610614
var err error
615+
611616
opts.JoinServers, err = getCartridgeJoinServersOpts(instancesCfg,
612617
rcfg.Instances, instanceUUID)
613618
if err != nil {
@@ -625,7 +630,47 @@ func updateCartridgeReplicasets(evaler connector.Evaler, discovered Replicasets,
625630
editOpts = append(editOpts, opts)
626631
}
627632

628-
return cartridgeEditReplicasets(evaler, editOpts, timeout)
633+
// return cartridgeEditReplicasets(evaler, editOpts, timeout)
634+
err := cartridgeEditReplicasets(evaler, editOpts, timeout)
635+
636+
var dump []string = make([]string, 0, 40)
637+
dump = append(dump, "updateCartridgeReplicasets: replicasetCfg:")
638+
for k, v := range replicasetCfg {
639+
dump = append(dump, fmt.Sprintf(" %s: %+v", k, v))
640+
}
641+
dump = append(dump, "updateCartridgeReplicasets: instancesCfg:")
642+
for k, v := range instancesCfg {
643+
dump = append(dump, fmt.Sprintf(" %s: %+v", k, v))
644+
}
645+
dump = append(dump, "updateCartridgeReplicasets: discovered:")
646+
dump = append(dump, fmt.Sprintf(" State=%s", discovered.State))
647+
dump = append(dump, fmt.Sprintf(" Orchestrator=%s", discovered.Orchestrator))
648+
for i, rs := range discovered.Replicasets {
649+
dump = append(dump, fmt.Sprintf(" [%d]: %+v", i, rs))
650+
}
651+
652+
dump = append(dump, "updateCartridgeReplicasets: setup UUID maps")
653+
for _, replicaset := range discovered.Replicasets {
654+
dump = append(dump, fmt.Sprintf(" %s: %s", replicaset.Alias, replicaset.UUID))
655+
for _, instance := range replicaset.Instances {
656+
dump = append(dump, fmt.Sprintf(" %s: %s", instance.Alias, instance.UUID))
657+
}
658+
}
659+
dump = append(dump, "updateCartridgeReplicasets: replicasetUUID:")
660+
for k, v := range replicasetUUID {
661+
dump = append(dump, fmt.Sprintf(" %s: %s", k, v))
662+
}
663+
dump = append(dump, "updateCartridgeReplicasets: instanceUUID:")
664+
for k, v := range instanceUUID {
665+
dump = append(dump, fmt.Sprintf(" %s: %s", k, v))
666+
}
667+
dump = append(dump, "updateCartridgeReplicasets: editOpts:")
668+
for i, opt := range editOpts {
669+
dump = append(dump, fmt.Sprintf("[%d]: %+v", i, opt))
670+
}
671+
fmt.Println(strings.Join(dump, "\n"))
672+
673+
return err
629674
}
630675

631676
// Expel expels an instance from a Cartridge replicasets.

cli/replicaset/lua/cartridge/edit_replicasets_body.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ local res, err = cartridge.admin_edit_topology({
55
replicasets = replicasets
66
})
77

8-
assert(res, tostring(err))
8+
assert(res, string.format("err:%s replicasets:%s", tostring(err), tostring(replicasets)))

magefile.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,18 @@ func (Unit) Coverage() error {
420420
func Integration() error {
421421
fmt.Println("Running integration tests...")
422422

423+
test_name := "test_replicaset_bootstrap_cartridge_app_second_bootstrap"
423424
return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "not slow and not slow_ee "+
424-
"and not notarantool", "test/integration")
425+
"and not notarantool", "-k", test_name, "--maxfail=1", "test/integration")
425426
}
426427

427428
// Run full set of integration tests.
428429
func IntegrationFull() error {
429430
fmt.Println("Running all integration tests...")
430431

432+
test_name := "test_replicaset_bootstrap_cartridge_app_second_bootstrap"
431433
return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "not slow_ee and not notarantool",
432-
"test/integration")
434+
"-k", test_name, "--maxfail=1", "test/integration")
433435
}
434436

435437
// Run full set of integration tests, excluding docker tests.

test/cartridge_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ def create(self):
175175
# Set replicasets config.
176176
with open(os.path.join(self.workdir, cartridge_name, "replicasets.yml"), "w") as f:
177177
f.write(yaml.dump(self.replicasets_cfg))
178+
with open(os.path.join(self.workdir, cartridge_name, "instances.yml"), "r") as f:
179+
print(f"CartridgeApp.create: instances.yml:\n{f.read()}")
180+
with open(os.path.join(self.workdir, cartridge_name, "replicasets.yml"), "r") as f:
181+
print(f"CartridgeApp.create: replicasets.yml:\n{f.read()}")
178182

179183
def build(self):
180184
cmd = [self.tt_cmd, "build", cartridge_name]

test/integration/replicaset/test_replicaset_bootstrap.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ def test_bootstrap_app_replicaset_specified(tt_cmd, tmpdir_with_cfg):
128128

129129

130130
@pytest.mark.skipif(tarantool_major_version > 2, reason="skip cartridge test for Tarantool > 2")
131+
@pytest.mark.parametrize("attempt", range(100))
131132
@pytest.mark.parametrize("flag", [None, "--cartridge"])
132-
def test_replicaset_bootstrap_cartridge_app_second_bootstrap(tt_cmd, cartridge_app, flag):
133+
def test_replicaset_bootstrap_cartridge_app_second_bootstrap(tt_cmd, cartridge_app, flag, attempt):
134+
print(f"Attempt #{attempt}")
133135
# Change the config.
134136
replicasets_cfg = {
135137
"router": {
@@ -159,8 +161,14 @@ def test_replicaset_bootstrap_cartridge_app_second_bootstrap(tt_cmd, cartridge_a
159161
"vshard_group": "default",
160162
},
161163
}
164+
with open(os.path.join(cartridge_app.workdir, cartridge_name, "instances.yml"), "r") as f:
165+
print(f"test: instances.yml:\n{f.read()}")
166+
with open(os.path.join(cartridge_app.workdir, cartridge_name, "replicasets.yml"), "r") as f:
167+
print(f"test: replicasets.yml #1:\n{f.read()}")
162168
with open(os.path.join(cartridge_app.workdir, cartridge_name, "replicasets.yml"), "w") as f:
163169
f.write(yaml.dump(replicasets_cfg))
170+
with open(os.path.join(cartridge_app.workdir, cartridge_name, "replicasets.yml"), "r") as f:
171+
print(f"test: replicasets.yml #2:\n{f.read()}")
164172

165173
# Run bootstrap after initial bootstrap again.
166174
cmd = [tt_cmd, "rs", "bootstrap"]

test/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,11 @@ def find_ports(n=1, port=8000):
446446
if s.connect_ex(("localhost", port)) == 0:
447447
busy = True
448448
break
449+
print(f"find_ports({n}): is port {port} busy... {busy}")
449450
if not busy:
450451
ports.append(port)
451452
port += 1
453+
print(f"find_ports({n}): {ports}")
452454
return ports
453455

454456

0 commit comments

Comments
 (0)