Testing Rainmaker
Posted: Wed Aug 02, 2023 12:31 pm
Hi All,
New here so I apologise in advance if this post is a little malformed.
I am currently working with Rainmaker on the ESP32S2 for work, but I am having trouble understanding the expected method of testing for Rainmaker.
Internally we use Unity.h as our test framework, and have had decent results with it.
Currently I am trying very simple tests whilst I get the hang of Rainmaker, but I am struggling to deinit properly.
My test code is as follows:
Which Results in the following logs:
As far as i can tell I cannot deinit Rainmaker, as the esp_rmaker_priv_data->state is not equal to ESP_RMAKER_STATE_INIT_DONE. Leading me to believe that I cant deinit because I have not correctly init!
Any pointers, help or advice is greatly welcomed. If you would require additional logs or code then let me know!
New here so I apologise in advance if this post is a little malformed.
I am currently working with Rainmaker on the ESP32S2 for work, but I am having trouble understanding the expected method of testing for Rainmaker.
Internally we use Unity.h as our test framework, and have had decent results with it.
Currently I am trying very simple tests whilst I get the hang of Rainmaker, but I am struggling to deinit properly.
My test code is as follows:
Code: Select all
#include "unity.h"
#include "wifi.h"
#include "storage.h"
#include "rainmaker.h"
#include "rmaker_insights.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
static const char *TAG = "Rainmaker Test";
#define PARAM_ID_1 0
#define PARAM_ID_2 1
#define PARAM_ID_3 2
#define TYPE_ID_1 0
#define TYPE_ID_2 1
static Rainmaker_Handle_t handle;
static bool setup_complete = false;
static bool valid_rainmaker_init(void)
{
return Rainmaker_Init("Test-node", "Test type");
}
static void rainmaker_setUp(void)
{
ESP_LOGW(TAG, "SETUP");
Storage_Init_Custom_Partition("nvs");
Wifi_Init(false);
Rainmaker_Init("Test-node", "Test type");
Rainmaker_Enable_Insights();
Rainmaker_Start();
}
static void rainmaker_tearDown(void)
{
ESP_LOGW(TAG, "TEARDOWN");
Rainmaker_Stop();
Rainmaker_Deinit();
Wifi_Deinit();
Storage_Delete_All_And_Deinit("nvs");
}
static void callback(uint8_t type, uint8_t param, uint8_t val)
{
return;
}
TEST_CASE("Successful init of rainmaker", "[Rainmaker]")
{
rainmaker_setUp();
TEST_ASSERT_TRUE(is_rainmaker_init());
TEST_ASSERT_TRUE(Rainmaker_Get_Init());
rainmaker_tearDown();
UnityConcludeTest();
}
TEST_CASE("Successful deinit of rainmaker", "[Rainmaker]")
{
rainmaker_setUp();
rainmaker_tearDown();
TEST_ASSERT_FALSE(is_rainmaker_init());
UnityConcludeTest();
}
Code: Select all
#### Starting interactive test menu #####
Select a test group:
100. switch
101. flow sensor
102. rainmaker
103. storage
104. wifi
105. button
106. local coms
107. local coms OTA
108. temp
109. led
110. ota update
111. https coms
Please enter an integer between 100 and 999:
102
Press enter to confirm the option.
#### Starting interactive test menu for component Rainmaker #####
Please Select one of the following options:
1. Run All Tests
2. Run A Named Test
#### Running Rainmaker tests #####
Running tests matching 'Rainmaker'...
Running Successful init of rainmaker...
W (6758) Rainmaker Test: SETUP
I (6763) Wifi: Wifi Init
I (6764) Wifi: nefit_sta init
I (6768) wifi:wifi driver task: 3ffe7650, prio:23, stack:6656, core=0
I (6771) wifi:wifi firmware version: b2f1f86
I (6771) wifi:wifi certification version: v7.0
I (6774) wifi:config NVS flash: enabled
I (6778) wifi:config nano formating: disabled
I (6782) wifi:Init data frame dynamic rx buffer num: 32
I (6787) wifi:Init management frame dynamic rx buffer num: 32
I (6792) wifi:Init management short buffer num: 32
I (6797) wifi:Init dynamic tx buffer num: 32
I (6801) wifi:Init static rx buffer size: 1600
I (6805) wifi:Init static rx buffer num: 10
I (6809) wifi:Init dynamic rx buffer num: 32
I (6814) wifi_init: rx ba win: 6
I (6817) wifi_init: tcpip mbox: 32
I (6821) wifi_init: udp mbox: 6
I (6825) wifi_init: tcp mbox: 6
I (6828) wifi_init: tcp tx win: 5744
I (6833) wifi_init: tcp rx win: 5744
I (6837) wifi_init: tcp mss: 1440
I (6841) wifi_init: WiFi IRAM OP enabled
I (6846) wifi_init: WiFi RX IRAM OP enabled
I (6854) esp_rmaker_work_queue: Work Queue created.
I (6862) esp_mqtt_glue: AWS PPI: ?Platform=APN3|A0|RM|EX00|RMDev|1x0|84F703DB4212
I (6864) esp_mqtt_glue: Initialising MQTT
I (6869) esp_rmaker_mqtt_budget: MQTT Budgeting initialised. Default: 100, Max: 1024, Revive count: 1, Revive period: 5
I (6880) esp_rmaker_node: Node ID ----- UUTpXHzAQWj7CnsZ6o8uGE
I (6887) esp_rmaker_time_service: Time service enabled
I (6893) Insights: Enabling insights
W (6897) Insights: Event loop creation failed with ESP_ERR_INVALID_STATE. Proceeding since it must have been created elsewhere.
I (6911) heap_metrics: free:0x11190 lfb:0xb800 min_free_ever:0x11190
I (6917) esp_insights: =========================================
I (6923) esp_insights: Insights enabled for Node ID UUTpXHzAQWj7CnsZ6o8uGE
I (6930) esp_insights: =========================================
I (6937) Rainmaker: Rainmaker start
E (6941) Rainmaker: No valid types to start
W (6946) Rainmaker Test: TEARDOWN
W (6950) insights_transport: disconnect callback not set
I (6956) esp_insights: Deleting the periodic timer
I (6962) esp_rmaker_work_queue: esp_rmaker_work_queue was successfully deinitialized
E (6970) esp_rmaker_core: ESP RainMaker is still running. Please stop it first.
I (6978) Wifi: Start Deinit
I (6982) wifi:Deinit lldesc rx mblock:10
I (6986) Wifi: nefit_sta destroy
W (6989) Storage: Deleteing nvs partition
/workspaces/Xarkle-hub/components/rainmaker/test/rainmaker_test.c:63:Successful init of rainmaker:PASS
/workspaces/Xarkle-hub/components/rainmaker/test/rainmaker_test.c:63:Successful init of rainmaker:PASS
Running Successful deinit of rainmaker...
W (7306) Rainmaker Test: SETUP
I (7311) Wifi: Wifi Init
I (7312) Wifi: nefit_sta init
I (7315) wifi:wifi driver task: 3ffeeb24, prio:23, stack:6656, core=0
I (7318) wifi:wifi firmware version: b2f1f86
I (7318) wifi:wifi certification version: v7.0
I (7322) wifi:config NVS flash: enabled
I (7326) wifi:config nano formating: disabled
I (7330) wifi:Init data frame dynamic rx buffer num: 32
I (7335) wifi:Init management frame dynamic rx buffer num: 32
I (7341) wifi:Init management short buffer num: 32
I (7345) wifi:Init dynamic tx buffer num: 32
I (7349) wifi:Init static rx buffer size: 1600
I (7353) wifi:Init static rx buffer num: 10
I (7357) wifi:Init dynamic rx buffer num: 32
I (7362) wifi_init: rx ba win: 6
I (7365) wifi_init: tcpip mbox: 32
I (7369) wifi_init: udp mbox: 6
I (7373) wifi_init: tcp mbox: 6
I (7377) wifi_init: tcp tx win: 5744
I (7381) wifi_init: tcp rx win: 5744
I (7385) wifi_init: tcp mss: 1440
I (7389) wifi_init: WiFi IRAM OP enabled
I (7394) wifi_init: WiFi RX IRAM OP enabled
E (7399) esp_rmaker_core: ESP RainMaker already initialised
E (7405) Rainmaker: Could not initialise node
E (7410) Rainmaker: Rainmaker is not init, can't enable insights
I (7417) Rainmaker: Rainmaker start
E (7421) Rainmaker: No valid types to start
W (7426) Rainmaker Test: TEARDOWN
E (7430) insights_transport: Transport callbacks not registered
E (7436) insights_transport: Not initialized
E (7441) esp_rmaker_core: ESP RainMaker is still running. Please stop it first.
I (7449) Wifi: Start Deinit
I (7454) wifi:Deinit lldesc rx mblock:10
I (7458) Wifi: nefit_sta destroy
W (7461) Storage: Deleteing nvs partition
/workspaces/Xarkle-hub/components/rainmaker/test/rainmaker_test.c:71:Successful deinit of rainmaker:PASS
/workspaces/Xarkle-hub/components/rainmaker/test/rainmaker_test.c:71:Successful deinit of rainmaker:PASS
-----------------------
2 Tests 0 Failures 0 Ignored
OK
Any pointers, help or advice is greatly welcomed. If you would require additional logs or code then let me know!