fix: fix incomplete cleanup in tunnel.json and zombie process in functional test
parent
1edaec55f4
commit
3c42f1ce99
|
@ -87,7 +87,10 @@ func (r *persistentRegistry) Register(tunnel *ID) (rerr error) {
|
||||||
|
|
||||||
alreadyExists := false
|
alreadyExists := false
|
||||||
for i, t := range tunnels {
|
for i, t := range tunnels {
|
||||||
if t.Route.Equal(tunnel.Route) {
|
// it is allowed for multiple minikube clusters to have multiple tunnels simultaneously
|
||||||
|
// it is possible that an old tunnel from an old profile has duplicated route information
|
||||||
|
// so we need to check both machine name and route information
|
||||||
|
if tunnel.MachineName == t.MachineName && t.Route.Equal(tunnel.Route) {
|
||||||
isRunning, err := checkIfRunning(t.Pid)
|
isRunning, err := checkIfRunning(t.Pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error checking whether conflicting tunnel (%v) is running: %s", t, err)
|
return fmt.Errorf("error checking whether conflicting tunnel (%v) is running: %s", t, err)
|
||||||
|
|
|
@ -79,7 +79,7 @@ func TestFunctional(t *testing.T) {
|
||||||
|
|
||||||
// TestFunctionalNewestKubernetes are functionality run functional tests using NewestKubernetesVersion
|
// TestFunctionalNewestKubernetes are functionality run functional tests using NewestKubernetesVersion
|
||||||
func TestFunctionalNewestKubernetes(t *testing.T) {
|
func TestFunctionalNewestKubernetes(t *testing.T) {
|
||||||
if strings.Contains(*startArgs, "--kubernetes-version") {
|
if strings.Contains(*startArgs, "--kubernetes-version") || constants.NewestKubernetesVersion == constants.DefaultKubernetesVersion {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
}
|
}
|
||||||
k8sVersionString := constants.NewestKubernetesVersion
|
k8sVersionString := constants.NewestKubernetesVersion
|
||||||
|
@ -91,7 +91,7 @@ func TestFunctionalNewestKubernetes(t *testing.T) {
|
||||||
|
|
||||||
func testFunctional(t *testing.T, k8sVersion string) {
|
func testFunctional(t *testing.T, k8sVersion string) {
|
||||||
profile := UniqueProfileName("functional")
|
profile := UniqueProfileName("functional")
|
||||||
ctx := context.WithValue(context.Background(), "k8sVersion", k8sVersion)
|
ctx := context.WithValue(context.Background(), ContextKey("k8sVersion"), k8sVersion)
|
||||||
ctx, cancel := context.WithTimeout(ctx, Minutes(40))
|
ctx, cancel := context.WithTimeout(ctx, Minutes(40))
|
||||||
defer func() {
|
defer func() {
|
||||||
if !*cleanup {
|
if !*cleanup {
|
||||||
|
|
|
@ -432,4 +432,9 @@ func validateTunnelDelete(_ context.Context, t *testing.T, _ string) {
|
||||||
checkRoutePassword(t)
|
checkRoutePassword(t)
|
||||||
// Stop tunnel
|
// Stop tunnel
|
||||||
tunnelSession.Stop(t)
|
tunnelSession.Stop(t)
|
||||||
|
// prevent the child process from becoming a defunct zombie process
|
||||||
|
if err := tunnelSession.cmd.Wait(); err != nil {
|
||||||
|
t.Logf("failed to stop process: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,9 +119,11 @@ func StartArgs() []string {
|
||||||
return strings.Split(*startArgs, " ")
|
return strings.Split(*startArgs, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ContextKey string
|
||||||
|
|
||||||
func StartArgsWithContext(ctx context.Context) []string {
|
func StartArgsWithContext(ctx context.Context) []string {
|
||||||
res := strings.Split(*startArgs, " ")
|
res := strings.Split(*startArgs, " ")
|
||||||
value := ctx.Value("k8sVersion")
|
value := ctx.Value(ContextKey("k8sVersion"))
|
||||||
if value != nil && value != "" {
|
if value != nil && value != "" {
|
||||||
res = append(res, fmt.Sprintf("--kubernetes-version=%s", value))
|
res = append(res, fmt.Sprintf("--kubernetes-version=%s", value))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue