Skip to content

ESRestTestCase - assertWarnings does not work #36251

Closed
@markharwood

Description

@markharwood

When we deprecate a server endpoint, REST test clients start failing and there's no way to write tests that check the particular warnings issued.

Rest tests currently have a stark choice:

  • fail all uses of deprecated calls in a test class (setStrictDeprecationMode=true)
  • ignore all deprecation warnings in a test class (setStrictDeprecationMode=false)

What we'd ideally like is to be able to write tests that check the deprecated calls we make produce the warnings we'd expect and the ESTestCase base class already has a method to do just this: assertWarnings.

Sadly, assertWarnings currently only works in server-side tests. It relies on ThreadLocals populated by calls to DeprecationLogger deep down in the server call stack. These warnings do not get materialised in remote clients like ESRestTestCase. Ideally the Rest client would be able to take the HTTP warning headers it already knows about in Response.getWarnings() and make them available for checks in ESTestCase.assertWarnings. Maybe we could achieve that by also having a form of DeprecationLogger on the client? At the very least, assertWarnings should throw an Unsupported exception in ESRestTestCase if we don't have the means to propagate warnings.

Related: @nik9000 has #36126 in flight for LLRC which helps shift the failure strictness from a class level to a method level but I don't think that helps fulfil the goal of making EsRestTestCase.assertWarnings work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    >bug>testIssues or PRs that are addressing/adding testsv7.0.0-beta1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions