Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezzfelipe committed Aug 22, 2024
1 parent 76a8816 commit fe6b178
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
dmtri = { version = "0.1.0", git = "https://github.com/demeter-run/specs.git" }
dmtri = { version = "0.1.0", git = "https://github.com/demeter-run/specs.git", branch = "chore/add_update_resource_protos" }
# dmtri = { version = "0.1.0", path = "../specs/gen/rust" }
# dmtri = { version = "0.1.0", path = "../fabric-specs/gen/rust" }

Expand Down
45 changes: 44 additions & 1 deletion test/expect
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ fi
# Create namespace using grpcurl
echo "Creating namespace"
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
NAMESPACE=$(./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" -d '{"name": "New Namespace"}' "$NODE_IP:30950" demeter.ops.v1alpha.ProjectService.CreateProject | jq -r '.namespace')
OUTPUT=$(./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" -d '{"name": "New Namespace"}' "$NODE_IP:30950" demeter.ops.v1alpha.ProjectService.CreateProject | jq)
echo "CreateProject output:"
echo $OUTPUT
PROJECT_ID=$(echo $OUTPUT | jq -r '.id')
NAMESPACE=$(echo $OUTPUT | jq -r '.namespace')

# Check if namespace is created
echo "Checking if namespace $NAMESPACE exists"
Expand All @@ -95,3 +99,42 @@ if ! kubectl get namespace "$NAMESPACE" &> /dev/null; then
echo "Error: Namespace $NAMESPACE not found after 120 attempts."
exit 1
fi

# Change project name
echo "Updating project..."
./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" -d '{"id": "'"$PROJECT_ID"'" "name": "New name"}' "$NODE_IP:30950" demeter.ops.v1alpha.ProjectService.UpdateProject

NEW_NAME=$(./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" "$NODE_IP:30950" demeter.ops.v1alpha.ProjectService.FetchProjects | jq '.records[0].name' )
if [[ "$NEW_NAME" == "New name" ]]; then
echo "Succesfuly updated project"
else
echo "Failed to update project"
exit 1
fi

# Create resource
echo "Creating resource..."
OUTPUT=$(./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" \
-d '{"id": "'"$PROJECT_ID"'" "name": "New name"}' \
-d '{"project_id": "'"$PROJECT_ID"'","kind": "CardanoNodePort","spec": "{\"throughputTier\":\"0\", \"authToken\":\"token\",\"network\":\"preview\",\"version\":\"stable\"}"}'
"$NODE_IP:30950" demeter.ops.v1alpha.ResourceService.CreateResource | jq )

echo "CreateResource output:"
echo $OUTPUT
RESOURCE_ID=$(echo $OUTPUT | jq -r '.id')

# Update resource
echo "Updating resource..."
./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" -d '{"id": "'"$RESOURCE_ID"'", "spec_patch": "{\"throughputTier\":\"1\""}}' "$NODE_IP:30950" demeter.ops.v1alpha.ResourceService.UpdateResource


OUTPUT=$(./grpcurl -plaintext -H "Authorization: Bearer $TOKEN" -d '{"resource_id": "'"$RESOURCE_ID"'", "project_id": "'"$PROJECT_ID"'" }' "$NODE_IP:30950" demeter.ops.v1alpha.ResourceService.FetchResourceById | jq )
echo $OUTPUT

NEW_TIER=$(echo $OUTPUT | jq -r '.records[0].spec' | jq -r '.throughputTier')
if [[ "$NEW_TIER" == "1" ]]; then
echo "Succesfuly updated resource"
else
echo "Failed to update resource"
exit 1
fi

0 comments on commit fe6b178

Please sign in to comment.