Files
compute/service/compute_live_test.go
zeekay 770d447c42 there is one way visor reaches a cloud
The direct token is gone: no digitalOceanToken(), no DIGITALOCEAN_ACCESS_TOKEN,
no digitalOceanToken conf key, no fallback that holds a key in this process. A
provider credential is spent through hanzoai/egress or it is not spent, and
without a carrier the platform account refuses with a sentence that says so.

Deleting the fallback fixes a reporting bug rather than only tidying. Presence
was two questions — a token OR a carrier — and the token half was the misleading
one: a revoked key is still a non-empty string, so ComputeConfigured answered
"configured" straight through a revocation, every caller took the configured
branch and failed inside it, and the hourly sweep reported zeros that read as
real data instead of "not connected". One question cannot disagree with itself.

The tests follow the same rule. What used to be asserted by setting an env var
is asserted by registering a carrier; four t.Setenv calls that cleared a variable
nothing reads any more are gone; and the live catalog test now skips on the
carrier rather than on a token, because a skip message that names the wrong
prerequisite sends the next reader to set something that does nothing.
2026-08-22 11:46:31 -07:00

69 lines
2.1 KiB
Go

// Copyright 2025 Hanzo Industries Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package service
import (
"testing"
)
// TestLiveDOCatalog exercises the real DigitalOcean catalog through the exact
// production code path (platform client -> godo -> mapping -> resale pricing).
//
// It needs a CARRIER, because that is the only way this process reaches a cloud:
// the credential is egress's. Register one and it runs; otherwise it skips, which
// is what it does in CI.
func TestLiveDOCatalog(t *testing.T) {
if !carrierRegistered() {
t.Skip("no carrier registered — the catalog is reached through egress, so there is nothing to ask")
}
regions, err := ListRegions()
if err != nil {
t.Fatalf("ListRegions: %v", err)
}
if len(regions) == 0 {
t.Fatal("expected at least one region")
}
t.Logf("regions: %d (e.g. %s = %q)", len(regions), regions[0].Slug, regions[0].Name)
sizes, err := ListSizes()
if err != nil {
t.Fatalf("ListSizes: %v", err)
}
if len(sizes) == 0 {
t.Fatal("expected at least one size")
}
for _, s := range sizes {
if s.PriceHourly <= 0 && s.PriceMonthly <= 0 {
continue
}
t.Logf("sample size: %s vcpus=%d mem=%dMB $%.5f/hr $%.2f/mo", s.Slug, s.Vcpus, s.MemoryMB, s.PriceHourly, s.PriceMonthly)
break
}
gpus, err := ListGPUSizes()
if err != nil {
t.Fatalf("ListGPUSizes: %v", err)
}
t.Logf("gpu sizes: %d", len(gpus))
for _, g := range gpus {
model := ""
if g.GPU != nil {
model = g.GPU.Model
}
t.Logf("gpu: %s model=%s $%.4f/hr $%.2f/mo", g.Slug, model, g.PriceHourly, g.PriceMonthly)
}
}