Skip to content

Commit d55f162

Browse files
wu-shengclaude
andcommitted
chore(test): upgrade the mock collector and drop the seed workaround
The pinned mock-collector image dated from October 2022, 13 commits behind the tool's master. Move it to c6b91a0e, which carries the fix for the first-insert race in SegmentItems/LogItems (apache/skywalking-agent-test-tool#65): when two processes reported their first segment for the same service name concurrently, the collector silently dropped one while both reporters got HTTP 200. sw_fork_support worked around that race by seeding the service name with a parent-only /ping request and waiting for the collector to register it before triggering the concurrent parent/child reports. The collector no longer needs the help, so the endpoint, the seed step and the extra expected segment are gone and the test is back to asserting exactly the cross-fork trace it is about. The upgrade also picks up the validator changes made since 2022 (stricter span validation in #53, LogAssert ordering in #59, string operators in #49, protocol update in #63), so the full plugin matrix on CI is the real verification here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8020a1c commit d55f162

4 files changed

Lines changed: 3 additions & 47 deletions

File tree

tests/plugin/docker-compose.base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ version: '2.1'
2020

2121
services:
2222
collector:
23-
image: ghcr.io/apache/skywalking-agent-test-tool/mock-collector:7f20775e0631356c4823d9372b09d653db0e6540
23+
image: ghcr.io/apache/skywalking-agent-test-tool/mock-collector:c6b91a0eaef16d427268e9806d5df65949e2a9bf
2424
ports:
2525
- 19876:19876
2626
- 12800:12800

tests/plugin/web/sw_fork_support/expected.data.yml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,8 @@
1717

1818
segmentItems:
1919
- serviceName: provider
20-
segmentSize: 3
20+
segmentSize: 2
2121
segments:
22-
- segmentId: not null
23-
spans:
24-
- operationName: /ping
25-
parentSpanId: -1
26-
spanId: 0
27-
spanLayer: Http
28-
tags:
29-
- key: http.method
30-
value: GET
31-
- key: http.url
32-
value: http://0.0.0.0:9090/ping
33-
- key: http.status_code
34-
value: '200'
35-
startTime: gt 0
36-
endTime: gt 0
37-
componentId: 7001
38-
spanType: Entry
39-
peer: not null
40-
skipAnalysis: false
4122
- segmentId: not null
4223
spans:
4324
- operationName: /users

tests/plugin/web/sw_fork_support/services/app.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ def users():
5050

5151
frontend = Flask('frontend')
5252

53-
# readiness/warm-up endpoint: its segment arrives alone and seeds the service name
54-
# in the mock collector, whose first-insert for a service is not concurrency-safe
55-
# (SegmentItems.addSegmentItem check-then-act) — the parent and child later report
56-
# their /users segments concurrently under the same service name
57-
@frontend.route('/ping', methods=['GET'])
58-
def ping():
59-
return jsonify({'song': 'Despacito'})
60-
6153
@frontend.route('/users', methods=['GET'])
6254
def call_backend():
6355
res = requests.get('http://127.0.0.1:9091/users', timeout=5)

tests/plugin/web/sw_fork_support/test_fork_support.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
import time
1817
from typing import Callable
1918

2019
import pytest
@@ -26,10 +25,7 @@
2625
@pytest.fixture
2726
def prepare():
2827
# type: () -> Callable
29-
# /ping (parent-only) also seeds the service name in the mock collector before the
30-
# parent and child post their /users segments concurrently: the collector's very first
31-
# insert for a service name is not concurrency-safe and can silently drop one segment
32-
return lambda *_: requests.get('http://0.0.0.0:9090/ping', timeout=5).raise_for_status()
28+
return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5).raise_for_status()
3329

3430

3531
class TestPlugin(TestPluginBase):
@@ -44,19 +40,6 @@ class TestPlugin(TestPluginBase):
4440

4541
@pytest.mark.parametrize('version', ['grpcio>=1.83'])
4642
def test_plugin(self, docker_compose, version):
47-
# the /ping seed segment must be REGISTERED by the collector before /users makes
48-
# the parent and child report concurrently, otherwise all three segments can be
49-
# in flight together and the collector's first-insert race still drops one
50-
for _ in range(30):
51-
if '/ping' in requests.get('http://localhost:12800/receiveData', timeout=5).text:
52-
break
53-
time.sleep(1)
54-
else:
55-
raise Exception('the /ping seed segment never reached the collector')
56-
57-
response = requests.get('http://0.0.0.0:9090/users', timeout=5)
58-
assert response.status_code == 200
59-
6043
self.validate()
6144

6245
stdout, stderr = docker_compose.get_logs()

0 commit comments

Comments
 (0)