package io.wdd.server.func;

import io.wdd.func.auto.beans.ProjectDeployContext;
import io.wdd.func.auto.service.AppFuncScheduler;
import io.wdd.func.auto.service.BaseFuncScheduler;
import io.wdd.func.auto.service.HarborFuncScheduler;
import io.wdd.server.beans.po.ServerInfoPO;
import io.wdd.server.beans.request.ServerQueryEntity;
import io.wdd.server.coreService.CoreServerService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

@SpringBootTest
public class TestBaseFuncScheduler {

    @Resource
    BaseFuncScheduler baseFuncScheduler;

    @Resource
    HarborFuncScheduler harborFuncScheduler;

    @Resource
    AppFuncScheduler appFuncScheduler;

    @Resource
    CoreServerService serverService;

    @Test
    public void testRunProcedure() {

        ProjectDeployContext projectDeployContext = new ProjectDeployContext();

//        projectDeployContext.setProjectId(1716372290994155522L); // vultr
        projectDeployContext.setProjectId(1722453318596550657L); // lappro


        ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
        // exsi server
        serverQueryEntity.setServerName("Chengdu-amd64-99");

        // lappro
//        serverQueryEntity.setServerName("Chengdu-amd64-65");

        ServerInfoPO serverInfoPO = serverService
                .serverGetByPage(serverQueryEntity)
                .getRecords()
                .get(0);

        System.out.println("serverInfoPO = " + serverInfoPO);

        projectDeployContext.setMasterNode(serverInfoPO);


//        baseFuncScheduler.runProcedure(projectDeployContext);

//        harborFuncScheduler.runProcedure(projectDeployContext);

        appFuncScheduler.runProcedure(projectDeployContext);
    }

}
