summaryrefslogtreecommitdiff
path: root/tests/docker-test.sh
blob: 71e7f20c6d99fa4008966962450e3a2e9ef59877 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash

start_docker() {
    hostname=$1
    group=$2
    ansible-playbook -u root -v --extra-vars "docker_hostname=$hostname docker_groupname=$group" \
        ./tests/docker-test.yml
    event-watcher.py -n -o
}

start_docker_compose() {
    cd $CI_DATA
    docker-compose up -d
}


jenkins_master()
{
    TARGET=${1:-ci.linaro.org}

    start_docker $TARGET jenkins_master
    ansible-playbook --skip-tags="nfs,ssh-ldap,letsencrypt,vpn" \
        -i docker_hosts \
        ./jenkins-master.yml
}

gerrit()
{
    TARGET=${1:-review.linaro.org}

    start_docker $TARGET gerrit
    ansible-playbook -vvv --skip-tags="imapd" \
        -l $TARGET \
        -i docker_hosts \
        ./gerrit.yml
}

ssh_ldap()
{
    TARGET=${1:-mmwg-hackbox.linaro.org}

    start_docker $TARGET ssh-ldap
    ansible-playbook \
        -i docker_hosts \
        ./ssh-ldap.yml
}

start_git()
{
    TARGET=${1:-git-ap.linaro.org}

    start_docker $TARGET git
    ansible-playbook \
        -i docker_hosts \
        ./git.yml
}

tf_ci_stack()
{
    export CI_DATA="$(dirname $(readlink -f $0))/tf-ci-stack/"
    if [ ! -e $CI_DATA/swarm.txt ]
    then
        # This assumes docker on local machine has TCP open at port 2376
        # Add as many docker hosts as you have in your home network
        echo 10.50.0.1:2376 >> $CI_DATA/swarm.txt
    fi
    start_docker_compose
    echo FIXME sleeping till jenkins is ready
    sleep 90
    (
        mkdir -p $CI_DATA/work
        cd $CI_DATA/work
        [ -e ci-yadp-builder ] || git clone https://git.linaro.org/infrastructure/ci-yadp-builder.git
        ( cd ci-yadp-builder;
            # only deploy swarm
            cp ../../hosts-simulator .
            # replace rsa auth with user/password
            cp ../../docker_vol_x86_64.txt docker_vol_x86_64.yml
            cp ../../shadow /tmp
            python3 ./yadp_builder.py --server http://localhost:8080 -i hosts-simulator -u admin -p hunter2 )
        [ -e configs ] || git clone https://git.linaro.org/ci/job/configs.git
        ( cd configs;
            cp ../../jenkins_jobs.ini .
            jenkins-jobs --conf jenkins_jobs.ini update swarm-demo.yaml
        )
    )


}

ci_stack()
{
    export CI_DATA="$(dirname $(readlink -f $0))/ci-stack/"
    if [ ! -e $CI_DATA/swarm.txt ]
    then
        # This assumes docker on local machine has TCP open at port 2376
        # Add as many docker hosts as you have in your home network
        echo 10.50.0.1:2376 >> $CI_DATA/swarm.txt
    fi
    start_docker_compose
    echo FIXME sleeping till jenkins is ready
    sleep 90
    (
        mkdir -p $CI_DATA/work
        cd $CI_DATA/work
        [ -e ci-yadp-builder ] || git clone https://git.linaro.org/infrastructure/ci-yadp-builder.git
        ( cd ci-yadp-builder;
            # only deploy swarm
            cp ../../hosts-simulator .
            # replace rsa auth with user/password
            cp ../../docker_vol_x86_64.txt docker_vol_x86_64.yml
            cp ../../shadow /tmp
            python3 ./yadp_builder.py --server http://localhost:8080 -i hosts-simulator -u admin -p hunter2 )
        [ -e configs ] || git clone https://git.linaro.org/ci/job/configs.git
        ( cd configs;
            cp ../../jenkins_jobs.ini .
            jenkins-jobs --conf jenkins_jobs.ini update swarm-demo.yaml
        )
    )

}

case $1 in
    tf-ci-stack)
        tf_ci_stack
        ;;
    ci-stack)
        ci_stack
        ;;
    jenkins-master)
        jenkins_master $2
        ;;
    gerrit)
        gerrit $2
        ;;
    git)
        start_git $2
        ;;
    ssh-ldap)
        ssh_ldap $2
        ;;
    *)
        echo usage $0 service-to-test
        ;;
esac