|
6 | 6 | InstanceType,
|
7 | 7 | SchedulingPolicy,
|
8 | 8 | } from "@cloudflare/containers-shared";
|
| 9 | +import { ApplicationAffinityHardwareGeneration } from "@cloudflare/containers-shared/src/client/models/ApplicationAffinityHardwareGeneration"; |
9 | 10 | import { http, HttpResponse } from "msw";
|
10 | 11 | import { clearCachedAccount } from "../../cloudchamber/locations";
|
11 | 12 | import { mockAccountV4 as mockContainersAccount } from "../cloudchamber/utils";
|
@@ -1497,6 +1498,143 @@ describe("wrangler deploy with containers", () => {
|
1497 | 1498 | "
|
1498 | 1499 | `);
|
1499 | 1500 | });
|
| 1501 | + |
| 1502 | + describe("affinities", () => { |
| 1503 | + it("may be specified on creation", async () => { |
| 1504 | + mockGetVersion("Galaxy-Class"); |
| 1505 | + writeWranglerConfig({ |
| 1506 | + ...DEFAULT_DURABLE_OBJECTS, |
| 1507 | + containers: [ |
| 1508 | + { |
| 1509 | + ...DEFAULT_CONTAINER_FROM_REGISTRY, |
| 1510 | + affinities: { |
| 1511 | + hardware_generation: "highest-overall-performance", |
| 1512 | + }, |
| 1513 | + }, |
| 1514 | + ], |
| 1515 | + }); |
| 1516 | + |
| 1517 | + mockGetApplications([]); |
| 1518 | + |
| 1519 | + mockCreateApplication(); |
| 1520 | + |
| 1521 | + await runWrangler("deploy index.js"); |
| 1522 | + |
| 1523 | + expect(cliStd.stdout).toMatchInlineSnapshot(` |
| 1524 | + "╭ Deploy a container application deploy changes to your application |
| 1525 | + │ |
| 1526 | + │ Container application changes |
| 1527 | + │ |
| 1528 | + ├ NEW my-container |
| 1529 | + │ |
| 1530 | + │ [[containers]] |
| 1531 | + │ name = \\"my-container\\" |
| 1532 | + │ scheduling_policy = \\"default\\" |
| 1533 | + │ instances = 0 |
| 1534 | + │ max_instances = 10 |
| 1535 | + │ rollout_active_grace_period = 0 |
| 1536 | + │ |
| 1537 | + │ [containers.configuration] |
| 1538 | + │ image = \\"docker.io/hello:world\\" |
| 1539 | + │ instance_type = \\"dev\\" |
| 1540 | + │ |
| 1541 | + │ [containers.constraints] |
| 1542 | + │ tier = 1 |
| 1543 | + │ |
| 1544 | + │ [containers.affinities] |
| 1545 | + │ hardware_generation = \\"highest-overall-performance\\" |
| 1546 | + │ |
| 1547 | + │ [containers.durable_objects] |
| 1548 | + │ namespace_id = \\"1\\" |
| 1549 | + │ |
| 1550 | + │ |
| 1551 | + │ SUCCESS Created application my-container (Application ID: undefined) |
| 1552 | + │ |
| 1553 | + ╰ Applied changes |
| 1554 | +
|
| 1555 | + " |
| 1556 | + `); |
| 1557 | + }); |
| 1558 | + |
| 1559 | + it("may be specified on modification", async () => { |
| 1560 | + mockGetVersion("Galaxy-Class"); |
| 1561 | + writeWranglerConfig({ |
| 1562 | + ...DEFAULT_DURABLE_OBJECTS, |
| 1563 | + containers: [ |
| 1564 | + { |
| 1565 | + ...DEFAULT_CONTAINER_FROM_REGISTRY, |
| 1566 | + affinities: { |
| 1567 | + hardware_generation: "highest-overall-performance", |
| 1568 | + }, |
| 1569 | + }, |
| 1570 | + ], |
| 1571 | + }); |
| 1572 | + |
| 1573 | + mockGetApplications([ |
| 1574 | + { |
| 1575 | + id: "abc", |
| 1576 | + name: "my-container", |
| 1577 | + instances: 0, |
| 1578 | + max_instances: 10, |
| 1579 | + created_at: new Date().toString(), |
| 1580 | + version: 1, |
| 1581 | + account_id: "1", |
| 1582 | + scheduling_policy: SchedulingPolicy.DEFAULT, |
| 1583 | + rollout_active_grace_period: 0, |
| 1584 | + configuration: { |
| 1585 | + image: "docker.io/hello:world", |
| 1586 | + disk: { |
| 1587 | + size: "2GB", |
| 1588 | + size_mb: 2000, |
| 1589 | + }, |
| 1590 | + vcpu: 0.0625, |
| 1591 | + memory: "256MB", |
| 1592 | + memory_mib: 256, |
| 1593 | + }, |
| 1594 | + constraints: { |
| 1595 | + tier: 1, |
| 1596 | + }, |
| 1597 | + durable_objects: { |
| 1598 | + namespace_id: "1", |
| 1599 | + }, |
| 1600 | + }, |
| 1601 | + ]); |
| 1602 | + |
| 1603 | + mockModifyApplication({ |
| 1604 | + affinities: { |
| 1605 | + hardware_generation: |
| 1606 | + ApplicationAffinityHardwareGeneration.HIGHEST_OVERALL_PERFORMANCE, |
| 1607 | + }, |
| 1608 | + }); |
| 1609 | + mockCreateApplicationRollout({ |
| 1610 | + description: "Progressive update", |
| 1611 | + strategy: "rolling", |
| 1612 | + kind: "full_auto", |
| 1613 | + }); |
| 1614 | + |
| 1615 | + await runWrangler("deploy index.js"); |
| 1616 | + |
| 1617 | + expect(cliStd.stdout).toMatchInlineSnapshot(` |
| 1618 | + "╭ Deploy a container application deploy changes to your application |
| 1619 | + │ |
| 1620 | + │ Container application changes |
| 1621 | + │ |
| 1622 | + ├ EDIT my-container |
| 1623 | + │ |
| 1624 | + │ [containers.constraints] |
| 1625 | + │ tier = 1 |
| 1626 | + │ + [containers.affinities] |
| 1627 | + │ + hardware_generation = \\"highest-overall-performance\\" |
| 1628 | + │ |
| 1629 | + │ |
| 1630 | + │ SUCCESS Modified application my-container (Application ID: abc) |
| 1631 | + │ |
| 1632 | + ╰ Applied changes |
| 1633 | +
|
| 1634 | + " |
| 1635 | + `); |
| 1636 | + }); |
| 1637 | + }); |
1500 | 1638 | });
|
1501 | 1639 |
|
1502 | 1640 | // This is a separate describe block because we intentionally do not mock any
|
|
0 commit comments