Skip to content

Networking test fixes #4240

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

Closed
wants to merge 16 commits into from
Closed

Conversation

bridadan
Copy link
Contributor

@bridadan bridadan commented Apr 27, 2017

Description

This PR attempts to fix a number of issues that have cropped up with the networking tests lately. This pr is still in development.

Status

IN DEVELOPMENT

Migrations

If this PR changes any APIs or behaviors, give a short description of what API users should do when this PR is merged.

NO

Todos

  • Transition all Greentea tests that use TEST_ASSERT statements to utest-style tests
  • Generate MAC addresses from the Greentea UUID to help prevent MAC conflicts (should help with DHCP failures)
  • Get the nightly passing, maybe run additional stress testing

@bridadan
Copy link
Contributor Author

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 102

Build failed!

@bridadan bridadan force-pushed the networking_test_fixes branch from 3893d9e to 11f4ee0 Compare April 28, 2017 01:06
@bridadan
Copy link
Contributor Author

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 103

Test failed!

@kegilbert
Copy link
Contributor

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented May 1, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 114

Test failed!

@bridadan
Copy link
Contributor Author

bridadan commented May 1, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented May 2, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 115

All builds and test passed!

@bridadan
Copy link
Contributor Author

bridadan commented May 2, 2017

@geky I think we need to take a look at the udp_echo_parallel test, I'm not so sure that this is very reliable as it is currently written. I think we may need to reorganize or it come up with something different.

@geky
Copy link
Contributor

geky commented May 3, 2017

/morph test-nightly

Copy link
Contributor

@kegilbert kegilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good update 👍

@geky geky force-pushed the networking_test_fixes branch from 8e31a49 to 457b1c1 Compare May 3, 2017 20:23
}

i++;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should keep this i here. It is keeping track of the total number of loops, not the number of successes.

bridadan and others added 14 commits May 3, 2017 16:30
The dtls test already has the ability to retry upon a UDP failure.
However the sockets are currently configured to be blocking and to wait
forever. I added a timeout of 1.5 seconds in order the test to correctly
timeout.
This adds some extra logs to the test for debugging purposes. Also
allows the test to fail immediately if it fails to obtain an IP address.
The Greentea UUID can be used as a source of entropy/randomness during
the test. This is useful for uniquely identifying a test run.
Before, the UDP test was very strict on the number of packets it would
try to match before failing. Now it will keep trying for the whole test
to get enough passing packets. It also includes the test's UUID so you
can validate which packets are being received.
Making the test more forgiven for minor networking issues. Also adding
more debug prints to make it easier to see which packets are coming from
where.
…et device as Locally Administrated and Unicast
This matches the timeout used in linux:
https://linux.die.net/man/5/dhclient.conf

This resolves several issues noticed during testing when we
have a very large number of devices that try to get an IP address
around the same time.
Avoids getting stuck in loop where the device always picks
up the previous test's packets
Avoids accidentally using a part of the uuid that isn't very unique.
ie, the mac address component of type 1 uuids.
Copy link
Contributor Author

@bridadan bridadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok , when you rebase can you also do it on top of master? I think a targets.json has crept in here for some reason. (you are too quick for me!)

}

Case cases[] = {
Case("Testing TCP echo", test_tcp_echo),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: seems a bit redundant to put "Testing" in the title of a test case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, a quick grep shows it's traditional :P

TESTS/mbedmicro-rtos-mbed/threads/main.cpp:    Case("Testing parallel threads with murder", test_parallel_threads<3, increment_with_murder>),
TESTS/mbedmicro-rtos-mbed/threads/main.cpp:    Case("Testing serial threads with murder", test_serial_threads<10, increment_with_murder>),
TESTS/mbedmicro-rtos-mbed/threads/main.cpp:    Case("Testing thread self terminate", test_self_terminate),
TESTS/mbedmicro-rtos-mbed/mutex/main.cpp:    Case("Test single thread lock", test_single_thread_lock),
TESTS/mbedmicro-rtos-mbed/mutex/main.cpp:    Case("Test single thread trylock", test_single_thread_trylock),
TESTS/mbedmicro-rtos-mbed/mutex/main.cpp:    Case("Test single thread lock recursive", test_single_thread_lock_recursive),
TESTS/network/wifi/main.cpp:    Case("Scan test", wifi_scan, greentea_failure_handler),
TESTS/network/wifi/main.cpp:    Case("Connect test", wifi_connect, greentea_failure_handler),
TESTS/network/wifi/main.cpp:    Case("Scan while connected test", wifi_connect_scan, greentea_failure_handler),
TESTS/network/wifi/main.cpp:    Case("HTTP test", wifi_http, greentea_failure_handler),

but I can update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah woops haha. Nevermind then!

Copy link
Contributor

@geky geky May 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too late, is updated : P

@geky geky force-pushed the networking_test_fixes branch from 0a65f88 to 071b79b Compare May 3, 2017 21:31
@geky geky force-pushed the networking_test_fixes branch from 071b79b to 56ba283 Compare May 3, 2017 21:50
@bridadan
Copy link
Contributor Author

bridadan commented May 3, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented May 3, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 142

Build failed!

This is a workaround for IAR's lack of flexibility with memory regions.
Otherwise these tests would use very little heap and be mostly global
allocations.
@geky
Copy link
Contributor

geky commented May 4, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented May 4, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 154

Test failed!

@bridadan bridadan changed the title [WIP, DO NOT MERGE] Networking test fixes Networking test fixes May 12, 2017
@bridadan
Copy link
Contributor Author

/morph test-nightly

@bridadan
Copy link
Contributor Author

@adbridge and/or @mazimkhan, could you take a look at the Greentea client changes I've made? Everything seems to be ok, but doesn't hurt to have a few extra eyes on this.

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 207

All builds and test passed!

@adbridge adbridge self-requested a review May 15, 2017 13:56
Copy link
Contributor

@adbridge adbridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of instances of magic numbers, where a macro should be used.

General lack of commenting of the changes.

Multiple instances of the same comments ( so please check through all changes for duplicates where I haven't marked them all individually...

* This function is blocking.
*/
void GREENTEA_SETUP(const int timeout, const char *host_test_name) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No header for this function ??

char _key[8] = {0};

while (1) {
greentea_parse_kv(_key, buffer, sizeof(_key), size);
greentea_write_string("mbedmbedmbedmbedmbedmbedmbedmbed\r\n");
if (strcmp(_key, GREENTEA_TEST_ENV_SYNC) == 0) {
// Found correct __sunc message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_sync

* After host test name is received master will invoke host test script
* and add hos test's callback handlers to main event loop
* This function is blocking.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should describe how this differs from standard GREENTEA_SETUP


tx_buffer[i++] = ' ';

for (; i<tx_size; ++i) {
tx_buffer[i] = (rand() % 10) + '0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a comment saying what this is actually doing and why

tx_buffer[i] = (rand() % 10) + '0';
}
}

int main() {
GREENTEA_SETUP(60, "udp_echo");

char uuid[48] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 48 characters ? Shouldn't this be a #define ?

for (int i = 0; i < sizeof(uuid); i++) {
mac += uuid[i];
}
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment in function


// Test setup
utest::v1::status_t test_setup(const size_t number_of_cases) {
char uuid[48] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

for (int i = 0; i < sizeof(uuid); i++) {
mac += uuid[i];
}
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment inside function

@@ -90,5 +84,32 @@ int main() {
}

eth.disconnect();
GREENTEA_TESTSUITE_RESULT(result);
TEST_ASSERT_EQUAL(true, result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be TEST_ASSERT_TRUE(result)

@@ -204,6 +194,32 @@ int main() {
}

net.disconnect();
GREENTEA_TESTSUITE_RESULT(result);
TEST_ASSERT_EQUAL(true, result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_ASSERT_TRUE

Copy link

@mazimkhan mazimkhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have general design comment:
For getting a random mac address do we really need to change greentea API? It can be done by generating the mac address in the host test script and sending a key,value pair to the target. That will delegate following repeated code to the host side where the UUID is coming from:

+    char uuid[48] = {0};
 +    GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
 +
 +    // create mac address based on uuid
 +    uint64_t mac = 0;
 +    for (int i = 0; i < sizeof(uuid); i++) {
 +        mac += uuid[i];
 +    }

Also above adding UUID bytes can compromise the uniqueness and randomness of UUID. For instance if there are two different sequences like 05 04 06 and 06 05 04 they will produce same sum. Hence the position of the bytes is just as important as their value.
In my opinion host side can produce more strong random and unique mac address that can be given to the target test to use.

@bridadan
Copy link
Contributor Author

Thanks for all of the feedback, especially @adbridge and @mazimkhan. After doing more examination, the method we went about for overriding the mbed mac address doesn't actually work since most vendors that have LWIP implementations already override the mbed_mac_address function. (should have seen that one, face palm).

I'm closing this PR in favor of the updated (and reduced scope) #4369. Let's continue the discussion there, thanks!

@bridadan
Copy link
Contributor Author

Also, added the issue #4370 to help track some of the outstanding issues (including what we have already tried to solve them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants