Skip to content

Commit 33016f1

Browse files
sbSteveKxiazhvera
andauthored
Switch to using a role for CI (#348)
* switch to using a role for integrated tests * separate python * setup permision&test against CI_PubSub_Role * test against iot account * update host * test host * use a ci job role for test * update role permission * update tests to use host argument * quick run discovery test * quick test for gg discovery * migrate gg discovery test * more comments --------- Co-authored-by: Vera Xia <[email protected]>
1 parent b1f495d commit 33016f1

14 files changed

+69
-59
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88

99
env:
1010
RUN: ${{ github.run_id }}-${{ github.run_number }}
11-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
12-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11+
AWS_DEFAULT_REGION: us-east-1
12+
CI_SDK_V1_ROLE: arn:aws:iam::180635532705:role/CI_SDK_V1_ROLE
1313
PACKAGE_NAME: aws-iot-device-sdk-python
1414
AWS_EC2_METADATA_DISABLED: true
1515

@@ -33,6 +33,9 @@ jobs:
3333
3434
integration-tests:
3535
runs-on: ubuntu-latest
36+
permissions:
37+
id-token: write # This is required for requesting the JWT
38+
contents: read # This is required for actions/checkout
3639
strategy:
3740
fail-fast: false
3841
matrix:
@@ -43,6 +46,10 @@ jobs:
4346
- uses: actions/setup-python@v5
4447
with:
4548
python-version: ${{ matrix.python-version }}
49+
- uses: aws-actions/configure-aws-credentials@v2
50+
with:
51+
role-to-assume: ${{ env.CI_SDK_V1_ROLE }}
52+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
4653
- name: Integration tests
4754
run: |
4855
pip install pytest
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
name: HandleStaleDiscussions
22
on:
3-
schedule:
4-
- cron: '0 */4 * * *'
5-
discussion_comment:
6-
types: [created]
3+
schedule:
4+
- cron: '0 */4 * * *'
5+
discussion_comment:
6+
types: [created]
77

88
jobs:
9-
handle-stale-discussions:
10-
name: Handle stale discussions
11-
runs-on: ubuntu-latest
12-
permissions:
13-
discussions: write
14-
steps:
15-
- name: Stale discussions action
16-
uses: aws-github-ops/handle-stale-discussions@v1
17-
env:
18-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
9+
handle-stale-discussions:
10+
name: Handle stale discussions
11+
runs-on: ubuntu-latest
12+
permissions:
13+
discussions: write
14+
steps:
15+
- name: Stale discussions action
16+
uses: aws-github-ops/handle-stale-discussions@v1
17+
env:
18+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19+

test-integration/IntegrationTests/IntegrationTestAsyncAPIGeneralNotificationCallbacks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
TOPIC = "topic/test/async_cb/"
3333
MESSAGE_PREFIX = "MagicMessage-"
3434
NUMBER_OF_PUBLISHES = 3
35-
HOST = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
3635
ROOT_CA = "./test-integration/Credentials/rootCA.crt"
3736
CERT = "./test-integration/Credentials/certificate.pem.crt"
3837
KEY = "./test-integration/Credentials/privateKey.pem.key"
@@ -102,9 +101,10 @@ def get_random_string(length):
102101
############################################################################
103102
# Main #
104103
# Check inputs
105-
my_check_in_manager = checkInManager(1)
104+
my_check_in_manager = checkInManager(2)
106105
my_check_in_manager.verify(sys.argv)
107106
mode = my_check_in_manager.mode
107+
host = my_check_in_manager.host
108108

109109
skip_when_match(ModeIsALPN(mode).And(
110110
Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0)))
@@ -115,7 +115,7 @@ def get_random_string(length):
115115
print("Connecting...")
116116
callback_manager = CallbackManager()
117117
sdk_mqtt_client = MQTTClientManager()\
118-
.create_nonconnected_mqtt_client(mode, CLIENT_ID, HOST, (ROOT_CA, CERT, KEY), callback_manager)
118+
.create_nonconnected_mqtt_client(mode, CLIENT_ID, host, (ROOT_CA, CERT, KEY), callback_manager)
119119
sdk_mqtt_client.connectAsync(keepAliveIntervalSecond=1, ackCallback=callback_manager.connack) # Add callback
120120
print("Wait some time to make sure we are connected...")
121121
time.sleep(10) # 10 sec

test-integration/IntegrationTests/IntegrationTestAutoReconnectResubscribe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ def threadBRuntime(self, pyCoreClient, callback):
135135
############################################################################
136136
# Main #
137137
# Check inputs
138-
myCheckInManager = checkInManager.checkInManager(1)
138+
myCheckInManager = checkInManager.checkInManager(2)
139139
myCheckInManager.verify(sys.argv)
140140

141-
host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
142141
rootCA = "./test-integration/Credentials/rootCA.crt"
143142
certificate = "./test-integration/Credentials/certificate.pem.crt"
144143
privateKey = "./test-integration/Credentials/privateKey.pem.key"
145144
mode = myCheckInManager.mode
145+
host = myCheckInManager.host
146146

147147
skip_when_match(ModeIsALPN(mode).And(
148148
Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0)))

test-integration/IntegrationTests/IntegrationTestClientReusability.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
NUMBER_OF_MESSAGES_PER_LOOP = 3
4141
NUMBER_OF_LOOPS = 3
4242
SUB_WAIT_TIME_OUT_SEC = 20
43-
HOST = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
4443
ROOT_CA = "./test-integration/Credentials/rootCA.crt"
4544
CERT = "./test-integration/Credentials/certificate.pem.crt"
4645
KEY = "./test-integration/Credentials/privateKey.pem.key"
@@ -94,19 +93,20 @@ def verify(self):
9493

9594
############################################################################
9695
# Main #
97-
my_check_in_manager = checkInManager(1)
96+
my_check_in_manager = checkInManager(2)
9897
my_check_in_manager.verify(sys.argv)
9998
mode = my_check_in_manager.mode
99+
host = my_check_in_manager.host
100100

101101
skip_when_match(ModeIsALPN(mode).And(
102102
Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0)))
103103
), "This test is not applicable for mode %s and Python verison %s. Skipping..." % (mode, sys.version_info[:3]))
104104

105105
simple_thread_manager = simpleThreadManager()
106106

107-
client_pub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_PUB, HOST, (ROOT_CA, CERT, KEY))
107+
client_pub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_PUB, host, (ROOT_CA, CERT, KEY))
108108
print("Client publisher initialized.")
109-
client_sub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_SUB, HOST, (ROOT_CA, CERT, KEY))
109+
client_sub = MQTTClientManager().create_nonconnected_mqtt_client(mode, CLIENT_ID_SUB, host, (ROOT_CA, CERT, KEY))
110110
print("Client subscriber initialized.")
111111
client_twins = ClientTwins(client_pub, client_sub)
112112
print("Client twins initialized.")

test-integration/IntegrationTests/IntegrationTestConfigurablePublishMessageQueueing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ def performConfigurableOfflinePublishQueueTest(clientPub, clientSub):
274274

275275

276276
# Check inputs
277-
myCheckInManager = checkInManager.checkInManager(1)
277+
myCheckInManager = checkInManager.checkInManager(2)
278278
myCheckInManager.verify(sys.argv)
279279

280-
host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
280+
host = myCheckInManager.host
281281
rootCA = "./test-integration/Credentials/rootCA.crt"
282282
certificate = "./test-integration/Credentials/certificate.pem.crt"
283283
privateKey = "./test-integration/Credentials/privateKey.pem.key"

test-integration/IntegrationTests/IntegrationTestDiscovery.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from TestToolLibrary.skip import ModeIsWebSocket
99

1010

11-
HOST = "arc9d2oott9lj-ats.iot.us-east-1.amazonaws.com" # <[email protected]> 003261610643
1211
PORT = 8443
1312
CA = "./test-integration/Credentials/rootCA.crt"
1413
CERT = "./test-integration/Credentials/certificate_drs.pem.crt"
1514
KEY = "./test-integration/Credentials/privateKey_drs.pem.key"
1615
TIME_OUT_SEC = 30
1716
# This is a pre-generated test data from DRS integration tests
17+
# The test resources point to account # <[email protected]> 003261610643
1818
ID_PREFIX = "Id-"
1919
GGC_ARN = "arn:aws:iot:us-east-1:003261610643:thing/DRS_GGC_0kegiNGA_0"
2020
GGC_PORT_NUMBER_BASE = 8080
@@ -108,10 +108,14 @@
108108
}
109109
'''
110110

111+
my_check_in_manager = checkInManager(2)
112+
my_check_in_manager.verify(sys.argv)
113+
mode = my_check_in_manager.mode
114+
host = my_check_in_manager.host
111115

112116
def create_discovery_info_provider():
113117
discovery_info_provider = DiscoveryInfoProvider()
114-
discovery_info_provider.configureEndpoint(HOST, PORT)
118+
discovery_info_provider.configureEndpoint(host, PORT)
115119
discovery_info_provider.configureCredentials(CA, CERT, KEY)
116120
discovery_info_provider.configureTimeout(TIME_OUT_SEC)
117121
return discovery_info_provider
@@ -196,9 +200,6 @@ def verify_group_object(discovery_info):
196200

197201
############################################################################
198202
# Main #
199-
my_check_in_manager = checkInManager(1)
200-
my_check_in_manager.verify(sys.argv)
201-
mode = my_check_in_manager.mode
202203

203204
skip_when_match(ModeIsWebSocket(mode), "This test is not applicable for mode: %s. Skipping..." % mode)
204205

test-integration/IntegrationTests/IntegrationTestJobsClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ def _test_send_response_confirm(self, sendResult):
154154
############################################################################
155155
# Main #
156156
# Check inputs
157-
myCheckInManager = checkInManager.checkInManager(1)
157+
myCheckInManager = checkInManager.checkInManager(2)
158158
myCheckInManager.verify(sys.argv)
159159

160-
host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
160+
host = myCheckInManager.host
161161
rootCA = "./test-integration/Credentials/rootCA.crt"
162162
certificate = "./test-integration/Credentials/certificate.pem.crt"
163163
privateKey = "./test-integration/Credentials/privateKey.pem.key"

test-integration/IntegrationTests/IntegrationTestMQTTConnection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ def _performPublish(self, pyCoreClient, topic, qos, payload):
8484
############################################################################
8585
# Main #
8686
# Check inputs
87-
myCheckInManager = checkInManager.checkInManager(2)
87+
myCheckInManager = checkInManager.checkInManager(3)
8888
myCheckInManager.verify(sys.argv)
8989

90-
host = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
90+
host = myCheckInManager.host
9191
rootCA = "./test-integration/Credentials/rootCA.crt"
9292
certificate = "./test-integration/Credentials/certificate.pem.crt"
9393
privateKey = "./test-integration/Credentials/privateKey.pem.key"

test-integration/IntegrationTests/IntegrationTestOfflineQueueingForSubscribeUnsubscribe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def get_random_string(length):
4747
TOPIC_B = "topic/test/offline_sub_unsub/b" + get_random_string(4)
4848
MESSAGE_PREFIX = "MagicMessage-"
4949
NUMBER_OF_PUBLISHES = 3
50-
HOST = "ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
5150
ROOT_CA = "./test-integration/Credentials/rootCA.crt"
5251
CERT = "./test-integration/Credentials/certificate.pem.crt"
5352
KEY = "./test-integration/Credentials/privateKey.pem.key"
@@ -74,7 +73,7 @@ def __init__(self, mode):
7473
time.sleep(2) # Make sure the subscription is valid
7574

7675
def _create_connected_client(self, id_prefix):
77-
return MQTTClientManager().create_connected_mqtt_client(self.__mode, id_prefix, HOST, (ROOT_CA, CERT, KEY))
76+
return MQTTClientManager().create_connected_mqtt_client(self.__mode, id_prefix, host, (ROOT_CA, CERT, KEY))
7877

7978
def start(self):
8079
thread_client_sub_unsub = Thread(target=self._thread_client_sub_unsub_runtime)
@@ -192,9 +191,10 @@ def verify(self):
192191
############################################################################
193192
# Main #
194193
# Check inputs
195-
my_check_in_manager = checkInManager(1)
194+
my_check_in_manager = checkInManager(2)
196195
my_check_in_manager.verify(sys.argv)
197196
mode = my_check_in_manager.mode
197+
host = my_check_in_manager.host
198198

199199
skip_when_match(ModeIsALPN(mode).And(
200200
Python2VersionLowerThan((2, 7, 10)).Or(Python3VersionLowerThan((3, 5, 0)))

0 commit comments

Comments
 (0)