Skip to content

Commit

Permalink
chore(agw): adapt gateway_subscriber_state format (#13212)
Browse files Browse the repository at this point in the history
* chore(agw): remove outer array from gateway_subscriber_state to make
to fix deserializing error

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>

* chore(agw): Adapt test case for get_operational_states

Signed-off-by: Sebastian Thomas <sebastian.thomas@tngtech.com>

Co-authored-by: Sebastian Thomas <sebastian.thomas@tngtech.com>
  • Loading branch information
alexzurbonsen and sebathomas committed Jul 12, 2022
1 parent 3c37124 commit 228a655
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
3 changes: 1 addition & 2 deletions lte/gateway/c/session_manager/OperationalStatesHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ OpState get_operational_states(magma::lte::SessionStore* session_store) {
std::map<std::string, std::string> state;
state[TYPE] = SUBSCRIBER_STATE_TYPE;
state[DEVICE_ID] = it.first;
subscribers[state[DEVICE_ID]] = nlohmann::json::array();
nlohmann::json sessions_by_apn = nlohmann::json::object();

for (auto& session : it.second) {
Expand All @@ -59,7 +58,7 @@ OpState get_operational_states(magma::lte::SessionStore* session_store) {
}
state[VALUE] = sessions_by_apn.dump();
states.push_back(state);
subscribers[state[DEVICE_ID]].push_back(sessions_by_apn);
subscribers[state[DEVICE_ID]] = sessions_by_apn;
}
std::map<std::string, std::string> gateway_subscriber_state;
gateway_subscriber_state[TYPE] = GATEWAY_SUBSCRIBER_STATE_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,25 @@ TEST_F(OperationalStatesHandlerTest, test_get_operational_states) {
EXPECT_FALSE(subscriber_state_it == subscriber_state.end());
json_value = nlohmann::json::parse(subscriber_state_it->second);
nlohmann::json gateway_subscribers = json_value[SUBSCRIBERS];
nlohmann::json content = gateway_subscribers[IMSI1];
content = content[0][APN1];
EXPECT_EQ(content[0]["lifecycle_state"],
nlohmann::json content = gateway_subscribers[IMSI1][APN1];
EXPECT_EQ(content.size(), 1);
content = content[0];
EXPECT_EQ(content["lifecycle_state"],
session_fsm_state_to_str(SESSION_ACTIVE));
EXPECT_EQ(content[0]["session_start_time"], SESSION_START_TIME_1);
EXPECT_EQ(content[0]["apn"], APN1);
EXPECT_EQ(content[0]["ipv4"], IP1);
EXPECT_EQ(content[0]["session_id"], SESSION_ID_1);
content = gateway_subscribers[IMSI2];
content = content[0][APN1];
EXPECT_EQ(content[0]["lifecycle_state"],
EXPECT_EQ(content["session_start_time"], SESSION_START_TIME_1);
EXPECT_EQ(content["apn"], APN1);
EXPECT_EQ(content["ipv4"], IP1);
EXPECT_EQ(content["session_id"], SESSION_ID_1);

content = gateway_subscribers[IMSI2][APN1];
EXPECT_EQ(content.size(), 1);
content = content[0];
EXPECT_EQ(content["lifecycle_state"],
session_fsm_state_to_str(SESSION_ACTIVE));
EXPECT_EQ(content[0]["session_start_time"], SESSION_START_TIME_2);
EXPECT_EQ(content[0]["apn"], APN1);
EXPECT_EQ(content[0]["ipv4"], IP2);
EXPECT_EQ(content[0]["session_id"], SESSION_ID_2);
EXPECT_EQ(content["session_start_time"], SESSION_START_TIME_2);
EXPECT_EQ(content["apn"], APN1);
EXPECT_EQ(content["ipv4"], IP2);
EXPECT_EQ(content["session_id"], SESSION_ID_2);
break;
}
}
Expand Down

0 comments on commit 228a655

Please sign in to comment.