Skip to content

Commit

Permalink
2110 intermediate migration 2 (#515)
Browse files Browse the repository at this point in the history
* fix[api]: adding duplicate provider column to enforce db constraints without affecting existing duplicates ...

* fix[api]: rmeove v2 of ceramic_cache api

* feat(infra): remove lambdas and load balancer rule related to ceramic_cache API v2, adjust test checking for stamp uniqueness
  • Loading branch information
nutrina authored Feb 7, 2024
1 parent a291f10 commit 3469a32
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 118 deletions.
40 changes: 20 additions & 20 deletions api/ceramic_cache/test/test_db_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
},
}

# TODO: enable this after uniqueness can be enforced
# class TestGetStamps:
# @pytest.mark.django_db
# def test_no_duplicate_stamps(self):
# """Make sure that it is not possible to have duplicate stamps in the DB"""

# address = "0x123test"
class TestGetStamps:
@pytest.mark.django_db
def test_no_duplicate_stamps(self):
"""Make sure that it is not possible to have duplicate stamps in the DB"""

# # Create the first stamp
# CeramicCache.objects.create(
# address=address,
# provider=stamp["credentialSubject"]["provider"],
# stamp=stamp,
# )
address = "0x123test"

# with pytest.raises(IntegrityError) as exc_info:
# # Create the same stamp (same provider) again
# # We expect an exception to be thrown
# CeramicCache.objects.create(
# address=address,
# provider=stamp["credentialSubject"]["provider"],
# stamp=stamp,
# )
# Create the first stamp
CeramicCache.objects.create(
address=address,
provider_clone=stamp["credentialSubject"]["provider"],
stamp=stamp,
)

with pytest.raises(IntegrityError) as exc_info:
# Create the same stamp (same provider) again
# We expect an exception to be thrown
CeramicCache.objects.create(
address=address,
provider_clone=stamp["credentialSubject"]["provider"],
stamp=stamp,
)
55 changes: 6 additions & 49 deletions infra/prod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,10 +1010,10 @@ const redashInitScript = redashDbUrl.apply((url) =>
echo "Try to pull from git repo or clone the repo if it was not cloned before ..."
git pull /passport-redash || git clone https://github.com/gitcoinco/passport-redash.git /passport-redash
echo "Changing directory and setting permissions..."
cd /passport-redash
chmod +x ./setup.sh
./setup.sh
Expand Down Expand Up @@ -1360,10 +1360,7 @@ buildHttpLambdaFn({
name: "cc-auhenticate",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.authenticate_POST.handler"],
pathPatterns: [
"/ceramic-cache/authenticate",
"/ceramic-cache/v2/authenticate",
],
pathPatterns: ["/ceramic-cache/authenticate"],
httpRequestMethods: ["POST"],
listenerPriority: 1005,
});
Expand All @@ -1373,7 +1370,7 @@ buildHttpLambdaFn({
name: "cc-v1-score-POST",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.score_POST.handler"],
pathPatterns: ["/ceramic-cache/score/*", "/ceramic-cache/v2/score/*"],
pathPatterns: ["/ceramic-cache/score/*"],
httpRequestMethods: ["POST"],
listenerPriority: 1006,
});
Expand All @@ -1383,7 +1380,7 @@ buildHttpLambdaFn({
name: "cc-v1-score-GET",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.score_GET.handler"],
pathPatterns: ["/ceramic-cache/score/*", "/ceramic-cache/v2/score/*"],
pathPatterns: ["/ceramic-cache/score/*"],
httpRequestMethods: ["GET"],
listenerPriority: 1007,
});
Expand All @@ -1393,7 +1390,7 @@ buildHttpLambdaFn({
name: "cc-weights-GET",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.weights_GET.handler"],
pathPatterns: ["/ceramic-cache/weights", "/ceramic-cache/v2/weights"],
pathPatterns: ["/ceramic-cache/weights"],
httpRequestMethods: ["GET"],
listenerPriority: 1015,
});
Expand All @@ -1408,46 +1405,6 @@ buildHttpLambdaFn({
listenerPriority: 1010,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-bulk-POST",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamps.bulk_POST.handler"],
pathPatterns: ["/ceramic-cache/v2/stamps/bulk"],
httpRequestMethods: ["POST"],
listenerPriority: 1011,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-bulk-PATCH",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamps.bulk_PATCH.handler"],
pathPatterns: ["/ceramic-cache/v2/stamps/bulk"],
httpRequestMethods: ["PATCH"],
listenerPriority: 1012,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-bulk-DELETE",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamps.bulk_DELETE.handler"],
pathPatterns: ["/ceramic-cache/v2/stamps/bulk"],
httpRequestMethods: ["DELETE"],
listenerPriority: 1013,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-GET",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamp_GET.handler"],
pathPatterns: ["/ceramic-cache/v2/stamp"],
httpRequestMethods: ["GET"],
listenerPriority: 1014,
});

buildQueueLambdaFn({
...lambdaSettings,
name: "rescore",
Expand Down
55 changes: 6 additions & 49 deletions infra/staging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,7 @@ buildHttpLambdaFn({
name: "cc-auhenticate",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.authenticate_POST.handler"],
pathPatterns: [
"/ceramic-cache/authenticate",
"/ceramic-cache/v2/authenticate",
],
pathPatterns: ["/ceramic-cache/authenticate"],
httpRequestMethods: ["POST"],
listenerPriority: 2005,
});
Expand All @@ -682,7 +679,7 @@ buildHttpLambdaFn({
name: "cc-v1-score-POST",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.score_POST.handler"],
pathPatterns: ["/ceramic-cache/score/*", "/ceramic-cache/v2/score/*"],
pathPatterns: ["/ceramic-cache/score/*"],
httpRequestMethods: ["POST"],
listenerPriority: 2006,
});
Expand All @@ -692,7 +689,7 @@ buildHttpLambdaFn({
name: "cc-v1-score-GET",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.score_GET.handler"],
pathPatterns: ["/ceramic-cache/score/*", "/ceramic-cache/v2/score/*"],
pathPatterns: ["/ceramic-cache/score/*"],
httpRequestMethods: ["GET"],
listenerPriority: 2007,
});
Expand All @@ -702,7 +699,7 @@ buildHttpLambdaFn({
name: "cc-weights-GET",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v1.weights_GET.handler"],
pathPatterns: ["/ceramic-cache/weights", "/ceramic-cache/v2/weights"],
pathPatterns: ["/ceramic-cache/weights"],
httpRequestMethods: ["GET"],
listenerPriority: 2015,
});
Expand All @@ -717,46 +714,6 @@ buildHttpLambdaFn({
listenerPriority: 2010,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-bulk-POST",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamps.bulk_POST.handler"],
pathPatterns: ["/ceramic-cache/v2/stamps/bulk"],
httpRequestMethods: ["POST"],
listenerPriority: 2011,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-bulk-PATCH",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamps.bulk_PATCH.handler"],
pathPatterns: ["/ceramic-cache/v2/stamps/bulk"],
httpRequestMethods: ["PATCH"],
listenerPriority: 2012,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-bulk-DELETE",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamps.bulk_DELETE.handler"],
pathPatterns: ["/ceramic-cache/v2/stamps/bulk"],
httpRequestMethods: ["DELETE"],
listenerPriority: 2013,
});

buildHttpLambdaFn({
...lambdaSettings,
name: "cc-v2-st-GET",
memorySize: 512,
dockerCmd: ["aws_lambdas.scorer_api_passport.v2.stamp_GET.handler"],
pathPatterns: ["/ceramic-cache/v2/stamp"],
httpRequestMethods: ["GET"],
listenerPriority: 2014,
});

buildQueueLambdaFn({
...lambdaSettings,
name: "rescore",
Expand Down Expand Up @@ -1027,10 +984,10 @@ const redashInitScript = redashDbUrl.apply((url) =>
echo "Try to pull from git repo or clone the repo if it was not cloned before ..."
git pull /passport-redash || git clone https://github.com/gitcoinco/passport-redash.git /passport-redash
echo "Changing directory and setting permissions..."
cd /passport-redash
chmod +x ./setup.sh
./setup.sh
Expand Down

0 comments on commit 3469a32

Please sign in to comment.