To answer this question I set up a similar test suite and again ran the tests through the WAMulator to see what the http payload looked like. The test suite code is shown below. Details of the interaction with the REST API are encapsulated within the ohids object (short for the class name OAMHostIdentifierService) which I can share if there is interest. I'm using Spring to auto-wire and inject that service. And I'm using Java's UUID class to create some host names that won't conflict with real values already in our test environment. TestNG is being used as the framework for running these tests and sequencing them using its dependsOnMethods aspect.
Note that I do some validation in all but the two tests where I attempt to get the Host Identifier by the two DNS names embedded in the originally created Host Identifier. I don't know what to expect and I want the tests will to run to completion and, as any test should, clean up any relics of the test so that we are back to the state that we were in before running the tests. Of course if some of the other tests failed I'd have to go clean up the objects manually so it isn't completely rock solid.
private String identifierName
= "it--" + UUID.randomUUID().toString();
private String dnsName1
= "it--dns-" + UUID.randomUUID().toString();
private String dnsName2
= "it--dns-" + UUID.randomUUID().toString();
private String identifierId = null;
@Test
public void createHostIdentifierTwoDnsHosts() {
List<Host> hosts = new ArrayList<Host>();
hosts.add(new Host(dnsName1));
hosts.add(new Host(dnsName2));
OAMHostIdentifier id
= new OAMHostIdentifier( identifierName, hosts);
String response = ohids.createHostIdentifier(endpoint, id);
Assert.assertTrue(response.contains("?id="),
"successful creation should return URL for accessing new object");
// cache returned id for use in verifying other tests
// split around the characters "?id=" in returned URL
identifierId = response.split("\\?id\\=")[1];
}
@Test(dependsOnMethods = "createHostIdentifierTwoDnsHosts")
public void getHostIdentifierByName() {
OAMHostIdentifier id
= ohids.getHostIdentifierByName(endpoint, identifierName, Resources.CACHE.NOT_ALLOWED);
Assert.assertNotNull(id, "search for host identifier by name should not return null.");
Assert.assertEquals(id.getId(), identifierId, "search for host identifier by name should return identifier with same ID.");
}
@Test(dependsOnMethods = "getHostIdentifierByName")
public void getHostIdentifierById() {
OAMHostIdentifier id
= ohids.getHostIdentifierById(endpoint, identifierId, Resources.CACHE.NOT_ALLOWED);
Assert.assertNotNull(id, "search for host identifier by id should not return null.");
Assert.assertEquals(id.getId(), id.getId(), "search for host identifier by id should return identifier with same ID.");
}
@Test(dependsOnMethods = "getHostIdentifierById")
public void getHostIdentifierByDnsHost1() {
OAMHostIdentifier id
= ohids.getHostIdentifierByName(endpoint, dnsName1, Resources.CACHE.NOT_ALLOWED);
System.out.println((id == null ? "Host Identifier NOT found by DNS-1 name" : "Host Identifier found by DNS-1 name"));
}
@Test(dependsOnMethods = "getHostIdentifierByDnsHost1")
public void getHostIdentifierByDnsHost2() {
OAMHostIdentifier id
= ohids.getHostIdentifierByName(endpoint, dnsName2, Resources.CACHE.NOT_ALLOWED);
System.out.println((id == null ? "Host Identifier NOT found by DNS-2 name" : "Host Identifier found by DNS-2 name"));
}
@Test(dependsOnMethods = "getHostIdentifierByDnsHost2")
public void deleteHostIdentifierById() {
String msg = ohids.deleteHostIdentifierById(endpoint, identifierId);
Assert.assertNotNull(msg, "delete host identifier should not return null.");
Assert.assertTrue(msg.contains("HostIdentifier is deleted"), "delete host identifier response should contain the text, 'HostIdentifier is deleted'.");
}
The tests run successfully to completion. However, when I look at the console output for each test I note that the requests for the Host Identifier by DNS name both show the answer I was seeking:
Host Identifier NOT found by DNS-1 name
Host Identifier NOT found by DNS-2 name
And when looking at the http traffic as it passes through the WAMulator for getting the Host Identifier by name or Id I see the following payload being returned:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><HostIdentifiers>
<HostIdentifier>
<id>a4458dae484b04246bcea4c1804b9b9c4</id>
<name>it--74705474-6703-4d6d-adea-6595d72c2682</name>
<Hosts>
<host>
<hostName>it--dns-0a5d6dcc-2a83-4121-8fdf-d822351016e6</hostName>
</host>
<host>
<hostName>it--dns-02bf280f-4cb9-482f-bdfe-e7369023d573</hostName>
</host>
</Hosts>
</HostIdentifier>
</HostIdentifiers>
But for the queries by DNS names the result including request and response headers is as follows. Note that the request gives an http 200 response but the list of HostIdentifiers in this case is empty:
Canonical Req. Line: GET /oam/services/rest/11.1.2.0.0/ssa/policyadmin/hostidentifier?name=it--dns-0a5d6dcc-2a83-4121-8fdf-d822351016e6 HTTP/1.1
Rewritten Req. Line: GET /oam/services/rest/11.1.2.0.0/ssa/policyadmin/hostidentifier?name=it--dns-0a5d6dcc-2a83-4121-8fdf-d822351016e6 HTTP/1.1
Accept: application/xml
User-Agent: Java/1.6.0_65
Host: localhost.lds.org:8080
Connection: close
X-Wmltr: handled
X-Forwarded-Scheme: http
cctx: /{/.../*,*}
RESPONSE Bytes to CLIENT: 455
HTTP/1.1 200 OK
Date: Fri, 21 Feb 2014 16:16:50 GMT
Content-Length: 90
Content-Type: application/xml
Set-Cookie: JSESSIONID=4HD2TH7SqPJ29nbKPKLNqBF4RSjsVgvhCbGRB2ShvXLsSTLfyQD1!-955026361; path=/; HttpOnly
x-oracle-dms-ecid: 32bcdd031430eb16:7e79f4e9:144504ffa11:-8000-000000000001e7ee
x-powered-by: Servlet/2.5 JSP/2.1
Connection: close
X-ConnId: C-022
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><HostIdentifiers></HostIdentifiers>
So I've got the answer to my question. You can query OAM for a Host Identifier using its name or its id but not any of the nested DNS names that it represents.
No comments:
Post a Comment