1
1
Add test suite for netlink and weighted reachable components.  We
don't have a great way of running components through unit tests
today, so make them stand-alone tests that are run with mpirun
and such.

Signed-off-by: Brian Barrett <bbarrett@amazon.com>
Этот коммит содержится в:
Gabe Saba 2017-07-29 00:00:40 +00:00 коммит произвёл Brian Barrett
родитель ae122c4b17
Коммит c6235a9a0f
6 изменённых файлов: 1315 добавлений и 0 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -682,3 +682,6 @@ test/util/opal_path_nfs
test/util/opal_path_nfs.out
test/util/opal_bit_ops
test/util/bipartite_graph
opal/test/reachable/reachable_netlink
opal/test/reachable/reachable_weighted

19
opal/test/reachable/Makefile Обычный файл
Просмотреть файл

@ -0,0 +1,19 @@
# Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
# reserved.
#
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
PROGS = reachable_weighted reachable_netlink
all: $(PROGS)
CC = ortecc
CFLAGS = -g
clean:
rm -f $(PROGS) *~

196
opal/test/reachable/reachable_netlink.c Обычный файл
Просмотреть файл

@ -0,0 +1,196 @@
/*
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#include "opal_config.h"
#include "reachable_shared.h"
#include "opal/runtime/opal.h"
#include "opal/mca/reachable/reachable.h"
#include "opal/util/if.h"
#include "opal/class/opal_list.h"
#include "opal/util/if.h"
/*
* Creates list of remote interfaces for testing reachability.
* Only minimum information is filled out.
*/
opal_list_t* build_if_list(void)
{
/* Allocate memory for and create interface list */
opal_list_t *if_list = OBJ_NEW(opal_list_t);
opal_if_t *intf;
/*
* Add localhost to list
*/
intf = create_if(AF_INET, "127.0.0.1", 8, 0);
opal_list_append(if_list, &(intf->super));
/*
* Add localhost with non-standard address
*/
intf = create_if(AF_INET, "127.31.41.59", 8, 0);
opal_list_append(if_list, &(intf->super));
/*
* Add another localhost with non-standard address
*/
intf = create_if(AF_INET, "127.26.53.58", 8, 0);
opal_list_append(if_list, &(intf->super));
/*
* Google's public DNS
*/
intf = create_if(AF_INET, "8.8.8.8", 16, 0);
opal_list_append(if_list, &(intf->super));
/*
* Google's public DNS (2)
*/
intf = create_if(AF_INET, "8.8.4.4", 16, 0);
opal_list_append(if_list, &(intf->super));
/*
* IPv6: Google's public DNS (IPv6)
*/
intf = create_if(AF_INET6, "2001:4860:4860::8888", 64, 0);
opal_list_append(if_list, &(intf->super));
/*
* IPv6: Google's public DNS 2 (IPv6)
*/
intf = create_if(AF_INET6, "2001:4860:4860::8844", 128, 0);
opal_list_append(if_list, &(intf->super));
/*
* IPv6: Google's public DNS 1 (IPv6) EXPLICIT ADDRESS
*/
intf = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8888", 64, 0);
opal_list_append(if_list, &(intf->super));
/*
* IPv6: Google's public DNS 2 (IPv6) EXPLICIT ADDRESS
*/
intf = create_if(AF_INET6, "2001:4860:4860:0:0:0:0:8844", 64, 0);
opal_list_append(if_list, &(intf->super));
/*
* IPv6: something that should be on the same link local...
*/
intf = create_if(AF_INET6, "fe80::0001", 64, 0);
opal_list_append(if_list, &(intf->super));
return if_list;
}
int main(int argc, char **argv)
{
opal_list_t *local_list, *remote_list;
opal_reachable_t *results;
uint32_t i, j;
int successful_connections = 0;
int local_ifs;
int remote_ifs;
opal_if_t *local_if;
opal_init(&argc, &argv);
/* List of interfaces generated by opal */
local_list = &opal_if_list;
/* Create test interfaces */
remote_list = build_if_list();
local_ifs = opal_list_get_size(local_list);
remote_ifs = opal_list_get_size(remote_list);
/* Tests reachability by looking up entries in routing table.
* Tests routes to localhost and google's nameservers.
*/
results = opal_reachable.reachable(local_list, remote_list);
printf("Local interfaces:\n");
i = 0;
OPAL_LIST_FOREACH(local_if, local_list, opal_if_t) {
char addr[128];
char *family;
switch (local_if->af_family) {
case AF_INET:
family = "IPv4";
inet_ntop(AF_INET, &(((struct sockaddr_in*) &local_if->if_addr))->sin_addr,
addr, sizeof(addr));
break;
case AF_INET6:
family = "IPv6";
inet_ntop(AF_INET6, &(((struct sockaddr_in6*) &local_if->if_addr))->sin6_addr,
addr, sizeof(addr));
break;
default:
family = "Unknown";
strcpy(addr, "Unknown");
break;
}
printf(" %3d: %s\t%s\t%s/%d\n", i, local_if->if_name,
family, addr, local_if->if_mask);
i++;
}
printf("\nRemote interfaces:\n");
i = 0;
OPAL_LIST_FOREACH(local_if, remote_list, opal_if_t) {
char addr[128];
char *family;
switch (local_if->af_family) {
case AF_INET:
family = "IPv4";
inet_ntop(AF_INET, &(((struct sockaddr_in*) &local_if->if_addr))->sin_addr,
addr, sizeof(addr));
break;
case AF_INET6:
family = "IPv6";
inet_ntop(AF_INET6, &(((struct sockaddr_in6*) &local_if->if_addr))->sin6_addr,
addr, sizeof(addr));
break;
default:
family = "Unknown";
strcpy(addr, "Unknown");
break;
}
printf(" %3d: %s\t%s\t%s/%d\n", i, local_if->if_name,
family, addr, local_if->if_mask);
i++;
}
printf("\nConnectivity Table:\n ");
for (j = 0 ; j < remote_ifs ; j++) {
printf("%3d ", j);
}
printf("\n");
for (i = 0; i < local_ifs ; i++) {
printf(" %3d: ", i);
for (j = 0 ; j < remote_ifs ; j++) {
printf("%3d ", results->weights[i][j]);
}
printf("\n");
}
printf("\n");
OBJ_RELEASE(remote_list);
opal_output(0, "Passed all tests!\n");
return 0;
}

70
opal/test/reachable/reachable_shared.h Обычный файл
Просмотреть файл

@ -0,0 +1,70 @@
/*
* Copyright (c) 2017-XXXX Amazon.com, Inc. or its affiliates.
* All Rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef TEST_REACHABLE_SHARED
#define TEST_REACHABLE_SHARED 1
#include <assert.h>
#include "opal/runtime/opal.h"
#include "opal/mca/reachable/reachable.h"
#include "opal/util/if.h"
BEGIN_C_DECLS
/* Create and populate opal_if_t with information required by opal_reachable */
opal_if_t* create_if(int af_family, char *address, int mask, int bandwidth)
{
opal_if_t *interface = OBJ_NEW(opal_if_t);
strncpy(interface->if_name, "interface0", IF_NAMESIZE);
interface->af_family = af_family;
((struct sockaddr *)&(interface->if_addr))->sa_family = af_family;
if (AF_INET == af_family){
assert(1 == inet_pton(af_family, address, &((struct sockaddr_in *)&(interface->if_addr))->sin_addr));
} else if (AF_INET6 == af_family){
assert(1 == inet_pton(af_family, address, &((struct sockaddr_in6 *)&(interface->if_addr))->sin6_addr));
}
interface->if_mask = mask;
interface->if_bandwidth = bandwidth;
return interface;
}
/* Run a test between a pair of interfaces
* and clean up the memory afterwards.
* Return the weight between the pair of
* interfaces
*/
int run_single_test(opal_if_t *local_if, opal_if_t *remote_if)
{
opal_list_t *local_list = OBJ_NEW(opal_list_t);
opal_list_t *remote_list = OBJ_NEW(opal_list_t);
opal_list_append(local_list, &(local_if->super));
opal_list_append(remote_list, &(remote_if->super));
opal_reachable_t *results;
results = opal_reachable.reachable(local_list, remote_list);
OBJ_RELEASE(local_list);
OBJ_RELEASE(remote_list);
int result = results->weights[0][0];
/* release results */
OBJ_RELEASE(results);
return result;
}
END_C_DECLS
#endif

1015
opal/test/reachable/reachable_weighted.c Обычный файл

Разница между файлами не показана из-за своего большого размера Загрузить разницу

12
opal/test/reachable/tests Исполняемый файл
Просмотреть файл

@ -0,0 +1,12 @@
#!/bin/bash
# Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
# reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
mpirun -np 1 --mca reachable netlink reachable_netlink
mpirun -np 1 --mca reachable weighted reachable_weighted