Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Node {
name: String!
groupId: ID
domain: String # 所属しているdomain
expiresAt: AWSDateTime
heartbeatIntervalSeconds: Int
}

Expand Down
2 changes: 2 additions & 0 deletions js/functions/joinGroupFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ export function response(ctx) {
// TransactWriteItemsは個別のアイテムを返さないため、
// リクエストパラメータからNode型を構築
const { groupId, domain, nodeId } = ctx.args;
const group = ctx.stash.group;

return {
id: nodeId,
name: `Node ${nodeId}`,
groupId: groupId,
domain: domain,
expiresAt: group ? group.expiresAt : null,
heartbeatIntervalSeconds: +(ctx.env.MESH_MEMBER_HEARTBEAT_INTERVAL_SECONDS || '120')
};
}
1 change: 1 addition & 0 deletions spec/fixtures/mutations/join_group.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mutation JoinGroup($groupId: ID!, $domain: String!, $nodeId: ID!) {
name
groupId
domain
expiresAt
heartbeatIntervalSeconds
}
}
33 changes: 33 additions & 0 deletions spec/requests/join_group_expires_at_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "spec_helper"
require "time"

RSpec.describe "joinGroup expiresAt validation", type: :request do
let(:timestamp) { (Time.now.to_f * 1000).to_i }
let(:domain) { "test-join-expires-at-#{timestamp}.example.com" }
let(:host_id) { "host-#{timestamp}" }
let(:node_id) { "node-#{timestamp}" }
let(:group_name) { "Join Group expiresAt Test" }

it "joinGroup mutation returns expiresAt" do
# 1. グループを作成
group = create_test_group(group_name, host_id, domain)
group_id = group["id"]
group_expires_at = group["expiresAt"]
expect(group_id).not_to be_nil
expect(group_expires_at).to match_iso8601

# 2. グループに参加
join_response = join_test_node(group_id, domain, node_id)

# 3. expiresAtが返されることを確認
expect(join_response["expiresAt"]).not_to be_nil
expect(join_response["expiresAt"]).to match_iso8601

# 4. グループのexpiresAtと一致することを確認
# AWSDateTimeのフォーマットが微妙に異なる可能性(ミリ秒の有無など)を考慮し、
# Timeオブジェクトに変換して比較する
group_time = Time.parse(group_expires_at)
join_time = Time.parse(join_response["expiresAt"])
expect(join_time).to eq(group_time)
end
end
Loading