Contract tests define the Peer protocol against a real server

Đang mở
#372 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python

Hướng nghiên cứu

First check the network Peer protocol from blocked issue #371, then read tests/testapp/tests/integration/test_syncsession.py:56-219 for the second-server harness. Implement the mixin and network subclass in tests/testapp/tests/integration/test_peer_protocol_contract.py, run the seven contract cases and characterization suite, and confirm pytest does not collect the mixin itself.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

DEV: backend P0 - critical TAG: unit tests

Overview

A contract suite describes the expected behavior of the Peer protocol, and it runs against a real network server. This work is part of milestone M3.

Background & Motivation

Later, a disk connection must behave like a morango server. A shared contract suite makes this parity testable. The network connection is the reference implementation, so the suite starts with the network half.

The suite also gives an extra safety net for the operation refactor in milestone M4.

Design: spec. Plan: implementation plan, Task 11.

Description & Expected Outcomes

One abstract test mixin holds the contract cases. It asks each subclass for a connection, a sync session, a local transfer session, and a way to read the records that the peer holds. A network subclass runs the cases against the second-server test harness.

The contract cases are:

  • Create, then get, returns an equal PeerTransferSession.
  • An update to records_total and client_fsic shows in the next get.
  • An advance to serializing returns that stage with status completed and a server_fsic value.
  • With zero records, an advance from queuing to dequeuing returns dequeuing with status completed.
  • A push of 3 valid records gives records_transferred equal to 3.
  • A push of a record with a partition outside the filter raises an error.
  • Two close calls, and a close call for an unknown id, do not raise an error.

Deliverables & Contracts

The suite delivers these capabilities:

  • The abstract mixin is not collected as a test class by itself.
  • The network subclass passes every contract case.
  • A disk subclass can reuse every case without a change (#385).
Acceptance Criteria
  • tests/testapp/tests/integration/test_peer_protocol_contract.py contains the mixin and the network subclass.
  • All seven contract cases pass for the network subclass.
  • Pytest does not collect the mixin as a test case.
  • The characterization suite passes without edits.

Technical Pointers & Architecture

  • Target Components / Context: tests/testapp/tests/integration/.
  • Related Patterns: The second-server harness (LiveServer, second_environment, PushPullClientTestCase) at tests/testapp/tests/integration/test_syncsession.py:56-219.
  • Data Model & Schema Considerations: None.
  • Resilience & Failure Modes: The out-of-filter case raises requests.HTTPError on the network and ValidationError on disk. The case accepts both types.

Notes & Tradeoffs

  • Dependencies: Blocked by: #371 (Peer protocol on the network connection). Blocks: #385.
  • Testing Requirements: The network is the reference. If a case fails on the network, fix the case, not the connection. The characterization suite from #363 and #364 must pass without edits.
  • Tradeoffs & Alternatives Considered: A single end-to-end parity test catches less drift than a case-by-case contract. The spec keeps both.
  • Compatibility & Migrations: Tests only.

Metadata

  • Complexity: Medium
  • Target Branch: release-v0.9.x

AI Usage

Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.

Ngôn ngữ chính
Python
Star
15
Fork
27
Merge trung bình
6 ngày 44 phút
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của learningequality/morango

Tất cả issue của learningequality/morango

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.