Skip to content

Commit

Permalink
Fix test install and full test suite in Daily (#2300)
Browse files Browse the repository at this point in the history
  • Loading branch information
jumaffre authored Mar 11, 2021
1 parent ccff1ca commit 03aec4b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .daily_canary
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Happy daily trigger.
Happy daily trigger :)
63 changes: 40 additions & 23 deletions tests/infra/consortium.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import http
import json
import random
import re
import infra.network
import infra.proc
import infra.checker
Expand Down Expand Up @@ -37,7 +38,8 @@ def __init__(
self.recovery_threshold = None
self.authenticate_session = authenticate_session
# If a list of member IDs is passed in, generate fresh member identities.
# Otherwise, recover the state of the consortium from the state of CCF.
# Otherwise, recover the state of the consortium from the common directory
# and the state of the service
if members_info is not None:
self.recovery_threshold = 0
for m_local_id, has_share, m_data in members_info:
Expand All @@ -55,9 +57,30 @@ def __init__(
self.recovery_threshold += 1
self.members.append(new_member)
else:
# TODO: Why do we still need this?
with remote_node.client("member0") as mc:
r = mc.post(
for f in os.listdir(self.common_dir):
if re.search("member(.*)_cert.pem", f) is not None:
local_id = f.split("_")[0]
new_member = infra.member.Member(
local_id,
curve,
self.common_dir,
share_script,
is_recovery_member=os.path.isfile(
os.path.join(self.common_dir, f"{local_id}_enc_privk.pem")
),
authenticate_session=authenticate_session,
)
self.members.append(new_member)
LOG.info(
f"Successfully recovered member {local_id}: {new_member.service_id}"
)

if not self.members:
LOG.warning("No consortium member to recover")
return

with remote_node.client(self.members[0].local_id) as c:
r = c.post(
"/gov/query",
{
"text": """tables = ...
Expand All @@ -71,27 +94,21 @@ def __init__(
"""
},
)
for m_id, info in r.body.json():
new_member = infra.member.Member(
f"member{m_id}",
curve,
self.common_dir,
share_script,
is_recovery_member="encryption_pub_key" in info,
authenticate_session=authenticate_session,
)
for member_service_id, info in r.body.json():
status = info["status"]
if (
infra.member.MemberStatus[status]
== infra.member.MemberStatus.ACTIVE
):
new_member.set_active()
self.members.append(new_member)
LOG.info(
f"Successfully recovered member {m_id} with status {status}"
)
member = self.get_member_by_service_id(member_service_id)
if member:
if (
infra.member.MemberStatus[status]
== infra.member.MemberStatus.ACTIVE
):
member.set_active()
else:
LOG.warning(
f"Keys and certificates for consortium member {member_service_id} do not exist locally"
)

r = mc.post(
r = c.post(
"/gov/query",
{
"text": """tables = ...
Expand Down
12 changes: 6 additions & 6 deletions tests/infra/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,25 @@ def __init__(
txs=None,
library_dir=".",
):
self.existing_network = existing_network
if self.existing_network is None:
if existing_network is None:
self.consortium = None
self.users = []
self.node_offset = 0
self.txs = txs
else:
self.consortium = self.existing_network.consortium
self.consortium = existing_network.consortium
self.users = existing_network.users
# When creating a new network from an existing one (e.g. for recovery),
# the node id of the nodes of the new network should start from the node
# id of the existing network, so that new nodes id match the ones in the
# nodes KV table
self.node_offset = (
len(self.existing_network.nodes) + self.existing_network.node_offset
len(existing_network.nodes) + existing_network.node_offset
)
self.txs = self.existing_network.txs
self.txs = existing_network.txs

self.ignoring_shutdown_errors = False
self.nodes = []
self.users = []
self.hosts = hosts
self.status = ServiceStatus.CLOSED
self.binary_dir = binary_dir
Expand Down

0 comments on commit 03aec4b

Please sign in to comment.