@@ -7,26 +7,50 @@ package main
77
88import (
99 "bytes"
10+ "context"
11+ "net"
1012 "os"
1113 "os/exec"
1214 "path/filepath"
1315 "strings"
1416 "testing"
17+ "time"
18+
19+ "tailscale.com/tstest/nettest"
20+ "tailscale.com/util/cibuild"
1521)
1622
1723func Test_generate (t * testing.T ) {
24+ nettest .SkipIfNoNetwork (t )
25+
26+ ctx , cancel := context .WithTimeout (t .Context (), 10 * time .Second )
27+ defer cancel ()
28+ if _ , err := net .DefaultResolver .LookupIPAddr (ctx , "get.helm.sh" ); err != nil {
29+ // https://github.com/helm/helm/issues/31434
30+ t .Skipf ("get.helm.sh seems down or unreachable; skipping test" )
31+ }
32+
1833 base , err := os .Getwd ()
1934 base = filepath .Join (base , "../../../" )
2035 if err != nil {
2136 t .Fatalf ("error getting current working directory: %v" , err )
2237 }
2338 defer cleanup (base )
39+
40+ helmCLIPath := filepath .Join (base , "tool/helm" )
41+ if out , err := exec .Command (helmCLIPath , "version" ).CombinedOutput (); err != nil && cibuild .On () {
42+ // It's not just DNS. Azure is generating bogus certs within GitHub Actions at least for
43+ // helm. So try to run it and see if we can even fetch it.
44+ //
45+ // https://github.com/helm/helm/issues/31434
46+ t .Skipf ("error fetching helm; skipping test in CI: %v, %s" , err , out )
47+ }
48+
2449 if err := generate (base ); err != nil {
2550 t .Fatalf ("CRD template generation: %v" , err )
2651 }
2752
2853 tempDir := t .TempDir ()
29- helmCLIPath := filepath .Join (base , "tool/helm" )
3054 helmChartTemplatesPath := filepath .Join (base , "cmd/k8s-operator/deploy/chart" )
3155 helmPackageCmd := exec .Command (helmCLIPath , "package" , helmChartTemplatesPath , "--destination" , tempDir , "--version" , "0.0.1" )
3256 helmPackageCmd .Stderr = os .Stderr
0 commit comments