OCI.Inspector (oci v0.0.6)

View Source

Helper functions for debugging OCI conformance tests.

This module provides utilities for inspecting and debugging OCI (Open Container Initiative) conformance tests. It allows for runtime inspection of request details and process state, and provides a way to set up debugging breakpoints during test execution of specific tests so you don't have to breakpoint through hundreds of unrelated requests.

Usage

The module is primarily used in conjunction with OCI conformance tests. When a request includes the x-oci-conformance-test header, the inspector will track the request and enable debugging capabilities.

Add a x-oci-conformance-test header to the request to enable debugging in the appropriate Distribution Spec (example: 02 Push Test):

req.SetHeader("x-oci-conformance-test", g.CurrentSpecReport().FullText())

In elixir, put an OCI.Inspector.inspect/2 call in your plug pipeline to enable debugging. When a header comes through for inspection, the proccess dictionary will be populated with the request id and the test name to enable granular breakpointing by specific HTTP requests, not just line number.

def call(conn, %{registry: registry}) do
  conn =
    conn
    |> put_private(:oci_registry, registry)
    |> authenticate()
    |> OCI.Inspector.inspect("after:authenticate/1")
end

Put a debugger at the line of code you want to breakpoint and pass in the binding(), the breakpoint will only trigger for the specific HTTP request.

def verify_digest(data, digest) do
  OCI.Inspector.pry(binding())
  # ... code
end

Features

  • Request inspection with detailed logging
  • Process state tracking
  • Runtime debugging capabilities
  • Test case identification

Summary

Types

t()

Represents the state of an OCI Inspector instance.

Functions

Inspects an incoming request and sets up debugging context if it's a conformance test.

Sets up a debugging breakpoint for the current process if it's part of a conformance test.

Types

t()

@type t() :: %OCI.Inspector{test: String.t()}

Represents the state of an OCI Inspector instance.

Functions

inspect(conn, label \\ "none")

@spec inspect(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Inspects an incoming request and sets up debugging context if it's a conformance test.

Parameters

  • conn - The Plug.Conn struct representing the incoming request
  • label - Optional label for the inspection output (default: "none")

Returns

  • The unmodified Plug.Conn struct

Examples

iex> conn = Plug.Conn.put_req_header(conn, "x-oci-conformance-test", "test-name")
iex> OCI.Inspector.inspect(conn)
%Plug.Conn{...}

log_info(conn, test, label)

pry(binding)

@spec pry(Keyword.t()) :: nil | any()

Sets up a debugging breakpoint for the current process if it's part of a conformance test.

This function will only activate the debugger if the process has been marked as part of a conformance test by a previous call to inspect/2.

Parameters

  • binding - The current binding context for the debugger

Returns

  • nil if no inspector context is found
  • The result of IEx.pry() if inspector context exists