Skip to content

Commit 2d421d1

Browse files
test: fix E2E Tests, improve test fixture naming/teardown, label creation (#539)
Co-authored-by: Zhiwei Liang <121905282+zliang-akamai@users.noreply.github.com>
1 parent 71a4b11 commit 2d421d1

23 files changed

+221
-228
lines changed

tests/integration/conftest.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def _generate_test_files(
122122

123123
# test helper specific to Domains test suite
124124
@pytest.fixture
125-
def create_master_domain():
126-
timestamp = str(int(time.time()))
125+
def master_domain():
126+
timestamp = str(time.time_ns())
127127

128128
domain_id = (
129129
exec_test_command(
@@ -152,8 +152,8 @@ def create_master_domain():
152152

153153

154154
@pytest.fixture
155-
def create_slave_domain():
156-
timestamp = str(int(time.time()) + randint(10, 1000))
155+
def slave_domain():
156+
timestamp = str(time.time_ns())
157157

158158
domain_id = (
159159
exec_test_command(
@@ -184,16 +184,16 @@ def create_slave_domain():
184184

185185
# Test helpers specific to Linodes test suite
186186
@pytest.fixture
187-
def create_linode_with_label():
188-
timestamp = str(int(time.time()) + randint(10, 1000))
187+
def linode_with_label():
188+
timestamp = str(time.time_ns())
189189
label = "cli" + timestamp
190190
result = (
191191
exec_test_command(
192192
LINODE_BASE_CMD
193193
+ [
194194
"create",
195195
"--type",
196-
"g6-standard-2",
196+
"g6-nanode-1",
197197
"--region",
198198
"us-east",
199199
"--image",
@@ -223,14 +223,14 @@ def create_linode_with_label():
223223

224224

225225
@pytest.fixture
226-
def create_linode_min_req():
226+
def linode_min_req():
227227
result = (
228228
exec_test_command(
229229
LINODE_BASE_CMD
230230
+ [
231231
"create",
232232
"--type",
233-
"g6-standard-2",
233+
"g6-nanode-1",
234234
"--region",
235235
"us-east",
236236
"--root_pass",
@@ -256,7 +256,7 @@ def create_linode_min_req():
256256

257257

258258
@pytest.fixture
259-
def create_linode_wo_image():
259+
def linode_wo_image():
260260
label = "cli" + str(int(time.time()) + randint(10, 1000))
261261
linode_id = (
262262
exec_test_command(
@@ -288,7 +288,7 @@ def create_linode_wo_image():
288288

289289

290290
@pytest.fixture
291-
def create_linode_backup_enabled():
291+
def linode_backup_enabled():
292292
# create linode with backups enabled
293293
linode_id = (
294294
exec_test_command(
@@ -321,8 +321,8 @@ def create_linode_backup_enabled():
321321

322322

323323
@pytest.fixture
324-
def take_snapshot_of_linode():
325-
timestamp = str(time.time())
324+
def snapshot_of_linode():
325+
timestamp = str(time.time_ns())
326326
# get linode id after creation and wait for "running" status
327327
linode_id = create_linode_and_wait()
328328
new_snapshot_label = "test_snapshot" + timestamp
@@ -348,7 +348,7 @@ def take_snapshot_of_linode():
348348

349349
# Test helpers specific to Nodebalancers test suite
350350
@pytest.fixture
351-
def create_nodebalancer_with_default_conf():
351+
def nodebalancer_with_default_conf():
352352
result = (
353353
exec_test_command(
354354
NODEBALANCER_BASE_CMD

tests/integration/domains/test_domain_records.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414

1515
@pytest.fixture
16-
def domain_records_setup():
17-
timestamp = str(int(time.time()))
16+
def test_domain_and_record():
17+
timestamp = str(time.time_ns())
1818
# Create domain
1919
domain_id = (
2020
exec_test_command(
@@ -65,15 +65,15 @@ def domain_records_setup():
6565

6666

6767
@pytest.mark.smoke
68-
def test_create_a_domain(create_master_domain):
68+
def test_create_a_domain(master_domain):
6969
# Current domain list
7070
process = exec_test_command(
7171
BASE_CMD + ["list", '--format="id"', "--text", "--no-header"]
7272
)
7373
output_current = process.stdout.decode()
7474

7575
# Create domain
76-
domain_id = create_master_domain
76+
domain_id = master_domain
7777

7878
process = exec_test_command(
7979
BASE_CMD + ["list", "--format=id", "--text", "--no-header"]
@@ -88,8 +88,8 @@ def test_create_a_domain(create_master_domain):
8888

8989

9090
@pytest.mark.smoke
91-
def test_create_domain_srv_record(domain_records_setup):
92-
domain_id = domain_records_setup[0]
91+
def test_create_domain_srv_record(test_domain_and_record):
92+
domain_id = test_domain_and_record[0]
9393

9494
process = exec_test_command(
9595
BASE_CMD
@@ -117,8 +117,8 @@ def test_create_domain_srv_record(domain_records_setup):
117117
)
118118

119119

120-
def test_list_srv_record(domain_records_setup):
121-
domain_id = domain_records_setup[0]
120+
def test_list_srv_record(test_domain_and_record):
121+
domain_id = test_domain_and_record[0]
122122
process = exec_test_command(
123123
BASE_CMD
124124
+ [
@@ -138,9 +138,9 @@ def test_list_srv_record(domain_records_setup):
138138

139139

140140
@pytest.mark.smoke
141-
def test_view_domain_record(domain_records_setup):
142-
domain_id = domain_records_setup[0]
143-
record_id = domain_records_setup[1]
141+
def test_view_domain_record(test_domain_and_record):
142+
domain_id = test_domain_and_record[0]
143+
record_id = test_domain_and_record[1]
144144

145145
process = exec_test_command(
146146
BASE_CMD
@@ -161,9 +161,9 @@ def test_view_domain_record(domain_records_setup):
161161
)
162162

163163

164-
def test_update_domain_record(domain_records_setup):
165-
domain_id = domain_records_setup[0]
166-
record_id = domain_records_setup[1]
164+
def test_update_domain_record(test_domain_and_record):
165+
domain_id = test_domain_and_record[0]
166+
record_id = test_domain_and_record[1]
167167

168168
process = exec_test_command(
169169
BASE_CMD
@@ -185,9 +185,9 @@ def test_update_domain_record(domain_records_setup):
185185
)
186186

187187

188-
def test_delete_a_domain_record(domain_records_setup):
189-
domain_id = domain_records_setup[0]
190-
record_id = domain_records_setup[1]
188+
def test_delete_a_domain_record(test_domain_and_record):
189+
domain_id = test_domain_and_record[0]
190+
record_id = test_domain_and_record[1]
191191

192192
process = exec_test_command(
193193
BASE_CMD + ["records-delete", domain_id, record_id]

tests/integration/domains/test_domains_tags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# @pytest.mark.skip(reason="BUG 943")
1717
def test_fail_to_create_master_domain_with_invalid_tags():
18-
timestamp = str(int(time.time()))
18+
timestamp = str(time.time_ns())
1919
bad_tag = "*"
2020

2121
exec_failing_test_command(
@@ -38,7 +38,7 @@ def test_fail_to_create_master_domain_with_invalid_tags():
3838

3939
# @pytest.mark.skip(reason="BUG 943")
4040
def test_fail_to_create_slave_domain_with_invalid_tags():
41-
timestamp = str(int(time.time()))
41+
timestamp = str(time.time_ns())
4242
bad_tag = "*"
4343

4444
exec_failing_test_command(
@@ -61,7 +61,7 @@ def test_fail_to_create_slave_domain_with_invalid_tags():
6161

6262
@pytest.mark.smoke
6363
def test_create_master_domain_with_tags():
64-
timestamp = str(int(time.time()))
64+
timestamp = str(time.time_ns())
6565
tag = "foo"
6666

6767
process = exec_test_command(

tests/integration/domains/test_master_domains.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414

1515
@pytest.fixture
16-
def setup_master_domains():
17-
timestamp = str(int(time.time()))
16+
def master_test_domain():
17+
timestamp = str(time.time_ns())
1818
# Create domain
1919
master_domain_id = (
2020
exec_test_command(
@@ -43,7 +43,7 @@ def setup_master_domains():
4343

4444

4545
def test_create_domain_fails_without_spcified_type():
46-
timestamp = str(int(time.time()))
46+
timestamp = str(time.time_ns())
4747

4848
# get debug output from linode-cli to a temporary file..
4949
# not all output from the linode-cli goes to stdout, stderr
@@ -66,7 +66,7 @@ def test_create_domain_fails_without_spcified_type():
6666

6767

6868
def test_create_master_domain_fails_without_soa_email():
69-
timestamp = str(int(time.time()))
69+
timestamp = str(time.time_ns())
7070
result = exec_failing_test_command(
7171
BASE_CMD
7272
+ [
@@ -85,17 +85,17 @@ def test_create_master_domain_fails_without_soa_email():
8585

8686

8787
@pytest.mark.smoke
88-
def test_create_master_domain(create_master_domain):
89-
domain_id = create_master_domain
88+
def test_create_master_domain(master_domain):
89+
domain_id = master_domain
9090
assert re.search("[0-9]+", domain_id)
9191

9292

93-
def test_update_master_domain_soa_email(setup_master_domains):
93+
def test_update_master_domain_soa_email(master_test_domain):
9494
# Remove --master_ips param when 872 is resolved
95-
timestamp = str(int(time.time()))
95+
timestamp = str(time.time_ns())
9696
new_soa_email = "pthiel_new@linode.com"
9797

98-
domain_id = setup_master_domains
98+
domain_id = master_test_domain
9999

100100
result = exec_test_command(
101101
BASE_CMD
@@ -117,7 +117,7 @@ def test_update_master_domain_soa_email(setup_master_domains):
117117
assert new_soa_email in result
118118

119119

120-
def test_list_master_domain(setup_master_domains):
120+
def test_list_master_domain(master_test_domain):
121121
result = exec_test_command(
122122
BASE_CMD
123123
+ [
@@ -133,7 +133,7 @@ def test_list_master_domain(setup_master_domains):
133133
assert re.search("[0-9]+,BC[0-9]+-example.com,master,active", result)
134134

135135

136-
def test_show_domain_detail(setup_master_domains):
136+
def test_show_domain_detail(master_test_domain):
137137
result = exec_test_command(
138138
BASE_CMD
139139
+ [

tests/integration/domains/test_slave_domains.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313

1414
BASE_CMD = ["linode-cli", "domains"]
15-
timestamp = str(int(time.time()))
15+
timestamp = str(time.time_ns())
1616

1717

1818
@pytest.fixture
@@ -61,12 +61,12 @@ def test_create_slave_domain_fails_without_master_dns_server():
6161

6262

6363
@pytest.mark.smoke
64-
def test_create_slave_domain(create_slave_domain):
65-
domain_id = create_slave_domain
64+
def test_create_slave_domain(slave_domain):
65+
domain_id = slave_domain
6666
assert re.search("[0-9]+", domain_id)
6767

6868

69-
def test_list_slave_domain(create_slave_domain):
69+
def test_list_slave_domain(slave_domain):
7070
result = exec_test_command(
7171
BASE_CMD + ["list", "--text", "--no-header"]
7272
).stdout.decode()

tests/integration/events/test_events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010

1111
@pytest.fixture
12-
def events_setup():
13-
timestamp = str(int(time.time()))
12+
def events_test_domain_id():
13+
timestamp = str(time.time_ns())
1414
# Create domain
1515
domain_id = (
1616
exec_test_command(
@@ -185,8 +185,8 @@ def test_filter_events_by_entity_id():
185185

186186

187187
@pytest.mark.skip(reason="https://github.com/linode/linode-cli/issues/500")
188-
def test_create_domain_and_filter_domain_events(events_setup):
189-
domain_id = events_setup
188+
def test_create_domain_and_filter_domain_events(events_test_domain_id):
189+
domain_id = events_test_domain_id
190190
result = exec_test_command(
191191
BASE_CMD
192192
+ [

0 commit comments

Comments
 (0)