Testing OCPP implementations

How chargers and backends are tested for OCPP: certification with the OCA test tool, open tools that check, emulate and play the backend, what to test from boot to certificate renewal, how charging profiles stack, and what the published JSON schemas do and do not catch.

Three ways to test

  • Certification: the Open Charge Alliance test tool (OCTT) plays the other side, a lab runs the test cases of the profiles the maker claims, and OCA issues a certificate. See OCPP certification.
  • Interoperability: plugfests pair each charger with each backend in turn (Interoperability test events).
  • Your own tests: emulators and test backends that you run every day, often in a build pipeline, so a change does not break what passed before.

The three answer different questions. A certificate says the listed profiles passed against the test tool. A plugfest says two products work together on the day. Your own tests say the product still does what it did last week.

Open tools

ToolPlays or checksUseful for
CheckOCPPChecks: a Wireshark dissector that validates each OCPP JSON message against the schemas (1.6, 2.0 and 2.0.1) and marks the ones that fail; needs unencrypted traffic or the TLS keys; SOAP is not coveredPassive audits of a real charger and backend pair
EmuOCPPPlays either side, with security profiles 1 to 3, on an emulated networkSecurity and robustness experiments
Monta ocpp-emulatorPlays the charger (OCPP 1.6 and 2.0.1) in a desktop appDriving a backend by hand
Solidstudio VCPPlays the charger from the terminal, with schema validationScripted and load tests of a backend
SteVe, CitrineOS, EVerest ocpp-csmsPlay the backendTesting a charger without the production backend
OCPP libraries (Mobility House ocpp, gocpp, ocpp-go)Building blocks for your own harness; the first two validate against the OCA schemasTest cases written as code

Licences and links are in Open source in EV charging: a map. None of these tools replaces a certificate, and none of them claims to run the test cases of the OCA test tool.

What to test

The areas below follow the functional blocks of OCPP 2.0.1 (the letters in the last column); OCPP 1.6 has the same topics in its feature profiles.

AreaWhat to checkOCPP 2.0.1 block
BootBootNotification after power up and after reboot; what the charger does while the answer is Pending or Rejected; the heartbeat interval it takes from the answerB, Provisioning
AuthorizationAccepted, Invalid, Blocked, Expired and Unknown tokens; the local list and the cache; how long the driver waits for an answer; a token presented again to stopC, Authorization; D, Local authorization list
TransactionsTransactionEvent Started, Updated and Ended in order, with a continuous seqNo; triggerReason and stoppedReason as they happened; where the transaction starts and stops (TxStartPoint and TxStopPoint)E, Transactions
Meter valuesSampled and clock aligned values with the configured measurands; an energy register that never goes backwards; signed values where the market needs them (Signed meter values and OCMF)J, Meter values
Smart chargingProfiles of each purpose and stack level, with validity periods, recurrence, limits in A and W, the number of phases; the composite schedule the charger reports; what happens when a profile is cleared (see the next section)K, Smart charging
Offline behaviourTransactions that start or end while the backend is unreachable, sent later with offline set to true and in order; authorization from the local list or cache while offlineE and C
ReconnectionBack off after a lost connection (RetryBackOffWaitMinimum, RetryBackOffRandomRange, RetryBackOffRepeatTimes); resending a TransactionEvent the backend did not process (MessageAttempts, MessageAttemptInterval); a StatusNotification of every connector after a long outage (OfflineThreshold)B and E
Security profilesProfile 1 (basic authentication, no TLS), 2 (TLS with basic authentication) and 3 (TLS with client certificates); refusing a weaker profile once a stronger one is set; security events reported to the backendA, Security
CertificatesRenewal of the charging station certificate started by the backend or by the charger (SignCertificate, CertificateSigned); installing and deleting CA certificates; what happens when a certificate expiresA, Security; M, ISO 15118 certificate management
FirmwareSigned firmware updates, the status notifications during the update, and a failed updateL, Firmware management

The configuration variable names above are those of the OCPP 2.0.1 device model as the EVerest implementation lists them. Check them, and the block letters, against the edition of OCPP 2.0.1 Part 2 you test to.

Smart charging profiles stack

A charger can hold several charging profiles at once, and the limit it applies at a moment is combined from them. That makes smart charging the area where two correct looking implementations most often disagree.

  • Each profile has a purpose. In OCPP 2.0.1: ChargingStationMaxProfile (a limit for the whole station), TxDefaultProfile (the default for new transactions), TxProfile (for one running transaction) and ChargingStationExternalConstraints (set by an external system, not by the backend).
  • Within a purpose, the valid profile with the highest stackLevel wins. A profile that is not yet valid, or has run out, does not count.
  • Across purposes, a TxProfile takes the place of the TxDefaultProfile for its transaction, and the result is then capped by the station maximum and by external constraints.
  • GetCompositeSchedule asks the charger for the result. Comparing it with what you expect is the most direct test.

Useful test cases: two profiles of the same purpose with different stack levels and overlapping validity; a TxDefaultProfile for all EVSEs and one for a single EVSE; a profile in W on a charger that limits in A; a period that ends during a session; ClearChargingProfile during a session. The car side of the same limit is in Smart charging: schedules, limits and grid signals and OCPP 2.0.1 and ISO 15118: the backend behind the cable.

The precedence rules summarised here are from the OCPP 2.0.1 smart charging block (K) as commonly implemented; check the edge cases (EVSE 0 against a single EVSE, and external constraints) against the specification edition you test to.

The OCPP JSON schemas

  • The OCA publishes a JSON schema file for every request and response of OCPP-J: JSON Schema draft 04 for OCPP 1.6, draft 06 for OCPP 2.0.1 and 2.1. The 2.0.1 files are marked "OCPP 2.0.1 FINAL" in their comment field.
  • The schemas are licensed by the OCA under CC BY-ND 4.0; the OCPP 2.1 files say so in their own comment field. They may be shipped unchanged with attribution, which is how libraries such as the Mobility House ocpp carry them, but a modified copy may not be shared.
  • The OCPP 2.0.1 schemas forbid fields they do not name (additionalProperties is false), so vendor data has to go into customData or a DataTransfer message.
Schema validation catchesIt does not catch
A required field that is missingA message sent at the wrong moment or in the wrong order
A value outside its enumeration, such as a misspelt reasonA reason that is valid but not what happened
A string longer than its maxLengthAn answer that came too late
A field the schema does not defineA meter value that goes backwards, or a profile applied wrongly

Schema validation is therefore the first gate, not the test. Behaviour needs test cases that look at the order and the content of messages over a whole session, which is what the OCA test tool and the areas above are about.

OCPP next to a capture

This analyzer reads an OCPP-J log of the charger next to a capture of the cable and shows it on an OCPP tab. It tells the OCPP version (1.6, 2.0.1 or 2.1) from the messages and holds every message against the OCA JSON schema of that version, which ships with the tool unchanged (OC-01). OC-02 to OC-05 check the OCPP-J framing: every call answered within ocpp.callTimeoutS, one call in flight per side, error codes the version defines, and message ids used once. OC-06 checks that the charger waits for an accepted BootNotification, OC-07 that the transaction events of 2.0.1 and 2.1 come in order with seqNo counting up, OC-08 that an OCPP 1.6 charger uses the transaction id the backend gave it, and OC-09 that each fault the charger reports carries a ChargeX Minimum Required Error Code, as a notice. PW-06 checks that the meter values the charger sends to the backend never go backwards. XL-01 to XL-05 hold the backend view against the cable: charging reported when the energy transfer starts and stops, the energy billed against the meter readings the car was shown, no energy after a rejected ID, and a stop reason that matches how the session ended. The worked backend test cases in Backend, Plug and Charge and payment test cases show which messages to look for, and the demo ocpp-rejected shows a backend that refuses a card (Worked example: the backend rejects the card).

Sources