Skip to content

Commit

Permalink
Fix code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred2g committed Feb 14, 2024
1 parent d0b4b41 commit cafef44
Showing 1 changed file with 18 additions and 27 deletions.
45 changes: 18 additions & 27 deletions tests/v3/connection_state_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3048,41 +3048,32 @@ static int s_test_mqtt_connection_publish_QoS1_timeout_with_ping_fn(struct aws_a
state_test_data->expected_ops_completed = 1;
aws_mutex_unlock(&state_test_data->lock);

uint16_t packet_id_1 = aws_mqtt_client_connection_publish(
state_test_data->mqtt_connection,
&pub_topic,
AWS_MQTT_QOS_AT_LEAST_ONCE,
false,
&payload_1,
s_on_op_complete,
state_test_data);
ASSERT_TRUE(packet_id_1 > 0);

aws_thread_current_sleep(1000000000);
for (int i = 0; i < 10; i++) {
uint16_t packet_id_1 = aws_mqtt_client_connection_publish(
state_test_data->mqtt_connection,
&pub_topic,
AWS_MQTT_QOS_AT_LEAST_ONCE,
false,
&payload_1,
s_on_op_complete,
state_test_data);
ASSERT_TRUE(packet_id_1 > 0);

packet_id_1 = aws_mqtt_client_connection_publish(
state_test_data->mqtt_connection,
&pub_topic,
AWS_MQTT_QOS_AT_LEAST_ONCE,
false,
&payload_1,
s_on_op_complete,
state_test_data);
ASSERT_TRUE(packet_id_1 > 0);
// sleep 1 second
aws_thread_current_sleep(1000000000);
}

// Wait for 2 seconds
// Wait for 3 seconds
aws_thread_current_sleep(3000000000);

// make sure we are still receiveing pings when the connection is down, in other words ping pushoff is not happening
ASSERT_INT_EQUALS(1, mqtt_mock_server_get_ping_count(state_test_data->mock_server));

/* publish should complete after the shutdown */
s_wait_for_ops_completed(state_test_data);
//ASSERT_INT_EQUALS(4l, mqtt_mock_server_get_ping_count(state_test_data->mock_server));
ASSERT_TRUE(mqtt_mock_server_get_ping_count(state_test_data->mock_server) > 1);

aws_channel_shutdown(state_test_data->server_channel, AWS_OP_SUCCESS);

/* Check the publish has been completed with timeout error */
ASSERT_UINT_EQUALS(state_test_data->op_complete_error, AWS_ERROR_MQTT_TIMEOUT);
/* publish should complete after the shutdown */
s_wait_for_ops_completed(state_test_data);

ASSERT_SUCCESS(
aws_mqtt_client_connection_disconnect(state_test_data->mqtt_connection, s_on_disconnect_fn, state_test_data));
Expand Down

0 comments on commit cafef44

Please sign in to comment.