static void test_pending_calls(size_t concurrent_calls) { size_t i; grpc_call **calls; grpc_channel *client; request_data rdata; servers_fixture *f; test_spec *spec = test_spec_create(0, 4); rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * spec->num_servers); f = setup_servers("127.0.0.1", &rdata, spec->num_servers); client = create_client(f); calls = perform_multirequest(f, client, concurrent_calls); grpc_call_cancel( calls[0], NULL); /* exercise the cancel pick path whilst there are pending picks */ gpr_free(rdata.call_details); grpc_channel_destroy(client); /* calls the LB's shutdown func */ /* destroy the calls after the channel so that they are still around for the * LB's shutdown func to process */ for (i = 0; i < concurrent_calls; i++) { grpc_call_destroy(calls[i]); } gpr_free(calls); teardown_servers(f); test_spec_destroy(spec); }
void Network::init(void) { // two timers for tcp/ip timer_set(&periodic_timer, CLOCK_SECOND / 2); /* 0.5s */ timer_set(&arp_timer, CLOCK_SECOND * 10); /* 10s */ // Initialize the uIP TCP/IP stack. uip_init(); uip_setethaddr(mac_address); if (!use_dhcp) { // manual setup of ip uip_ipaddr_t tip; /* local IP address */ uip_ipaddr(tip, ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); uip_sethostaddr(tip); /* host IP address */ printf("IP Addr: %d.%d.%d.%d\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); uip_ipaddr(tip, ipgw[0], ipgw[1], ipgw[2], ipgw[3]); uip_setdraddr(tip); /* router IP address */ printf("IP GW: %d.%d.%d.%d\n", ipgw[0], ipgw[1], ipgw[2], ipgw[3]); uip_ipaddr(tip, ipmask[0], ipmask[1], ipmask[2], ipmask[3]); uip_setnetmask(tip); /* mask */ printf("IP mask: %d.%d.%d.%d\n", ipmask[0], ipmask[1], ipmask[2], ipmask[3]); setup_servers(); }else{ #if UIP_CONF_UDP dhcpc_init(mac_address, sizeof(mac_address)); dhcpc_request(); printf("Getting IP address....\n"); #endif } }
void Network::dhcpc_configured(uint32_t ipaddr, uint32_t ipmask, uint32_t ipgw) { memcpy(this->ipaddr, &ipaddr, 4); memcpy(this->ipmask, &ipmask, 4); memcpy(this->ipgw, &ipgw, 4); uip_sethostaddr((u16_t*)this->ipaddr); uip_setnetmask((u16_t*)this->ipmask); uip_setdraddr((u16_t*)this->ipgw); setup_servers(); }
static void test_ping() { grpc_channel *client; request_data rdata; servers_fixture *f; cq_verifier *cqv; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; const size_t num_servers = 1; int i; rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * num_servers); f = setup_servers("127.0.0.1", &rdata, num_servers); cqv = cq_verifier_create(f->cq); client = create_client(f); grpc_channel_ping(client, f->cq, tag(0), NULL); cq_expect_completion(cqv, tag(0), 0); /* check that we're still in idle, and start connecting */ GPR_ASSERT(grpc_channel_check_connectivity_state(client, 1) == GRPC_CHANNEL_IDLE); /* we'll go through some set of transitions (some might be missed), until READY is reached */ while (state != GRPC_CHANNEL_READY) { grpc_channel_watch_connectivity_state( client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f->cq, tag(99)); cq_expect_completion(cqv, tag(99), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(client, 0); GPR_ASSERT(state == GRPC_CHANNEL_READY || state == GRPC_CHANNEL_CONNECTING || state == GRPC_CHANNEL_TRANSIENT_FAILURE); } for (i = 1; i <= 5; i++) { grpc_channel_ping(client, f->cq, tag(i), NULL); cq_expect_completion(cqv, tag(i), 1); cq_verify(cqv); } gpr_free(rdata.call_details); grpc_channel_destroy(client); teardown_servers(f); cq_verifier_destroy(cqv); }
void run_spec(const test_spec *spec) { grpc_channel *client; char *client_hostport; char *servers_hostports_str; request_data rdata; servers_fixture *f; grpc_channel_args args; grpc_arg arg_array[2]; rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * spec->num_servers); f = setup_servers("127.0.0.1", &rdata, spec->num_servers); /* Create client. */ servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, f->num_servers, ",", NULL); gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str); arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms"; arg_array[0].value.integer = RETRY_TIMEOUT; arg_array[1].type = GRPC_ARG_STRING; arg_array[1].key = GRPC_ARG_LB_POLICY_NAME; arg_array[1].value.string = "round_robin"; args.num_args = 2; args.args = arg_array; client = grpc_insecure_channel_create(client_hostport, &args, NULL); gpr_log(GPR_INFO, "Testing '%s' with servers=%s client=%s", spec->description, servers_hostports_str, client_hostport); const request_sequences sequences = perform_request(f, client, &rdata, spec); spec->verifier(f, client, &sequences, spec->num_iters); gpr_free(client_hostport); gpr_free(servers_hostports_str); gpr_free(rdata.call_details); request_sequences_destroy(&sequences); grpc_channel_destroy(client); /* calls the LB's shutdown func */ teardown_servers(f); }
void run_spec(const test_spec *spec) { grpc_channel *client; char *client_hostport; char *servers_hostports_str; int *actual_connection_sequence; request_data rdata; servers_fixture *f; grpc_channel_args args; grpc_arg arg; rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * spec->num_servers); f = setup_servers("127.0.0.1", &rdata, spec->num_servers); /* Create client. */ servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, f->num_servers, ",", NULL); gpr_asprintf(&client_hostport, "ipv4:%s?lb_policy=round_robin", servers_hostports_str); arg.type = GRPC_ARG_INTEGER; arg.key = "grpc.testing.fixed_reconnect_backoff"; arg.value.integer = 100; args.num_args = 1; args.args = &arg; client = grpc_insecure_channel_create(client_hostport, &args, NULL); gpr_log(GPR_INFO, "Testing '%s' with servers=%s client=%s", spec->description, servers_hostports_str, client_hostport); actual_connection_sequence = perform_request(f, client, &rdata, spec); spec->verifier(f, client, actual_connection_sequence, spec->num_iters); gpr_free(client_hostport); gpr_free(servers_hostports_str); gpr_free(actual_connection_sequence); gpr_free(rdata.call_details); grpc_channel_destroy(client); /* calls the LB's shutdown func */ teardown_servers(f); }