diff --git a/Cargo.lock b/Cargo.lock index 8d50016..ea09266 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -476,7 +476,7 @@ dependencies = [ [[package]] name = "dmtri" version = "0.1.0" -source = "git+https://github.com/demeter-run/specs.git#7d94c162d85affef990eed7a450dbbd1db8b0984" +source = "git+https://github.com/demeter-run/specs.git?branch=chore/add_update_resource_protos#b1686f6bb754e250879860e497ba7f4dba61b3c8" dependencies = [ "bytes", "pbjson", diff --git a/Cargo.toml b/Cargo.toml index 120df54..ddf9a04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/test/expect b/test/expect index c51b46b..57b5b8e 100755 --- a/test/expect +++ b/test/expect @@ -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" @@ -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