@ -52,7 +52,7 @@ func TestContainerBoot(t *testing.T) {
}
}
defer kube . Close ( )
defer kube . Close ( )
tailscaledConf := & ipn . ConfigVAlpha { AuthKey : func ( s string ) * string { return & s } ( "foo" ) , Version : "alpha0" }
tailscaledConf := & ipn . ConfigVAlpha { AuthKey : ptr . To ( "foo" ) , Version : "alpha0" }
tailscaledConfBytes , err := json . Marshal ( tailscaledConf )
tailscaledConfBytes , err := json . Marshal ( tailscaledConf )
if err != nil {
if err != nil {
t . Fatalf ( "error unmarshaling tailscaled config: %v" , err )
t . Fatalf ( "error unmarshaling tailscaled config: %v" , err )
@ -116,6 +116,9 @@ func TestContainerBoot(t *testing.T) {
// WantFiles files that should exist in the container and their
// WantFiles files that should exist in the container and their
// contents.
// contents.
WantFiles map [ string ] string
WantFiles map [ string ] string
// WantFatalLog is the fatal log message we expect from containerboot.
// If set for a phase, the test will finish on that phase.
WantFatalLog string
}
}
runningNotify := & ipn . Notify {
runningNotify := & ipn . Notify {
State : ptr . To ( ipn . Running ) ,
State : ptr . To ( ipn . Running ) ,
@ -349,12 +352,57 @@ func TestContainerBoot(t *testing.T) {
"/usr/bin/tailscaled --socket=/tmp/tailscaled.sock --state=mem: --statedir=/tmp" ,
"/usr/bin/tailscaled --socket=/tmp/tailscaled.sock --state=mem: --statedir=/tmp" ,
"/usr/bin/tailscale --socket=/tmp/tailscaled.sock up --accept-dns=false --authkey=tskey-key" ,
"/usr/bin/tailscale --socket=/tmp/tailscaled.sock up --accept-dns=false --authkey=tskey-key" ,
} ,
} ,
WantFiles : map [ string ] string {
"proc/sys/net/ipv4/ip_forward" : "1" ,
"proc/sys/net/ipv6/conf/all/forwarding" : "0" ,
} ,
} ,
} ,
{
{
Notify : runningNotify ,
Notify : runningNotify ,
} ,
} ,
} ,
} ,
} ,
} ,
{
Name : "egress_proxy_fqdn_ipv6_target_on_ipv4_host" ,
Env : map [ string ] string {
"TS_AUTHKEY" : "tskey-key" ,
"TS_TAILNET_TARGET_FQDN" : "ipv6-node.test.ts.net" , // resolves to IPv6 address
"TS_USERSPACE" : "false" ,
"TS_TEST_FAKE_NETFILTER_6" : "false" ,
} ,
Phases : [ ] phase {
{
WantCmds : [ ] string {
"/usr/bin/tailscaled --socket=/tmp/tailscaled.sock --state=mem: --statedir=/tmp" ,
"/usr/bin/tailscale --socket=/tmp/tailscaled.sock up --accept-dns=false --authkey=tskey-key" ,
} ,
WantFiles : map [ string ] string {
"proc/sys/net/ipv4/ip_forward" : "1" ,
"proc/sys/net/ipv6/conf/all/forwarding" : "0" ,
} ,
} ,
{
Notify : & ipn . Notify {
State : ptr . To ( ipn . Running ) ,
NetMap : & netmap . NetworkMap {
SelfNode : ( & tailcfg . Node {
StableID : tailcfg . StableNodeID ( "myID" ) ,
Name : "test-node.test.ts.net" ,
Addresses : [ ] netip . Prefix { netip . MustParsePrefix ( "100.64.0.1/32" ) } ,
} ) . View ( ) ,
Peers : [ ] tailcfg . NodeView {
( & tailcfg . Node {
StableID : tailcfg . StableNodeID ( "ipv6ID" ) ,
Name : "ipv6-node.test.ts.net" ,
Addresses : [ ] netip . Prefix { netip . MustParsePrefix ( "::1/128" ) } ,
} ) . View ( ) ,
} ,
} ,
} ,
WantFatalLog : "no forwarding rules for egress addresses [::1/128], host supports IPv6: false" ,
} ,
} ,
} ,
{
{
Name : "authkey_once" ,
Name : "authkey_once" ,
Env : map [ string ] string {
Env : map [ string ] string {
@ -697,6 +745,25 @@ func TestContainerBoot(t *testing.T) {
var wantCmds [ ] string
var wantCmds [ ] string
for i , p := range test . Phases {
for i , p := range test . Phases {
lapi . Notify ( p . Notify )
lapi . Notify ( p . Notify )
if p . WantFatalLog != "" {
err := tstest . WaitFor ( 2 * time . Second , func ( ) error {
state , err := cmd . Process . Wait ( )
if err != nil {
return err
}
if state . ExitCode ( ) != 1 {
return fmt . Errorf ( "process exited with code %d but wanted %d" , state . ExitCode ( ) , 1 )
}
waitLogLine ( t , time . Second , cbOut , p . WantFatalLog )
return nil
} )
if err != nil {
t . Fatal ( err )
}
// Early test return, we don't expect the successful startup log message.
return
}
wantCmds = append ( wantCmds , p . WantCmds ... )
wantCmds = append ( wantCmds , p . WantCmds ... )
waitArgs ( t , 2 * time . Second , d , argFile , strings . Join ( wantCmds , "\n" ) )
waitArgs ( t , 2 * time . Second , d , argFile , strings . Join ( wantCmds , "\n" ) )
err := tstest . WaitFor ( 2 * time . Second , func ( ) error {
err := tstest . WaitFor ( 2 * time . Second , func ( ) error {