Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provisioning client retry after DNS failure #1455

Merged
merged 3 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c-utility
2 changes: 1 addition & 1 deletion deps/uhttp
Submodule uhttp updated 1 files
+1 −1 deps/c-utility
93 changes: 93 additions & 0 deletions doc/updating_submodules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Updating submodules for the C SDK

## Commands

```bash
git checkout master
git pull

cd c-utility
git checkout master
git pull
git submodule update --init --recursive
cd ..

cd uamqp
git checkout master
git pull
cd deps/azure-c-shared-utility/
git checkout master
git pull
git submodule update --init --recursive
cd ..

git checkout -b SubmoduleUpdate
git add c-utility
git commit -m "Update azure-c-sharedutils reference"
git push --set-upstream origin SubmoduleUpdate
cd ..

cd umqtt
git checkout master
git pull
cd deps/c-utility
git checkout master
git pull
git submodule update --init --recursive
cd ..

git checkout -b SubmoduleUpdate
git add c-utility
git commit -m "Update azure-c-sharedutils reference"
git push --set-upstream origin SubmoduleUpdate
cd ..

cd deps/uhttp
git checkout master
git pull

cd deps/c-utility
git checkout master
git pull
git submodule update --init --recursive
cd ....

git checkout -b SubmoduleUpdate
git add deps/c-utility
git commit -m "Update azure-c-sharedutils reference"
git push --set-upstream origin SubmoduleUpdate
cd ....

cd provisioning_client/deps/utpm
git checkout master
git pull
cd deps/c-utility
git checkout master
git pull
git submodule update --init --recursive
cd ....

git checkout -b SubmoduleUpdate
git add deps/c-utility
git commit -m "Update azure-c-sharedutils reference"
git push --set-upstream origin SubmoduleUpdate
cd ......

git add c-utility
git add uamqp
git add umqtt
git add deps/uhttp
git add provisioning_client/deps/utpm
git commit -m "Update submodule references"
git push --set-upstream origin SubmoduleUpdate
```

## Testing

The following requires NodeJS and NPM.

`npm install check_submodules`

Run:

`/node_modules/.bin/check_submodules . master`
2 changes: 1 addition & 1 deletion provisioning_client/deps/utpm
Submodule utpm updated 1 files
+1 −1 deps/c-utility
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ MU_DEFINE_ENUM_STRINGS_WITHOUT_INVALID(PROV_DEVICE_REG_STATUS, PROV_DEVICE_REG_S
static const char* global_prov_uri = "global.azure-devices-provisioning.net";
static const char* id_scope = "[ID Scope]";

static bool g_registration_complete = false;
volatile static bool g_registration_complete = false;
static bool g_use_proxy = false;
static const char* PROXY_ADDRESS = "127.0.0.1";

Expand Down
18 changes: 14 additions & 4 deletions provisioning_client/src/prov_device_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,20 @@ PROV_DEVICE_HANDLE Prov_Device_Create(const char* uri, const char* id_scope, PRO
{
/* Codes_SRS_PROV_DEVICE_CLIENT_12_006: [ The function shall call the LL layer Prov_Device_LL_Create function and return with it's result. ] */
result->ProvDeviceLLHandle = Prov_Device_LL_Create(uri, id_scope, protocol);
/* Codes_SRS_PROV_DEVICE_CLIENT_12_007: [ The function shall initialize the result datastructure. ] */
result->ThreadHandle = NULL;
result->StopThread = 0;
result->do_work_freq_ms = DO_WORK_FREQ_DEFAULT;
if (result->ProvDeviceLLHandle == NULL)
{
/* Codes_SRS_PROV_DEVICE_CLIENT_12_025: [ If the Client initialization failed the function shall clean up the all resources and return NULL. ] */
LogError("Prov_Device_LL_Create failed");
free(result);
result = NULL;
}
else
{
/* Codes_SRS_PROV_DEVICE_CLIENT_12_007: [ The function shall initialize the result datastructure. ] */
result->ThreadHandle = NULL;
result->StopThread = 0;
result->do_work_freq_ms = DO_WORK_FREQ_DEFAULT;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion provisioning_client/src/prov_device_ll_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ static void cleanup_prov_info(PROV_INSTANCE_INFO* prov_info)
{
prov_info->prov_transport_protocol->prov_transport_close(prov_info->transport_handle);
prov_info->transport_open = false;
prov_info->is_connected = false;
}
free(prov_info->registration_id);
prov_info->registration_id = NULL;
Expand Down Expand Up @@ -1207,7 +1208,7 @@ void Prov_Device_LL_DoWork(PROV_DEVICE_LL_HANDLE handle)
else
{
// Check the connection
if (prov_info->prov_timeout > 0)
if ((prov_info->prov_state != CLIENT_STATE_READY) && (prov_info->prov_timeout > 0))
{
tickcounter_ms_t current_time = 0;
(void)tickcounter_get_current_ms(prov_info->tick_counter, &current_time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1583,10 +1583,12 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
STRICT_EXPECTED_CALL(on_prov_register_device_callback(PROV_DEVICE_RESULT_TRANSPORT, NULL, NULL, NULL));
STRICT_EXPECTED_CALL(prov_transport_close(IGNORED_PTR_ARG));
setup_cleanup_prov_info_mocks();
STRICT_EXPECTED_CALL(prov_transport_dowork(IGNORED_PTR_ARG));

//act
g_registration_callback(PROV_DEVICE_TRANSPORT_RESULT_ERROR, NULL, NULL, NULL, g_registration_ctx);
Prov_Device_LL_DoWork(handle);
Prov_Device_LL_DoWork(handle); // Second DoWork should not call the callback again.

//assert
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ TEST_FUNCTION(Prov_Device_Create_succeeds)

/* Tests_SRS_PROV_DEVICE_CLIENT_12_003: [ If the memory allocation failed the function shall return NULL. ] */
/* Tests_SRS_PROV_DEVICE_CLIENT_12_005: [ If the Lock initialization failed the function shall clean up the all resources and return NULL. ] */
/* Tests_SRS_PROV_DEVICE_CLIENT_12_025: [ If the Client initialization failed the function shall clean up the all resources and return NULL. ] */
TEST_FUNCTION(Prov_Device_Create_fail)
{
//arrange
Expand All @@ -318,17 +319,10 @@ TEST_FUNCTION(Prov_Device_Create_fail)

umock_c_negative_tests_snapshot();

size_t calls_cannot_fail[] = { 2 };

//act
size_t count = umock_c_negative_tests_call_count();
for (size_t index = 0; index < count; index++)
{
if (should_skip_index(index, calls_cannot_fail, sizeof(calls_cannot_fail) / sizeof(calls_cannot_fail[0])) != 0)
{
continue;
}

umock_c_negative_tests_reset();
umock_c_negative_tests_fail_call(index);

Expand Down
2 changes: 1 addition & 1 deletion uamqp
2 changes: 1 addition & 1 deletion umqtt
Submodule umqtt updated 1 files
+1 −1 deps/c-utility