go.ligato.io/vpp-agent/v3@v3.5.0/tests/e2e/000_initial_test.go (about)

     1  //  Copyright (c) 2019 Cisco and/or its affiliates.
     2  //
     3  //  Licensed under the Apache License, Version 2.0 (the "License");
     4  //  you may not use this file except in compliance with the License.
     5  //  You may obtain a copy of the License at:
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  //  Unless required by applicable law or agreed to in writing, software
    10  //  distributed under the License is distributed on an "AS IS" BASIS,
    11  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //  See the License for the specific language governing permissions and
    13  //  limitations under the License.
    14  
    15  package e2e
    16  
    17  import (
    18  	"testing"
    19  
    20  	. "github.com/onsi/gomega"
    21  
    22  	"go.ligato.io/vpp-agent/v3/proto/ligato/kvscheduler"
    23  	ns "go.ligato.io/vpp-agent/v3/proto/ligato/linux/namespace"
    24  	. "go.ligato.io/vpp-agent/v3/tests/e2e/e2etest"
    25  )
    26  
    27  func TestAgentInSync(t *testing.T) {
    28  	ctx := Setup(t)
    29  	defer ctx.Teardown()
    30  
    31  	ctx.Expect(ctx.AgentInSync()).To(BeTrue())
    32  }
    33  
    34  func TestStartStopMicroservice(t *testing.T) {
    35  	ctx := Setup(t)
    36  	defer ctx.Teardown()
    37  
    38  	const msName = "microservice1"
    39  	key := ns.MicroserviceKey(MsNamePrefix + msName)
    40  
    41  	ctx.StartMicroservice(msName)
    42  	ctx.Eventually(ctx.Agent.GetValueStateByKeyClb(key)).Should(Equal(kvscheduler.ValueState_OBTAINED))
    43  
    44  	ctx.StopMicroservice(msName)
    45  	ctx.Eventually(ctx.Agent.GetValueStateByKeyClb(key)).Should(Equal(kvscheduler.ValueState_NONEXISTENT))
    46  }
    47  
    48  func TestStartStopAgent(t *testing.T) {
    49  	ctx := Setup(t)
    50  	defer ctx.Teardown()
    51  
    52  	const agentName = "agent1"
    53  	key := ns.MicroserviceKey(agentName)
    54  
    55  	ctx.StartAgent(agentName)
    56  	ctx.Eventually(ctx.Agent.GetValueStateByKeyClb(key)).Should(Equal(kvscheduler.ValueState_OBTAINED))
    57  
    58  	ctx.StopAgent(agentName)
    59  	ctx.Eventually(ctx.Agent.GetValueStateByKeyClb(key)).Should(Equal(kvscheduler.ValueState_NONEXISTENT))
    60  }