Skip to content

Commit 034bc6b

Browse files
committed
dbg - prisma startup
1 parent f95eeef commit 034bc6b

4 files changed

Lines changed: 82 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,77 @@ jobs:
7272
exit 1
7373
fi
7474
echo "OpenAPI spec downloaded successfully"
75-
head -5 openapi.yml
75+
echo "=== Spec file size ==="
76+
wc -l openapi.yml
77+
echo "=== First 20 lines of spec ==="
78+
head -20 openapi.yml
79+
echo "=== Paths section ==="
80+
grep -A 20 "^paths:" openapi.yml || echo "No paths section found"
81+
echo "=== All path definitions ==="
82+
grep -E "^\s*/" openapi.yml || echo "No path definitions found"
7683
7784
# Start Prism container in background
7885
docker run -d --name prism -p 4010:4010 \
7986
-v $(pwd)/openapi.yml:/tmp/openapi.yml \
8087
stoplight/prism:4 \
8188
mock --host 0.0.0.0 /tmp/openapi.yml
8289
90+
# Check if container started
91+
echo "Checking container status..."
92+
docker ps | grep prism || echo "Container not found in docker ps"
93+
echo "=== Container logs ==="
94+
docker logs prism || echo "No logs available"
95+
echo "=== Container inspection ==="
96+
docker inspect prism | grep -A 10 -B 10 "State" || echo "Could not inspect container"
97+
echo "=== Network ports ==="
98+
docker port prism || echo "Could not get port mappings"
99+
83100
# Wait for Prism to start
84101
echo "Waiting for Prism to start..."
85102
sleep 15
86103
104+
# Test basic connectivity
105+
echo "Testing basic connectivity to localhost:4010..."
106+
curl -v http://localhost:4010 || echo "Basic connection failed"
107+
87108
# Verify Prism is running with retry
88109
for i in {1..5}; do
89-
if curl -f http://localhost:4010/health; then
90-
echo "Prism container started successfully on port 4010"
110+
echo "=== Attempt $i: Testing Prism health ==="
111+
if curl -v http://localhost:4010/health 2>&1 | head -10; then
112+
echo "✅ Prism container started successfully on port 4010"
91113
break
92114
else
93-
echo "Attempt $i: Prism not ready yet, waiting..."
115+
echo "❌ Attempt $i: Prism not ready yet, waiting..."
116+
echo "Container still running?"
117+
docker ps | grep prism || echo "Container stopped"
118+
echo "Recent logs:"
119+
docker logs --tail 5 prism
94120
sleep 5
95121
fi
96122
done
97123
124+
# Test available endpoints
125+
echo "=== Testing available Prism endpoints ==="
126+
echo "Testing root path:"
127+
curl -v http://localhost:4010/ 2>&1 | head -10 || echo "Root path failed"
128+
129+
echo "Testing /v0 path:"
130+
curl -v http://localhost:4010/v0 2>&1 | head -10 || echo "/v0 path failed"
131+
132+
echo "Testing /v0/breeders:"
133+
curl -v http://localhost:4010/v0/breeders 2>&1 | head -10 || echo "/v0/breeders failed"
134+
135+
echo "Testing OpenAPI spec:"
136+
curl -v http://localhost:4010/openapi.json 2>&1 | head -5 || echo "OpenAPI spec failed"
137+
138+
echo "=== Testing exact URLs that CLI will use ==="
139+
echo "Testing /breeders (what CLI should call):"
140+
curl -v http://localhost:4010/breeders 2>&1 | head -10 || echo "/breeders failed"
141+
142+
echo "Testing POST /breeders:"
143+
curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' \
144+
http://localhost:4010/breeders 2>&1 | head -10 || echo "POST /breeders failed"
145+
98146
- name: Integration tests against Prism mock
99147
run: |
100148
# Get the binary path
@@ -118,7 +166,7 @@ jobs:
118166
119167
# Test breeder show with a mock UUID
120168
echo "Testing: breeder show"
121-
$BINARY_PATH --hostname=localhost --port=4010 breeder show --uuid=123e4567-e89b-12d3-a456-426614174000
169+
$BINARY_PATH --hostname=localhost --port=4010 breeder show --id=123e4567-e89b-12d3-a456-426614174000
122170
123171
# Create update test file
124172
echo 'name: "Updated Test Breeder"' > test_breeder_update.yml
@@ -133,7 +181,7 @@ jobs:
133181
134182
# Test breeder purge
135183
echo "Testing: breeder purge"
136-
$BINARY_PATH --hostname=localhost --port=4010 breeder purge --uuid=123e4567-e89b-12d3-a456-426614174000
184+
$BINARY_PATH --hostname=localhost --port=4010 breeder purge --id=123e4567-e89b-12d3-a456-426614174000
137185
138186
# Test help commands
139187
echo "Testing: help commands"

src/godon/client.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,22 @@ proc newGodonClient*(hostname: string = DefaultHostname,
2929

3030
proc baseUrl*(client: GodonClient): string =
3131
## Get the base URL for API requests
32-
result = "http://" & client.config.hostname & ":" & $client.config.port & "/" & client.config.apiVersion
32+
result = "http://" & client.config.hostname & ":" & $client.config.port
3333

3434
proc handleResponse*[T](client: GodonClient; response: Response): ApiResponse[T] =
3535
## Handle HTTP response and convert to ApiResponse
3636
let statusCode = parseInt(split(response.status, " ")[0])
3737
if statusCode >= 200 and statusCode < 300:
3838
try:
39+
echo "Raw response body: ", response.body
3940
let jsonData = parseJson(response.body)
4041
result = ApiResponse[T](success: true, data: jsonData.to(T), error: "")
4142
except CatchableError as e:
4243
result = ApiResponse[T](success: false, data: default(T), error: "JSON parse error: " & e.msg)
4344
else:
4445
try:
4546
let errorJson = parseJson(response.body)
46-
let errorMsg = errorJson.getOrDefault("message").getStr("HTTP Error: " & $statusCode)
47+
let errorMsg = errorJson{"message"}.getStr("HTTP Error: " & $statusCode)
4748
result = ApiResponse[T](success: false, data: default(T), error: errorMsg)
4849
except CatchableError:
4950
result = ApiResponse[T](success: false, data: default(T), error: "HTTP Error: " & $statusCode)
@@ -54,7 +55,7 @@ proc handleError*(client: GodonClient, response: Response): ref CatchableError =
5455
var errorMsg = "HTTP Error: " & $statusCode
5556
try:
5657
let errorJson = parseJson(response.body)
57-
errorMsg = errorJson.getOrDefault("message").getStr(errorMsg)
58+
errorMsg = errorJson{"message"}.getStr(errorMsg)
5859
except CatchableError:
5960
discard
6061

src/godon/types.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import std/json
55

66
type
77
Breeder* = object
8-
uuid*: string
8+
id*: string
99
name*: string
1010
description*: string
11+
status*: string
1112
config*: JsonNode
1213
createdAt*: string
1314
updatedAt*: string

src/godon_cli.nim

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Usage:
1010
Commands:
1111
breeder list List all configured breeders
1212
breeder create --file <path> Create a breeder from file
13-
breeder show --uuid <uuid> Show breeder details
13+
breeder show --id <id> Show breeder details
1414
breeder update --file <path> Update a breeder from file
15-
breeder purge --uuid <uuid> Delete a breeder
15+
breeder purge --id <id> Delete a breeder
1616
1717
Global Options:
1818
--hostname, -h <host> Godon hostname (default: localhost)
@@ -24,7 +24,7 @@ Examples:
2424
godon_cli breeder list
2525
godon_cli --hostname api.example.com --port 9090 breeder list
2626
godon_cli breeder create --file breeder.yaml
27-
godon_cli breeder show --uuid 123e4567-e89b-12d3-a456-426614174000
27+
godon_cli breeder show --id 123e4567-e89b-12d3-a456-426614174000
2828
"""
2929

3030
proc writeError(message: string) =
@@ -41,7 +41,6 @@ proc parseArgs(): (string, string, int, string, seq[string]) =
4141
var p = initOptParser(commandLineParams())
4242

4343
for kind, key, val in p.getopt():
44-
echo "Parsed: kind=", kind, " key=", key, " val=", val
4544
case kind
4645
of cmdArgument:
4746
if command.len == 0:
@@ -87,9 +86,10 @@ proc handleBreederCommand(client: GodonClient, command: string, args: seq[string
8786
if response.success:
8887
echo "Breeders:"
8988
for breeder in response.data:
90-
echo " UUID: ", breeder.uuid
89+
echo " ID: ", breeder.id
9190
echo " Name: ", breeder.name
9291
echo " Description: ", breeder.description
92+
echo " Status: ", breeder.status
9393
echo " Created: ", breeder.createdAt
9494
echo " Updated: ", breeder.updatedAt
9595
echo " ---"
@@ -114,27 +114,27 @@ proc handleBreederCommand(client: GodonClient, command: string, args: seq[string
114114
let response = client.createBreederFromYaml(content)
115115
if response.success:
116116
echo "Breeder created successfully:"
117-
echo " UUID: ", response.data.uuid
117+
echo " ID: ", response.data.id
118118
echo " Name: ", response.data.name
119119
echo " Description: ", response.data.description
120120
else:
121121
writeError(response.error)
122122

123123
of "show":
124-
var uuid = ""
124+
var id = ""
125125
for i in 1 ..< args.len.int:
126-
if args[i-1] == "--uuid":
127-
uuid = args[i]
126+
if args[i-1] == "--id":
127+
id = args[i]
128128
break
129129

130-
if uuid.len == 0:
131-
writeError("breeder show requires --uuid <uuid>")
130+
if id.len == 0:
131+
writeError("breeder show requires --id <id>")
132132

133-
echo "Getting breeder details for UUID: ", uuid
134-
let response = client.getBreeder(uuid)
133+
echo "Getting breeder details for ID: ", id
134+
let response = client.getBreeder(id)
135135
if response.success:
136136
echo "Breeder Details:"
137-
echo " UUID: ", response.data.uuid
137+
echo " ID: ", response.data.id
138138
echo " Name: ", response.data.name
139139
echo " Description: ", response.data.description
140140
echo " Config: ", pretty(response.data.config)
@@ -161,24 +161,24 @@ proc handleBreederCommand(client: GodonClient, command: string, args: seq[string
161161
let response = client.updateBreederFromYaml(content)
162162
if response.success:
163163
echo "Breeder updated successfully:"
164-
echo " UUID: ", response.data.uuid
164+
echo " ID: ", response.data.id
165165
echo " Name: ", response.data.name
166166
echo " Description: ", response.data.description
167167
else:
168168
writeError(response.error)
169169

170170
of "purge":
171-
var uuid = ""
171+
var id = ""
172172
for i in 1 ..< args.len.int:
173-
if args[i-1] == "--uuid":
174-
uuid = args[i]
173+
if args[i-1] == "--id":
174+
id = args[i]
175175
break
176176

177-
if uuid.len == 0:
178-
writeError("breeder purge requires --uuid <uuid>")
177+
if id.len == 0:
178+
writeError("breeder purge requires --id <id>")
179179

180-
echo "Deleting breeder with UUID: ", uuid
181-
let response = client.deleteBreeder(uuid)
180+
echo "Deleting breeder with ID: ", id
181+
let response = client.deleteBreeder(id)
182182
if response.success:
183183
echo "Breeder deleted successfully"
184184
if response.data != nil:

0 commit comments

Comments
 (0)