Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/shop-dc-shim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ The service includes **intentional Jackson serialization errors** on the transac
**Note:** This requires the instance to have a k3s/k3d deployment with Astronomy Shop Demo
- Update and use `build-image-quay-dev.sh` to build a new image with your local changes
- Reference that new image in `k8s-addition.yaml` and copy to your instance
- `kubectl apply -f k8s-addition.yaml` will add the `shop-dc-shim-db`, `shop-dc-shim`, and `shop-dc-load-generator` pods to your cluster
- On your instances with the cluser `export APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY=<SE-LABS-TOKEN>`
- `envsubst < k8s-additions.yaml | kubectl apply -f -` will add the `shop-dc-shim-db`, `shop-dc-shim`, and `shop-dc-load-generator` pods to your cluster
- **NOTE:** `envsubst` is important here to pass the appd agent token
- Once `shop-dc-shim` finishes spinning up (5-7min) the load generator will start sending traffic
- **For DBMon** upgrade splunk-otel-collector helm chart with `dbmon-values.yaml`
- E.G. `helm upgrade splunk-otel-collector-1760534477 --values /home/splunk/dbmon-values.yaml splunk-otel-collector-chart/splunk-otel-collector --reuse-values`
Expand Down
18 changes: 8 additions & 10 deletions src/shop-dc-shim/load-generator/shop_load_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ def __init__(self, shop_service_url: str = "http://localhost:8070"):
["TERM-001", "TERM-002"])
]

# Product catalog (simulating local inventory)
self.products = [
Product("SKU-TELE-001", "Professional Telescope", 299.99, "telescopes"),
Product("SKU-BINO-001", "High-Power Binoculars", 149.99, "binoculars"),
Product("SKU-LENS-001", "Camera Lens Set", 199.99, "accessories"),
Product("SKU-TRIPOD-001", "Carbon Fiber Tripod", 89.99, "accessories"),
Product("SKU-BOOK-001", "Astronomy Guide Book", 24.99, "books"),
Product("SKU-COMPASS-001", "Digital Compass", 39.99, "navigation"),
Product("SKU-FILTER-001", "Light Pollution Filter", 79.99, "accessories"),
Product("SKU-MOUNT-001", "Telescope Mount", 159.99, "accessories")
Product("OLJCESPC7Z", "Professional Telescope", 299.99, "telescopes"),
Product("2ZYFJ3GM2N", "High-Power Binoculars", 149.99, "binoculars"),
Product("L9ECAV7KIM", "Camera Lens Set", 199.99, "accessories"),
Product("HQTGWGPNH4", "Astronomy Guide Book", 24.99, "books"),
Product("LS4PSXUNUM", "Digital Compass", 39.99, "navigation"),
Product("6E92ZMYYFZ", "Light Pollution Filter", 79.99, "accessories"),
Product("9SIQT8TOJO", "Telescope Mount", 159.99, "accessories")
]

# Customer database (simulating local customer records)
Expand Down Expand Up @@ -191,7 +189,7 @@ def create_purchase_request(self, store: StoreLocation, terminal: str) -> Dict[s
"creditCardNumber": "4111-1111-1111-1111", # Test card number
"creditCardCvv": random.randint(100, 999),
"expirationMonth": random.randint(1, 12),
"expirationYear": random.randint(2025, 2030)
"expirationYear": random.randint(2030, 2035)
},
"items": purchase_items
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
@Repository
public interface ShopTransactionRepository extends JpaRepository<ShopTransaction, Long> {

Optional<ShopTransaction> findByTransactionId(String transactionId);
@Query("SELECT s FROM ShopTransaction s, ShopTransaction s2, ShopTransaction s3 WHERE s.transactionId = :transactionId AND s.id = s2.id AND s.id = s3.id ORDER BY s.createdAt")
Optional<ShopTransaction> findByTransactionId(@Param("transactionId") String transactionId);

Optional<ShopTransaction> findByLocalOrderId(String localOrderId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.stereotype.Service;
import oteldemo.Demo.*;
import oteldemo.CheckoutServiceGrpc;
import oteldemo.CartServiceGrpc;

import javax.annotation.PreDestroy;
import java.util.UUID;
Expand All @@ -24,6 +25,7 @@ public class CloudCheckoutService {

private final ManagedChannel channel;
private final CheckoutServiceGrpc.CheckoutServiceBlockingStub checkoutStub;
private final CartServiceGrpc.CartServiceBlockingStub cartStub;
private final Tracer tracer;
private final String checkoutServiceAddr;

Expand All @@ -40,6 +42,12 @@ public CloudCheckoutService(

this.checkoutStub = CheckoutServiceGrpc.newBlockingStub(channel);

// Create cart service client otherwise we get cart errors on checkout
ManagedChannel cartChannel = ManagedChannelBuilder.forTarget("cart:8080")
.usePlaintext()
.build();
this.cartStub = CartServiceGrpc.newBlockingStub(cartChannel);

log.info("Initialized Cloud Checkout Service with gRPC address: {}", checkoutServiceAddr);
}

Expand Down Expand Up @@ -73,6 +81,13 @@ public CloudCheckoutResult submitToCloudCheckout(String localOrderId, ShopPurcha

// Generate a unique user ID for this transaction
String userId = "shop-dc-" + UUID.randomUUID().toString();

for (var item : request.getItems()) {
cartStub.addItem(AddItemRequest.newBuilder()
.setUserId(userId)
.setItem(CartItem.newBuilder().setProductId(item.getProductId()).setQuantity(item.getQuantity()).build())
.build());
}

// Build the gRPC PlaceOrderRequest
PlaceOrderRequest grpcRequest = buildGrpcRequest(userId, request);
Expand Down