Skip to content
Snippets Groups Projects
Select Git revision
  • f4d2897b930cb546d435f64fd4b74ea5d1223dff
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS
  • openEuler-22.03-LTS-Ascend
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 4.19.90-2210.5.0
  • 5.10.0-123.0.0
  • 5.10.0-60.63.0
  • 5.10.0-60.62.0
  • 4.19.90-2210.4.0
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
33 results

page_alloc.c

Blame
  • registry_test.go 3.41 KiB
    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You 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 kubernetes
    
    import (
    	"strconv"
    	"time"
    )
    
    import (
    	"github.com/stretchr/testify/assert"
    )
    
    import (
    	"github.com/apache/dubbo-go/common"
    	"github.com/apache/dubbo-go/common/constant"
    )
    
    func (s *KubernetesRegistryTestSuite) TestRegister() {
    
    	t := s.T()
    
    	r := s.initRegistry()
    	defer r.Destroy()
    
    	url, _ := common.NewURL(
    		"dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider",
    		common.WithParamsValue(constant.CLUSTER_KEY, "mock"),
    		common.WithMethods([]string{"GetUser", "AddUser"}),
    	)
    
    	err := r.Register(url)
    	assert.NoError(t, err)
    	_, _, err = r.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers")
    	if err != nil {
    		t.Fatal(err)
    	}
    }
    
    func (s *KubernetesRegistryTestSuite) TestSubscribe() {
    
    	t := s.T()
    
    	r := s.initRegistry()
    	defer r.Destroy()
    
    	url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
    
    	listener, err := r.DoSubscribe(&url)
    	if err != nil {
    		t.Fatal(err)
    	}
    	time.Sleep(1e9)
    
    	go func() {
    		err = r.Register(url)
    		if err != nil {
    			t.Fatal(err)
    		}
    	}()
    
    	serviceEvent, err := listener.Next()
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	t.Logf("got event %s", serviceEvent)
    }
    
    func (s *KubernetesRegistryTestSuite) TestConsumerDestroy() {
    
    	t := s.T()
    
    	r := s.initRegistry()
    
    	url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider",
    		common.WithParamsValue(constant.CLUSTER_KEY, "mock"),
    		common.WithMethods([]string{"GetUser", "AddUser"}))
    
    	_, err := r.DoSubscribe(&url)
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	//listener.Close()
    	time.Sleep(1e9)
    	r.Destroy()
    
    	assert.Equal(t, false, r.IsAvailable())
    
    }
    
    func (s *KubernetesRegistryTestSuite) TestProviderDestroy() {
    
    	t := s.T()
    
    	r := s.initRegistry()
    
    	url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider",
    		common.WithParamsValue(constant.CLUSTER_KEY, "mock"),
    		common.WithMethods([]string{"GetUser", "AddUser"}))
    	err := r.Register(url)
    	assert.NoError(t, err)
    
    	time.Sleep(1e9)
    	r.Destroy()
    	assert.Equal(t, false, r.IsAvailable())
    }
    
    func (s *KubernetesRegistryTestSuite) TestNewRegistry() {
    
    	t := s.T()
    
    	regUrl, err := common.NewURL("registry://127.0.0.1:443",
    		common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
    	if err != nil {
    		t.Fatal(err)
    	}
    	_, err = newKubernetesRegistry(&regUrl)
    	if err == nil {
    		t.Fatal("not in cluster, should be a err")
    	}
    }
    
    func (s *KubernetesRegistryTestSuite) TestHandleClientRestart() {
    
    	r := s.initRegistry()
    	r.WaitGroup().Add(1)
    	go r.HandleClientRestart()
    	time.Sleep(timeSecondDuration(1))
    	r.client.Close()
    }