-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Rialto Server Control CTs Type: Feature Test Plan: Component Tests Jira: RIALTO-466
- Loading branch information
1 parent
4b1c497
commit a9d4f86
Showing
13 changed files
with
488 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2024 Sky UK | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include "ControlTest.h" | ||
#include "ActionTraits.h" | ||
#include "ConfigureAction.h" | ||
#include "ExpectMessage.h" | ||
#include "MessageBuilders.h" | ||
|
||
namespace firebolt::rialto::server::ct | ||
{ | ||
ControlTest::ControlTest() | ||
{ | ||
willConfigureSocket(); | ||
configureSutInActiveState(); | ||
connectClient(); | ||
registerClient(); | ||
} | ||
|
||
void ControlTest::registerClient() | ||
{ | ||
ExpectMessage<ApplicationStateChangeEvent> expectedAppStateChange{m_clientStub}; | ||
|
||
auto registerClientReq(createRegisterClientRequest()); | ||
ConfigureAction<RegisterClient>(m_clientStub) | ||
.send(registerClientReq) | ||
.expectSuccess() | ||
.matchResponse([&](const auto &resp) { m_controlHandle = resp.control_handle(); }); | ||
|
||
auto receivedMessage = expectedAppStateChange.getMessage(); | ||
ASSERT_TRUE(receivedMessage); | ||
EXPECT_EQ(receivedMessage->application_state(), ApplicationStateChangeEvent_ApplicationState_RUNNING); | ||
} | ||
} // namespace firebolt::rialto::server::ct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2024 Sky UK | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef FIREBOLT_RIALTO_SERVER_CT_CONTROL_TEST_H_ | ||
#define FIREBOLT_RIALTO_SERVER_CT_CONTROL_TEST_H_ | ||
|
||
#include "RialtoServerComponentTest.h" | ||
|
||
namespace firebolt::rialto::server::ct | ||
{ | ||
class ControlTest : public RialtoServerComponentTest | ||
{ | ||
public: | ||
ControlTest(); | ||
~ControlTest() override = default; | ||
|
||
private: | ||
void registerClient(); | ||
|
||
protected: | ||
int m_controlHandle{-1}; | ||
}; | ||
} // namespace firebolt::rialto::server::ct | ||
|
||
#endif // FIREBOLT_RIALTO_SERVER_CT_CONTROL_TEST_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
tests/componenttests/server/tests/control/ApplicationStateChangeTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2024 Sky UK | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include "ActionTraits.h" | ||
#include "ConfigureAction.h" | ||
#include "ControlTest.h" | ||
#include "ExpectMessage.h" | ||
#include "MessageBuilders.h" | ||
|
||
namespace firebolt::rialto::server::ct | ||
{ | ||
class ApplicationStateChangeTest : public ControlTest | ||
{ | ||
public: | ||
ApplicationStateChangeTest() = default; | ||
~ApplicationStateChangeTest() override = default; | ||
|
||
void changeStateToInactive() | ||
{ | ||
ExpectMessage<ApplicationStateChangeEvent> m_expectedInactiveNotification{m_clientStub}; | ||
|
||
setStateInactive(); | ||
|
||
auto inactiveNotification{m_expectedInactiveNotification.getMessage()}; | ||
ASSERT_TRUE(inactiveNotification); | ||
EXPECT_EQ(inactiveNotification->application_state(), ApplicationStateChangeEvent_ApplicationState_INACTIVE); | ||
} | ||
|
||
void changeStateToRunning() | ||
{ | ||
ExpectMessage<ApplicationStateChangeEvent> m_expectedRunningNotification{m_clientStub}; | ||
|
||
setStateActive(); | ||
|
||
auto runningNotification{m_expectedRunningNotification.getMessage()}; | ||
ASSERT_TRUE(runningNotification); | ||
EXPECT_EQ(runningNotification->application_state(), ApplicationStateChangeEvent_ApplicationState_RUNNING); | ||
} | ||
|
||
void getSharedMemoryWillFail() | ||
{ | ||
auto getShmReq{createGetSharedMemoryRequest()}; | ||
ConfigureAction<GetSharedMemory>(m_clientStub).send(getShmReq).expectFailure(); | ||
} | ||
|
||
void getSharedMemoryWillSucceed() | ||
{ | ||
auto getShmReq{createGetSharedMemoryRequest()}; | ||
ConfigureAction<GetSharedMemory>(m_clientStub).send(getShmReq).expectSuccess(); | ||
} | ||
}; | ||
/* | ||
* Component Test: Application state change from RUNNING->INACTIVE->RUNNING | ||
* Test Objective: | ||
* Test the full lifecycle of an application and verify that the client is always notified. | ||
* | ||
* Sequence Diagrams: | ||
* Start Application in Running State, Application state change: Running to Inactive, | ||
* Switch Application from Inactive to Running State, Stop Application from Running State | ||
* - https://wiki.rdkcentral.com/display/ASP/Rialto+Application+Session+Management | ||
* | ||
* Test Setup: | ||
* Language: C++ | ||
* Testing Framework: Google Test | ||
* Components: Control | ||
* | ||
* Test Initialize: | ||
* Set Rialto Server to Active | ||
* Connect Rialto Client Stub | ||
* Register Rialto Client Stub in RUNNING state | ||
* | ||
* Test Steps: | ||
* Step 1: Change state to INACTIVE | ||
* ServerManager requests the server to change the state to INACTIVE. | ||
* Expect that the state change notification is propagated to the client. | ||
* Expect that the shared memory region cannot be fetched from the server. | ||
* | ||
* Step 2: Change state to RUNNING | ||
* ServerManager requests the server to change the state to ACTIVE. | ||
* Expect that the state change notification to RUNNING is propagated to the client. | ||
* Expect that the shared memory region is fetched from the server. | ||
* | ||
* Test Teardown: | ||
* Server is terminated. | ||
* | ||
* Expected Results: | ||
* The lifecycle of an application is successfully negotiated and notfied to | ||
* listening clients. | ||
* | ||
* Code: | ||
*/ | ||
TEST_F(ApplicationStateChangeTest, lifecycle) | ||
{ | ||
// Step 1: Change state to INACTIVE | ||
changeStateToInactive(); | ||
getSharedMemoryWillFail(); | ||
|
||
// Step 2: Change state to RUNNING | ||
changeStateToRunning(); | ||
getSharedMemoryWillSucceed(); | ||
} | ||
} // namespace firebolt::rialto::server::ct |
Oops, something went wrong.