[asterisk-bugs] [JIRA] (ASTERISK-24834) DNS Overhaul: Implement the proposed core API - sync/async functions, resolver registration
Joshua Colp (JIRA)
noreply at issues.asterisk.org
Wed Mar 11 06:43:40 CDT 2015
[ https://issues.asterisk.org/jira/browse/ASTERISK-24834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joshua Colp updated ASTERISK-24834:
-----------------------------------
Reviewboard Link: https://reviewboard.asterisk.org/r/4474/
> DNS Overhaul: Implement the proposed core API - sync/async functions, resolver registration
> -------------------------------------------------------------------------------------------
>
> Key: ASTERISK-24834
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-24834
> Project: Asterisk
> Issue Type: New Feature
> Security Level: None
> Components: Core/General
> Affects Versions: SVN, 13.0.0
> Reporter: Matt Jordan
> Assignee: Joshua Colp
>
> Note that this is part of the task to improve Asterisk's DNS support in the core. See [Asterisk DNS API|https://wiki.asterisk.org/wiki/display/~jcolp/Asterisk+DNS+API] for more information.
> h3. Implementation Outline
> As a first step towards having a more robust DNS capability in Asterisk that all modules can use, this task is to implement the core APIs of the proposed DNS API as well as add unit tests for them. This includes:
> * Implementing the synchronous/asynchronous APIs in {{dns.h}}. It should:
> ** Implement the {{ast_dns_record}} structure including its accessors.
> ** Provide a stub for the {{ast_dns_query}} structure. This does not have to include the full implementation of this structure, as later tasks will fill in more of it, but a basic query object is needed for the resolver.
> ** Implement the {{ast_dns_record}} structure including its accessors.
> * Implement the APIs in {{dns_resolver.h}}. The implementation should allow for a resolver registration to 'swap' out if unit testing is enabled to allow for unit testing of both the resolver API as well as the core DNS API.
> * Implement unit tests for the APIs in both {{dns.h}} and {{dns_resolver.h}}. A rough outline of what the tests should cover is below.
> h3. Unit Testing
> h4. {{dns_resolver.h}}
> *NOTE:* Additional unit tests may be needed and/or can be combined if necessary.
> * {{ast_dns_resolver_register}}
> ** Verify that it properly registers a resolver implementation
> ** Verify that a resolver implementation cannot be registered twice
> ** Verify that a NULL resolver implementation is handled
> * {{ast_dns_resolver_unregister}}
> ** Verify that a registered implementation can be unregistered
> ** Verify that an attempt to unregister an implementation that does not exist is handled gracefully
> ** Verify that a NULL resolver implementation is handled
> * {{ast_dns_resolver_set_data}}/{{ast_dns_resolver_get_data}}
> ** Verify that data can be set/retrieved from a query structure
> ** Verify that setting data on a query structure with data is handled gracefully
> ** Verify that removing data that is not set is handled
> * {{ast_dns_resolver_completed}}
> ** Verify that calling this on a query with data results in the data being removed
> ** Verify that calling this on a query without data is handled
> * {{ast_dns_resolver_add_record}}
> ** Verify that a nominal record can be added
> ** Verify that calling with this no {{data}} results in a failure
> ** Verify that calling with an invalid {{rr_type}} results in a failure
> ** Verify that calling with an invalid {{rr_class}} results in a failure
> ** Verify that calling with an invalid {{ttl}} results in a failure
> * {{ast_dns_resolver_set_result}}
> ** Verify that a nominal result can be added
> ** Verify that a nominal bogus result can be added
> ** Verify that adding a result without a canonical name fails
> h4. {{dns.h}}
> Note that these tests will require writing a mock resolver. The API needs to allow for a test module to insert itself as the resolver, and remove itself when the unit tests have completed.
> * {{ast_dns_query}} accessors for {{ast_dns_result}}
> ** Verify that {{ast_dns_query_get_result}} can pull a result from a query structure
> ** Verify that multiple calls to {{ast_dns_query_get_result}} return the same result
> ** Verify that {{ast_dns_query_get_result}} returns NULL if there is no result on a query structure
> * {{ast_dns_result}} accessors
> ** Verify that {{ast_dns_result_get_nxdomain}} returns the {{nxdomain}} value on a result
> ** Verify that {{ast_dns_result_get_secure}} returns the {{secure}} value on a result
> ** Verify that {{ast_dns_result_get_bogus}} returns the {{bogus}} value on a result
> ** Verify that {{ast_dns_result_get_canonical}} returns the value of {{canonical}}
> ** Verify that {{ast_dns_result_get_records}} returns the record when only when record exists
> ** Verify that {{ast_dns_result_get_records}} returns the record whe multiple records exist
> ** Verify that {{ast_dns_result_get_records}} returns NULL when no records exist
> * {{ast_dns_record}} accessors
> ** Verify that {{ast_dns_record_get_rr_type}} returns the record type
> ** Verify that {{ast_dns_record_get_rr_class}} returns the record class
> ** Verify that {{ast_dns_record_get_ttl}} returns the record's TTL
> ** Verify that {{ast_dns_record_get_data}} returns the record data
> ** Verify that {{ast_dns_record_get_next}} returns NULL if there was only one record
> ** Verify that {{ast_dns_record_get_next}} returns the next record when there are multiple records
> ** Verify that {{ast_dns_record_get_next}} returns NULL when there are no more records
> * Resolving
> ** Verify that calling {{ast_dns_resolve_async}} calls a mock resolver's resolve callback
> ** Verify that calling {{ast_dns_resolve_async}} returns an error if a resolver does not support asynchronous resolution
> ** Verify that calling {{ast_dns_resolve_async_recurring}} calls a mock resolver's resolve callback
> ** Verify that {{ast_dns_resolve_async_recurring}} will call a mock resolver's resolve callback ever TTL seconds
> ** Verify that calling {{ast_dns_resolve_cancel}} stops a {{ast_dns_resolve_async_recurring}} and calls a mock resolver's cancel callback
> ** Verify that calling {{ast_dns_resolve_cancel}} stops a {{ast_dns_resolve_async}} and calls a mock resolver's cancel callback
> ** Verify that calling {{ast_dns_resolve_cancel}} after {{ast_dns_resolve_async}} has fired fails
> ** Verify that calling {{ast_dns_resolve}} on a resolver that does not support synchronous resolving fails
> ** Verify that calling {{ast_dns_resolve}} on a resolver calls a mock resolver's resolve callback
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list